#!/usr/bin/env bash function usage() { if [ -n "$1" ];then echo -e "\nError: $1" fi cat< -u Example: `basename $0` -h wf.oopen.de -u chris WF network-name possible values are: NONE-WF NONE-CKUBU 123 AK AKB ANW-URB ANW-KM B3-Bornim CKUBU FLR-BRB GA-AL GA-Ersatz GA-NH GA-Schloss JONAS Kanzlei-Kiel MBR OOLM OPP ReachOut SPR-BE WF EOF exit } manage_files() { for file in $* ; do if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/$file ] ; then scp -o User=$remote_user ${remote_host}:${_network}-config/$file . ssh -l $remote_user ${remote_host} "rm ${_network}-config/$file" fi done } manage_archives() { for archive in $* ; do if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/$archive" ]; then scp -o User=$remote_user ${remote_host}:${_network}-config/$archive . gunzip < $archive | tar -xpf - rm -f $archive ssh -l $remote_user ${remote_host} "rm ${_network}-config/$archive" fi done } while getopts h:u: opt ; do case $opt in h) remote_host="$OPTARG" ;; u) remote_user="$OPTARG" ;; *) usage ;; esac done if [ -z "$remote_host" ]; then usage "Remote host not given" fi if [ -z "$remote_user" ]; then usage "Remote host not given" fi shift `expr $OPTIND - 1` [ $# -ne "1" ] && usage "wrong number of arguments" _network=$1 office_base_dir=$HOME/Office_Networks office_dir=${office_base_dir}/${_network} mkdir -p $office_dir cd $office_dir # - Nameserver Bind # - /etc/bind/* # - manage_archives bind_${_network}.tar.gz # - OpenVPN: # - /etc/openvpn/* # - # - /root/.openvpn # - archives="openvpn_${_network}.tar.gz root-dot-opennvpndir_${_network}.tar.gz" manage_archives $archives # - DynDNS # - # - /etc/ddclient.conf # - manage_files ddclient.conf.${_network} # - DHCP Server # - # - /etc/dhcp/dhcpd.conf - /etc/dhcp3/dhcpd.conf # - /etc/dhcp/dhcpd6.conf - /etc/dhcp3/dhcpd6.conf # - # - hosts.lan.conf # dhcp failover kanzlei kiel # - hosts.w-lan.conf # dhcp failover kanzlei kiel # - # - /etc/init.d/isc-dhcp6-server # - files="dhcpd.conf.${_network} dhcpd6.conf.${_network} isc-dhcp6-server.${_network} hosts.lan.conf.${_network} hosts.w-lan.conf.${_network} default_isc-dhcp-server.${_network}" manage_files "$files" # - DSL PPP # - # - /etc/ppp/peers/* # - # - /etc/ppp/pap-secrets # - /etc/ppp/chap-secrets # - # - /etc/ppp/ip-up.d/email_notice # - manage_files pap-secrets.${_network} chap-secrets.${_network} email_notice.${_network} manage_archives etc_ppp_peers_${_network}.tar.gz # - Postfix SMTP # - # - /etc/postfix/main.cf # - /etc/mailname # - /etc/postfix/generic # - /etc/postfix/generic.db # - /etc/postfix/sasl_passwd # - /etc/postfix/sasl_passwd.db # - files="main.cf.${_network} mailname.${_network} sasl_passwd.${_network} sasl_passwd.db.${_network} generic.${_network} generic.db.${_network}" manage_files $files # - Netzwerk: # - /etc/hostname # - /etc/hosts # - /etc/network/interfaces # - /etc/resolv.conf files="hostname.${_network} hosts.${_network} interfaces.${_network} resolv.conf.${_network} hostapd.conf.${_network}" manage_files $files # - /root/bin directory # - manage_archives root_bin_${_network}.tar.gz # - /usr/local/src directory # - manage_archives usr_local_src_${_network}.tar.gz # - /usr/local/sbin directory # - manage_archives usr_local_sbin_${_network}.tar.gz # - Firewall # - # - /etc/systemd/system/ipt-firewall.service # - /etc/systemd/system/ip6t-firewall.service # - # - /etc/init.d/ipt-firewall # - /etc/init.d/ipt-firewall # - # - /etc/ipt-firewall/* # - manage_archives etc_ipt-firewall_${_network}.tar.gz files="ipt-firewall.service.${_network} ip6t-firewall.service.${_network} ipt-firewall.${_network} ip6t-firewall.${_network} ipt-firewall-gateway.${_network} ip6t-firewall-gateway.${_network}" manage_files $files # - Check Script Onlinestatus # - # - /etc/systemd/system/check_net.service # - # - /usr/local/sbin/check_net.sh # - /usr/local/sbin/netconfig.sh # - # - /etc/check_net/* # - # - /etc/logrotate.d/check_net # - manage_archives etc_check_net_${_network}.tar.gz files="check_net.service.${_network} check_net-logrotate.${_network}" manage_files $files # - Other # - # - /etc/rc.local # - /var/spool/cron/crontabs/root # - /usr/local/igmpproxy/etc/igmpproxy.conf # - /etc/aiccu.conf # - /etc/default/aiccu # - /etc/radvd.conf # - files="rc.local.${_network} cron_root.${_network} igmpproxy.conf.${_network} aiccu.conf.${_network} aiccu.${_network} radvd.conf.${_network}" manage_files $files cat < $office_dir/README.txt Notice: You have to change some configuration files becaus the because the configuration of network interfaces must not be equal. !! Take care, to use the right device names !! Maybe they are called i.e. 'enp0sXX', but you can rename it. See also : README.rename.netdevices For the backup gateway host: eth1 --> LAN eth2 --> WAN or ppp0 (DSL device) eth0 --> WLAN or second LAN or what ever or br0 --> WLAN or second LAN or what ever So you have to change the following files dsl-provider.${_network}: ppp0 comes over eth2 interfaces.${_network}: see above default_isc-dhcp-server.${_network} ipt-firewall.${_network}: LAN device (mostly $local_if_1) = eth1 second LAN WLAN or what ever (if present) = eth0 EOF cat $office_dir/README.txt #rm /tmp/README$$ exit 0