From: Christian Heller Date: Sat, 12 Dec 2015 12:08:25 +0000 (+0100) Subject: Move more executables into config/bin. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/process?a=commitdiff_plain;h=81429a6325f9b45ef6cbd6a7a2b390ae1c7e8ba6;p=config Move more executables into config/bin. --- diff --git a/bin/setup_opendkim.sh b/bin/setup_opendkim.sh new file mode 100755 index 0000000..ce1e3d5 --- /dev/null +++ b/bin/setup_opendkim.sh @@ -0,0 +1,65 @@ +#!/bin/sh +set -e +selector=$1 +file=$2 + +if [ ! -n "$selector" ]; then + cat << EOF +Usage: $0 SELECTOR [KEYFILE] - set up DKIM system and configuration + +If existing KEYFILE is given, set up DKIM to use SELECTOR and apply key from +KEYFILE. + +If existing KEYFILE is not given, generate KEYFILE and DNS TXT file for +SELECTOR. +EOF + exit +fi + +if [ ! "$(id -u)" -eq "0" ]; then + echo "Must be run as root." + exit 1 +fi + +set -x +apt-get -y install opendkim + +if [ ! -n "$file" ]; then + apt-get -y install opendkim-tools + opendkim-genkey -d plomlompom.com -s $selector + apt-get -y --purge autoremove opendkim-tools + set +x + echo + echo 'Generated key file at '$selector'.private.' + echo 'Also generated '$selector'.txt, APPLY its content below to your DNS' \ + 'record.' + echo 'AFTER the waiting time for DNS propagation RERUN this script with' \ + 'the key file as SECOND parameter (still use selector as first one).' + echo + cat $selector.txt +else + if [ ! -f "$file" ]; then + set +x + echo + echo "Keyfile $file does not exist." + exit 1 + fi + cp ~/config/systemfiles/opendkim.conf /etc/opendkim.conf + sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf + mkdir -p /etc/opendkim + if [ -f /etc/opendkim/dkim.key ]; then + cp /etc/opendkim/dkim.key /etc/opendkim/dkim.key~ + fi + cp $file /etc/opendkim/dkim.key + cp ~/config/systemfiles/main.cf /etc/postfix/main.cf + cat >> /etc/postfix/main.cf << EOF + +# Use opendkim at given port as mail filter. +non_smtpd_milters = inet:localhost:12301 +EOF + service opendkim restart + service postfix restart + set +x + echo + echo 'Ensure the DKIM TXT entry in your DNS record matches!' +fi diff --git a/bin/symlink.sh b/bin/symlink.sh new file mode 100755 index 0000000..412b55d --- /dev/null +++ b/bin/symlink.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -x + +dir_minimal=~/config/dotfiles/minimal +dir_user_minimal=~/config/dotfiles/user/minimal +dir_user_thinkpad=~/config/dotfiles/user/thinkpad +dir_user_server=~/config/dotfiles/user/server +dir_root=~/config/dotfiles/root +homedir=`echo ~` +find ~ -lname $homedir'/config/*' -delete +for file in `ls $dir_minimal`; do + ln -fs $dir_minimal/$file ~/.$file +done +if [ "$(id -u)" -eq "0" ]; then + for file in `ls $dir_root`; do + ln -fs $dir_root/$file ~/.$file + done +else + for file in `ls $dir_user_minimal`; do + ln -fs $dir_user_minimal/$file ~/.$file + done + if [ "$1" = "thinkpad" ]; then + for file in `ls $dir_user_thinkpad`; do + ln -fs $dir_user_thinkpad/$file ~/.$file + done + elif [ "$1" = "server" ]; then + for file in `ls $dir_user_server`; do + ln -fs $dir_user_server/$file ~/.$file + done + fi +fi diff --git a/jessie_start_server.sh b/jessie_start_server.sh index a97bed8..b3e20d2 100755 --- a/jessie_start_server.sh +++ b/jessie_start_server.sh @@ -69,14 +69,14 @@ locale-gen apt-get -y install ca-certificates apt-get -y install git git clone http://github.com/plomlompom/config -config/symlink.sh +config/bin/symlink.sh # Add user. Remove old user's config/ if it exists. useradd -m -s /bin/bash plom rm /home/plom/.bashrc rm -rf /home/plom/config su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config' -su plom -c '/home/plom/config/symlink.sh server' +su plom -c '/home/plom/config/bin/symlink.sh server' # Set up editor. apt-get -y install vim diff --git a/jessie_start_thinkpad.sh b/jessie_start_thinkpad.sh index b0b13ee..3b5a544 100755 --- a/jessie_start_thinkpad.sh +++ b/jessie_start_thinkpad.sh @@ -69,13 +69,13 @@ service keyboard-setup restart apt-get -y install ca-certificates apt-get -y install git git clone http://github.com/plomlompom/config -config/symlink.sh +config/bin/symlink.sh # Add user. Remove old user's config/ if it exists. useradd -m -s /bin/bash plom rm -rf /home/plom/config su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config' -su plom -c '/home/plom/config/symlink.sh thinkpad' +su plom -c '/home/plom/config/bin/symlink.sh thinkpad' # Set up editor. apt-get -y install vim diff --git a/mails/server_postinstall_finished b/mails/server_postinstall_finished index 9cbd8c2..7e403cc 100644 --- a/mails/server_postinstall_finished +++ b/mails/server_postinstall_finished @@ -8,8 +8,8 @@ perform the following tasks: - ensure the following DNS TXT record for @: v=spf1 mx -all -- run (as root) config/setup_opendkim.sh $selector to set up system for DKIM key - signing, with a second parameter $keyfile if a key already exists; without +- run (as root) config/bin/setup_opendkim.sh $selector to set up system for DKIM + key signing, with a second parameter $keyfile if a key already exists; without second parameter, this will generate a new key and print the DNS record to add - in the screen weechat/bitlbee session (run "screen -dr"), switch to the diff --git a/setup_opendkim.sh b/setup_opendkim.sh deleted file mode 100755 index ce1e3d5..0000000 --- a/setup_opendkim.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -set -e -selector=$1 -file=$2 - -if [ ! -n "$selector" ]; then - cat << EOF -Usage: $0 SELECTOR [KEYFILE] - set up DKIM system and configuration - -If existing KEYFILE is given, set up DKIM to use SELECTOR and apply key from -KEYFILE. - -If existing KEYFILE is not given, generate KEYFILE and DNS TXT file for -SELECTOR. -EOF - exit -fi - -if [ ! "$(id -u)" -eq "0" ]; then - echo "Must be run as root." - exit 1 -fi - -set -x -apt-get -y install opendkim - -if [ ! -n "$file" ]; then - apt-get -y install opendkim-tools - opendkim-genkey -d plomlompom.com -s $selector - apt-get -y --purge autoremove opendkim-tools - set +x - echo - echo 'Generated key file at '$selector'.private.' - echo 'Also generated '$selector'.txt, APPLY its content below to your DNS' \ - 'record.' - echo 'AFTER the waiting time for DNS propagation RERUN this script with' \ - 'the key file as SECOND parameter (still use selector as first one).' - echo - cat $selector.txt -else - if [ ! -f "$file" ]; then - set +x - echo - echo "Keyfile $file does not exist." - exit 1 - fi - cp ~/config/systemfiles/opendkim.conf /etc/opendkim.conf - sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf - mkdir -p /etc/opendkim - if [ -f /etc/opendkim/dkim.key ]; then - cp /etc/opendkim/dkim.key /etc/opendkim/dkim.key~ - fi - cp $file /etc/opendkim/dkim.key - cp ~/config/systemfiles/main.cf /etc/postfix/main.cf - cat >> /etc/postfix/main.cf << EOF - -# Use opendkim at given port as mail filter. -non_smtpd_milters = inet:localhost:12301 -EOF - service opendkim restart - service postfix restart - set +x - echo - echo 'Ensure the DKIM TXT entry in your DNS record matches!' -fi diff --git a/symlink.sh b/symlink.sh deleted file mode 100755 index 412b55d..0000000 --- a/symlink.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -set -x - -dir_minimal=~/config/dotfiles/minimal -dir_user_minimal=~/config/dotfiles/user/minimal -dir_user_thinkpad=~/config/dotfiles/user/thinkpad -dir_user_server=~/config/dotfiles/user/server -dir_root=~/config/dotfiles/root -homedir=`echo ~` -find ~ -lname $homedir'/config/*' -delete -for file in `ls $dir_minimal`; do - ln -fs $dir_minimal/$file ~/.$file -done -if [ "$(id -u)" -eq "0" ]; then - for file in `ls $dir_root`; do - ln -fs $dir_root/$file ~/.$file - done -else - for file in `ls $dir_user_minimal`; do - ln -fs $dir_user_minimal/$file ~/.$file - done - if [ "$1" = "thinkpad" ]; then - for file in `ls $dir_user_thinkpad`; do - ln -fs $dir_user_thinkpad/$file ~/.$file - done - elif [ "$1" = "server" ]; then - for file in `ls $dir_user_server`; do - ln -fs $dir_user_server/$file ~/.$file - done - fi -fi