Initial import

This commit is contained in:
Christoph 2017-02-21 15:29:33 +01:00
commit 6c8a7a75ec
4 changed files with 1097 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/BAK/*

556
change_network_gateway.sh Executable file
View File

@ -0,0 +1,556 @@
#!/usr/bin/env bash
base_dir=/root/Office_Networks
chown -R root:root $base_dir
function usage() {
if [ -n "$1" ];then
echo -e "\nError: $1"
fi
cat<<EOF
`basename $0` - configure that gateway for a certain network
Usage: `basename $0` <network-name>
network-name possible values are:
NONE-WF
NONE-CKUBU
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
Notice:
!! To change the network, you have to chroot into /ro !!
remountrw
rebind on
chroot /ro
`basename $0` <network-name>
exit
rebind off
remountro
EOF
exit
}
function echo_OK() {
echo -en "\\033[45G[ \\033[1;32mOK\\033[0;39m ]\n"
}
function echo_FAILED() {
echo -en "\\033[45G[ \\033[1;31mFAIL\\033[0;39m ]\n"
}
[ $# -ne "1" ] && usage "wrong number of arguments"
case $1 in
CKUBU)
network=$1
_igmproxy=true
_add_support_if=true
;;
NONE-CKUBU|NONE-WF)
network=$1
_igmproxy=false
_add_support_if=false
;;
AKB|ANW-URB|ANW-KM|B3-Bornim|FLR-BRB|GA-AL|GA-Ersatz|GA-NH|GA-Schloss|JONAS|Kanzlei-Kiel|MBR|OOLM|OPP|ReachOut|SPR-BE|WF)
network=$1
_igmproxy=false
_add_support_if=true
;;
*)
usage
exit 1
esac
echo ""
echo "Configure gateway for network \"$network\".."
# - Nameserver Bind
# - /etc/bind/*
# -
echo -en "\tNameserver settings.."
_rval=true
rm -rf /etc/bind
if [ "$?" != "0" ]; then
_rval=false
fi
mkdir -p /var/log/named
if [ "$?" != "0" ]; then
_rval=false
fi
chown bind:bind /var/log/named > /dev/null 2>&1
cp -a ${base_dir}/${network}/bind /etc/bind
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
# - OpenVPN:
# - /etc/openvpn/*
# -
echo -en "\tVPN settings.."
/etc/init.d/openvpn stop > /dev/null
rm -rf /etc/openvpn
cp -a ${base_dir}/${network}/openvpn /etc/openvpn
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
if [ -d "/root/.openvpn" ]; then
echo -en "\tCleanup private VPN settings for user root.."
rm -rf /root/.openvpn
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -d "${base_dir}/${network}/.openvpn" ];then
echo -en "\tPrivate VPN settings for root user.."
cp -a ${base_dir}/${network}/.openvpn /root/.openvpn
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
chown -R root:root /root/.openvpn
chmod 700 /root/.openvpn
else
if [ -d "/root/.openvpn" ];then
rm /root/.openvpn
fi
fi
# - DynDNS
# - /etc/ddclient.conf
if [ -f ${base_dir}/${network}/ddclient.conf.${network} ];then
echo -en "\tConfigure DynDNS.."
cp -a ${base_dir}/${network}/ddclient.conf.${network} /etc/ddclient.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
# - DHCP Server
# - /etc/dhcp/dhcpd.conf
echo -en "\tDHCP Server settings.."
if [ -d /etc/dhcp ]; then
cp -a ${base_dir}/${network}/dhcpd.conf.${network} /etc/dhcp/dhcpd.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
elif [ -d /etc/dhcp3 ];then
cp -a ${base_dir}/${network}/dhcpd.conf.${network} /etc/dhcp3/dhcpd.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -f ${base_dir}/${network}/dhcpd6.conf.${network} ];then
echo -en "\tDHCP IPv6 Server settings.."
if [ -d /etc/dhcp ]; then
cp -a ${base_dir}/${network}/dhcpd6.conf.${network} /etc/dhcp/dhcpd6.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
elif [ -d /etc/dhcp3 ];then
cp -a ${base_dir}/${network}/dhcpd6.conf.${network} /etc/dhcp3/dhcpd6.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
fi
#if [ -f "${base_dir}/${network}/isc-dhcp6-server.${network}" ]; then
# echo -en "\tINIT-Script isc-dhcp6-server.."
# cp -a ${base_dir}/${network}/isc-dhcp6-server.${network} /etc/init.d/isc-dhcp6-server
# if [ "$?" != "0" ]; then
# echo_FAILED
# else
# echo_OK
# fi
#fi
# - DSL:
# - /etc/ppp/peers/dsl-provider
# - /etc/ppp/ip-up.d/email_notice
echo -en "\tDSL settings.."
_rval=true
cp -a ${base_dir}/${network}/dsl-provider.${network} /etc/ppp/peers/dsl-provider
if [ "$?" != "0" ]; then
_rval=false
fi
_network_name=`echo $network | tr '[:upper:]' '[:lower:]'`
if [ -f ${base_dir}/${network}/dsl-${_network_name}.${network} ]; then
cp -a ${base_dir}/${network}/dsl-${_network_name}.${network} /etc/ppp/peers/dsl-${_network_name}
fi
cp -a ${base_dir}/${network}/email_notice.${network} /etc/ppp/ip-up.d/email_notice
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/pap-secrets.${network} /etc/ppp/pap-secrets
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/chap-secrets.${network} /etc/ppp/chap-secrets
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
# - Postfix SMTP
# - /etc/postfix/main.cf
# - /etc/mailname
# - /etc/postfix/generic
# - /etc/postfix/generic.db
echo -en "\tConfigure Postfix SMTP Server.."
_rval=true
/etc/init.d/postfix stop > /dev/null
cp -a ${base_dir}/${network}/main.cf.${network} /etc/postfix/main.cf
if [ -f ${base_dir}/${network}/generic.${network} ]; then
cp -a ${base_dir}/${network}/generic.${network} /etc/postfix/generic
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/generic.db.${network} /etc/postfix/generic.db
if [ "$?" != "0" ]; then
_rval=false
fi
fi
if [ -f ${base_dir}/${network}/sasl_passwd.${network} ]; then
cp -a ${base_dir}/${network}/sasl_passwd.${network} /etc/postfix/sasl_passwd
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/sasl_passwd.db.${network} /etc/postfix/sasl_passwd.db
if [ "$?" != "0" ]; then
_rval=false
fi
fi
cp -a ${base_dir}/${network}/mailname.${network} /etc/mailname
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
# - Netzwerk:
# - /etc/network/interfaces
# - /etc/resolv.conf
# - /etc/hostname
# - /etc/hosts
echo -en "\tConfigure network settings.."
_rval=true
cp -a ${base_dir}/${network}/interfaces.${network} /etc/network/interfaces
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/resolv.conf.${network} /etc/resolv.conf
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/hosts.${network} /etc/hosts
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/hostname.${network} /etc/hostname
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
# - Firewall:
# -
echo -en "\tFirewall.."
if [ -f ${base_dir}/${network}/ipt-firewall.${network} ]; then
cp -a ${base_dir}/${network}/ipt-firewall.${network} /etc/init.d/ipt-firewall
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -f ${base_dir}/${network}/ip6t-firewall.${network} ]; then
echo -en "\tFirewall IPv6.."
cp -a ${base_dir}/${network}/ip6t-firewall.${network} /etc/init.d/ip6t-firewall
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
else
if [ -f "/etc/init.d/ip6t-firewall" ]; then
rm /etc/init.d/ip6t-firewall
fi
fi
_rval=true
if [ -f ${base_dir}/${network}/ipt-firewall.service.${_network} ] ; then
systemctl enable ipt-firewall.service
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ipt-firewall.service.${_network} /etc/systemd/system/ipt-firewall.service
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ipt-firewall-gateway.${_network} /usr/local/sbin/ipt-firewall-gateway
if [ "$?" != "0" ]; then
_rval=false
fi
mkdir -p /etc/ipt-firewall
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ipt-firewall-gateway.conf.${_network} /etc/ipt-firewall/ipt-firewall-gateway.conf
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
fi
_rval=true
if [ -f ${base_dir}/${network}/ip6t-firewall.service.${_network} ] ; then
systemctl enable ip6t-firewall.service
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ip6t-firewall.service.${_network} /etc/systemd/system/ip6t-firewall.service
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ip6t-firewall-gateway.${_network} /usr/local/sbin/ip6t-firewall-gateway
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/ip6t-firewall-gateway.conf.${_network} /etc/ipt-firewall/ip6t-firewall-gateway.conf
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
fi
# - Check Script Onlinestatus
# -
echo -en "\tCheck Script Onlinestatus.."
_rval=true
if [ -f ${base_dir}/${network}/check_net.service.${_network} ] ; then
cp -a ${base_dir}/${network}/check_net.service.${_network} /etc/systemd/system/check_net.service
if [ "$?" != "0" ]; then
_rval=false
fi
systemctl enable check_net.service
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/check_net.sh.${_network} /usr/local/sbin/check_net/check_net.sh
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/netconfig.sh.${_network} /usr/local/sbin/check_net/netconfig.sh
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/check_net.conf.${_network} /etc/check_net/check_net.conf
if [ "$?" != "0" ]; then
_rval=false
fi
mkdir -p /etc/check_net
if [ "$?" != "0" ]; then
_rval=false
fi
cp -a ${base_dir}/${network}/check_net-logrotate.${_network} /etc/logrotated.d/check_net
if [ "$?" != "0" ]; then
_rval=false
fi
if ! $_rval ; then
echo_FAILED
else
echo_OK
fi
fi
#if $_igmproxy ; then
if [ -f ${base_dir}/${network}/igmpproxy.conf.${network} ];then
echo -en "\tConfigure igmproxy (Entertain TV).."
PID=`ps aux | grep "/igmpproxy " | grep -v grep | awk '{print$2}'`
kill -9 $PID > /dev/null 2>&1
cp -a ${base_dir}/${network}/igmpproxy.conf.${network} /usr/local/igmpproxy/etc/igmpproxy.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -f ${base_dir}/${network}/aiccu.conf.${network} ]; then
echo -en "\tConfigure aiccu (IPv6 Tunnel).."
cp -a ${base_dir}/${network}/aiccu.conf.${network} /etc/aiccu.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -f ${base_dir}/${network}/aiccu.${network} ]; then
echo -en "\tSetting /etc/defaults/aiccu.."
cp -a ${base_dir}/${network}/aiccu.${network} /etc/default/aiccu
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if [ -f ${base_dir}/${network}/radvd.conf.${network} ]; then
echo -en "\tConfigure radvd (Router Advertisment Daemon).."
cp -a ${base_dir}/${network}/radvd.conf.${network} /etc/radvd.conf
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
if $_add_support_if ; then
if ! grep -e "eth1:rescue " /etc/network/interfaces > /dev/null ; then
echo -en "\tAdd interface eth1:rescue.."
cat << EOF >> /etc/network/interfaces
auto eth1:rescue
iface eth1:rescue inet static
address 172.16.1.1
network 172.16.1.0
netmask 255.255.255.0
broadcast 172.16.1.255
EOF
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
fi
fi
## - Cron (root)
## -
echo -en "\tSetting up cronjobs.."
if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" ];then
cp -a ${base_dir}/crontab_root.NONE /var/spool/cron/crontabs/root
else
if [ -f ${base_dir}/${network}/cron_root.${network} ];then
cp -a ${base_dir}/${network}/cron_root.${network} /var/spool/cron/crontabs/root
fi
fi
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
echo -en "\tSetting up rc.local.."
if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" ];then
cp -a ${base_dir}/rc.local.NONE /etc/rc.local
else
#cp -a ${base_dir}/rc.local /etc/rc.local
cp -a ${base_dir}/${network}/rc.local.${network} /etc/rc.local
fi
if [ "$?" != "0" ]; then
echo_FAILED
else
echo_OK
fi
echo ""
echo ""
echo -e " \\033[1;31m Take care, you are chrooted into /ro. Otherwise"
echo -e " changes are not persistent \\033[0;39m !!"
echo ""
echo ""
if $_add_support_if ; then
echo -e " After restarting, you can reach that device"
echo -e " at ip-address: \\033[1;33m172.16.1.1\\033[0;39m"
fi
echo ""
echo ""
echo -e " \\033[1;33mExit from chroot environment and restart to make changes active..\\033[0;39m"
echo ""
exit 0

197
copy_gateway-config.sh Executable file
View File

@ -0,0 +1,197 @@
#!/bin/bash
user=chris
function usage() {
if [ -n "$1" ];then
echo -e "\nError: $1"
fi
cat<<EOF
`basename $0` - Copies gateway configuration into ${user}'s homedirectory
Usage: `basename $0` <network-name>
network-name possible values are:
NONE-WF
NONE-CKUBU
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
}
[ $# -ne "1" ] && usage "wrong number of arguments"
_realpath=`which realpath`
if [ -z "$_realpath" ]; then
usage "realpath is not installed but neeeded"
fi
filesystem_prefix=""
if [ -d "/ro" ]; then
filesystem_prefix="/ro"
fi
_network=$1
homedir_user=`eval realpath ~$user`
_dir=${_network}-config
mkdir -p ${homedir_user}/${_dir}
# - Nameserver Bind
# - /etc/bind/*
# -
tar -czpf ${homedir_user}/${_dir}/bind_${_network}.tar.gz -C ${filesystem_prefix}/etc bind
chown ${user}:${user} ${homedir_user}/${_dir}/bind_${_network}.tar.gz
# - OpenVPN:
# - /etc/openvpn/*
# -
tar -czpf ${homedir_user}/${_dir}/openvpn_${_network}.tar.gz -C ${filesystem_prefix}/etc openvpn
chown ${user}:${user} ${homedir_user}/${_dir}/openvpn_${_network}.tar.gz
if [ -d "/root/.openvpn" ]; then
tar -czpf ${homedir_user}/${_dir}/root-dot-opennvpndir_${_network}.tar.gz -C /root .openvpn
chown ${user}:${user} ${homedir_user}/${_dir}/root-dot-opennvpndir_${_network}.tar.gz
fi
# - DynDNS
# -
if [ -f "${filesystem_prefix}/etc/ddclient.conf" ]; then
cp ${filesystem_prefix}/etc/ddclient.conf ${homedir_user}/${_dir}/ddclient.conf.${_network}
fi
# - DHCP Server
# -
if [ -f "${filesystem_prefix}/etc/dhcp/dhcpd.conf" ];then
cp ${filesystem_prefix}/etc/dhcp/dhcpd.conf ${homedir_user}/${_dir}/dhcpd.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/dhcp/dhcpd6.conf" ];then
cp ${filesystem_prefix}/etc/dhcp/dhcpd6.conf ${homedir_user}/${_dir}/dhcpd6.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/dhcp3/dhcpd.conf" ];then
cp ${filesystem_prefix}/etc/dhcp3/dhcpd.conf ${homedir_user}/${_dir}/dhcpd.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/dhcp3/dhcpd6.conf" ];then
cp ${filesystem_prefix}/etc/dhcp3/dhcpd6.conf ${homedir_user}/${_dir}/dhcpd.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/init.d/isc-dhcp6-server" ]; then
cp ${filesystem_prefix}/etc/init.d/isc-dhcp6-server ${homedir_user}/${_dir}/isc-dhcp6-server.${_network}
fi
# - DSL PPP
# -
if [ -f "${filesystem_prefix}/etc/ppp/peers/dsl-provider" ]; then
cp ${filesystem_prefix}/etc/ppp/peers/dsl-provider ${homedir_user}/${_dir}/dsl-provider.${_network}
fi
_network_name=`echo ${_network} | tr '[:upper:]' '[:lower:]'`
if [ -f "${filesystem_prefix}/etc/ppp/peers/dsl-$_network_name" ];then
cp ${filesystem_prefix}/etc/ppp/peers/dsl-$_network_name ${homedir_user}/${_dir}/dsl-${_network_name}.${_network}
fi
cp ${filesystem_prefix}/etc/ppp/pap-secrets ${homedir_user}/${_dir}/pap-secrets.${_network}
cp ${filesystem_prefix}/etc/ppp/chap-secrets ${homedir_user}/${_dir}/chap-secrets.${_network}
if [ -f "${filesystem_prefix}/etc/ppp/ip-up.d/email_notice" ];then
cp ${filesystem_prefix}/etc/ppp/ip-up.d/email_notice ${homedir_user}/${_dir}/email_notice.${_network}
fi
# - Postfix SMTP
# - /etc/postfix/main.cf
# - /etc/mailname
# - /etc/postfix/generic
# - /etc/postfix/generic.db
cp ${filesystem_prefix}/etc/postfix/main.cf ${homedir_user}/${_dir}/main.cf.${_network}
if [ -f "${filesystem_prefix}/etc/postfix/generic" ];then
cp ${filesystem_prefix}/etc/postfix/generic ${homedir_user}/${_dir}/generic.${_network}
cp ${filesystem_prefix}/etc/postfix/generic.db ${homedir_user}/${_dir}/generic.db.${_network}
fi
if [ -f "${filesystem_prefix}/etc/postfix/sasl_passwd" ]; then
cp ${filesystem_prefix}/etc/postfix/sasl_passwd ${homedir_user}/${_dir}/sasl_passwd.${_network}
cp ${filesystem_prefix}/etc/postfix/sasl_passwd.db ${homedir_user}/${_dir}/sasl_passwd.db.${_network}
fi
cp ${filesystem_prefix}/etc/mailname ${homedir_user}/${_dir}/mailname.${_network}
# - Netzwerk:
# - /etc/network/interfaces
# - /etc/resolv.conf
# - /etc/hostname
# - /etc/hosts
cp ${filesystem_prefix}/etc/hostname ${homedir_user}/${_dir}/hostname.${_network}
cp ${filesystem_prefix}/etc/hosts ${homedir_user}/${_dir}/hosts.${_network}
cp ${filesystem_prefix}/etc/network/interfaces ${homedir_user}/${_dir}/interfaces.${_network}
cp ${filesystem_prefix}/etc/resolv.conf ${homedir_user}/${_dir}/resolv.conf.${_network}
# - Firewall
# -
if [[ -f "${filesystem_prefix}/etc/systemd/system/ipt-firewall.service" ]]; then
cp ${filesystem_prefix}/etc/systemd/system/ipt-firewall.service ${homedir_user}/${_dir}/ipt-firewall.service.${_network}
cp ${filesystem_prefix}/usr/local/sbin/ipt-firewall-gateway ${homedir_user}/${_dir}/ipt-firewall-gateway.${_network}
cp ${filesystem_prefix}/etc/ipt-firewall/ipt-firewall-gateway.conf ${homedir_user}/${_dir}/ipt-firewall-gateway.conf.${_network}
fi
if [[ -f "${filesystem_prefix}/etc/systemd/system/ip6t-firewall.service" ]]; then
cp ${filesystem_prefix}/etc/systemd/system/ipt-firewall.service ${homedir_user}/${_dir}/ip6t-firewall.service.${_network}
cp ${filesystem_prefix}/usr/local/sbin/ip6t-firewall-gateway ${homedir_user}/${_dir}/ip6t-firewall-gateway.${_network}
cp ${filesystem_prefix}/etc/ipt-firewall/ip6t-firewall-gateway.conf ${homedir_user}/${_dir}/ip6t-firewall-gateway.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/init.d/ipt-firewall" ]; then
cp ${filesystem_prefix}/etc/init.d/ipt-firewall ${homedir_user}/${_dir}/ipt-firewall.${_network}
fi
if [ -f "${filesystem_prefix}/etc/init.d/ip6t-firewall" ]; then
cp ${filesystem_prefix}/etc/init.d/ip6t-firewall ${homedir_user}/${_dir}/ip6t-firewall.${_network}
fi
# - Check Script Onlinestatus
# -
if [[ -f "${filesystem_prefix}/etc/systemd/system/check_net.service" ]] ; then
cp ${filesystem_prefix}/etc/systemd/system/check_net.service ${homedir_user}/${_dir}/check_net.service.${_network}
cp ${filesystem_prefix}/usr/local/sbin/check_net.sh ${homedir_user}/${_dir}/check_net.sh.${_network}
cp ${filesystem_prefix}/usr/local/sbin/netconfig.sh ${homedir_user}/${_dir}/netconfig.sh.${_network}
cp ${filesystem_prefix}/etc/check_net/check_net.conf ${homedir_user}/${_dir}/check_net.conf.${_network}
fi
if [[ -f "${filesystem_prefix}/etc/logrotate.d/check_net" ]] ; then
cp ${filesystem_prefix}/etc/logrotate.d/check_net ${homedir_user}/${_dir}/check_net-logrotate.${_network}
fi
cp ${filesystem_prefix}/etc/rc.local ${homedir_user}/${_dir}/rc.local.${_network}
if [ -f "${filesystem_prefix}/var/spool/cron/crontabs/root" ]; then
cp ${filesystem_prefix}/var/spool/cron/crontabs/root ${homedir_user}/${_dir}/cron_root.${_network}
fi
if [ -f "${filesystem_prefix}/usr/local/igmpproxy/etc/igmpproxy.conf" ]; then
cp ${filesystem_prefix}/usr/local/igmpproxy/etc/igmpproxy.conf ${homedir_user}/${_dir}/igmpproxy.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/aiccu.conf" ]; then
cp ${filesystem_prefix}/etc/aiccu.conf ${homedir_user}/${_dir}/aiccu.conf.${_network}
fi
if [ -f "${filesystem_prefix}/etc/default/aiccu" ]; then
cp ${filesystem_prefix}/etc/default/aiccu ${homedir_user}/${_dir}/aiccu.${_network}
fi
if [ -f "${filesystem_prefix}/etc/radvd.conf" ]; then
cp ${filesystem_prefix}/etc/radvd.conf ${homedir_user}/${_dir}/radvd.conf.${_network}
fi
chown ${user}:${user} ${homedir_user}/${_dir}
chown ${user}:${user} ${homedir_user}/${_dir}/*.${_network}

343
remote-copy_gateway-config.sh Executable file
View File

@ -0,0 +1,343 @@
#!/usr/bin/env bash
function usage() {
if [ -n "$1" ];then
echo -e "\nError: $1"
fi
cat<<EOF
Usage: `basename $0` -h <remote host> -u <remote user> <network-name>
Example: `basename $0` -h wf.oopen.de -u chris WF
network-name possible values are:
NONE-WF
NONE-CKUBU
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
}
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
scp -o User=$remote_user ${remote_host}:${_network}-config/bind_${_network}.tar.gz .
gunzip < bind_${_network}.tar.gz | tar -xpf -
rm -f bind_${_network}.tar.gz
scp -o User=$remote_user ${remote_host}:${_network}-config/openvpn_${_network}.tar.gz .
gunzip < openvpn_${_network}.tar.gz | tar -xpf -
rm -f openvpn_${_network}.tar.gz
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/root-dot-opennvpndir_${_network}.tar.gz" ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/root-dot-opennvpndir_${_network}.tar.gz .
gunzip < root-dot-opennvpndir_${_network}.tar.gz | tar -xpf -
rm -f root-dot-opennvpndir_${_network}.tar.gz
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/ddclient.conf.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/ddclient.conf.${_network} .
fi
scp -o User=$remote_user ${remote_host}:${_network}-config/dhcpd.conf.${_network} .
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/dhcpd6.conf.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/dhcpd6.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/isc-dhcp6-server.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/isc-dhcp6-server.${_network} .
fi
# - DSL PPP
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/dsl-provider.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/dsl-provider.${_network} .
fi
_network_name=`echo $_network | tr '[:upper:]' '[:lower:]'`
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/dsl-${_network_name}.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/dsl-${_network_name}.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/pap-secrets.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/pap-secrets.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/chap-secrets.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/chap-secrets.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/email_notice.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/email_notice.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/generic.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/generic.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/generic.db.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/sasl_passwd.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/sasl_passwd.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/sasl_passwd.db.${_network} .
fi
scp -o User=$remote_user ${remote_host}:${_network}-config/mailname.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/main.cf.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/hostname.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/hosts.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/interfaces.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/rc.local.${_network} .
# - Firewall
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ipt-firewall.service.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/ipt-firewall.service.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/ipt-firewall-gateway.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/ipt-firewall-gateway.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ip6t-firewall.service.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/ip6t-firewall.service.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/ip6t-firewall-gateway.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/ip6t-firewall-gateway.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ipt-firewall.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/ipt-firewall.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/ip6t-firewall.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/ip6t-firewall.${_network} .
fi
# - Check Script Onlinestatus
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/check_net.service.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/check_net.service.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/check_net.sh.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/netconfig.sh.${_network} .
scp -o User=$remote_user ${remote_host}:${_network}-config/check_net.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/check_net-logrotate.${_network}" ]; then
scp -o User=$remote_user ${remote_host}:${_network}-config/check_net-logrotate.${_network} .
fi
scp -o User=$remote_user ${remote_host}:${_network}-config/resolv.conf.${_network} .
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/cron_root.${_network} ];then
scp -o User=$remote_user ${remote_host}:${_network}-config/cron_root.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/igmpproxy.conf.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/igmpproxy.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/aiccu.conf.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/aiccu.conf.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/aiccu.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/aiccu.${_network} .
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/radvd.conf.${_network} ] ; then
scp -o User=$remote_user ${remote_host}:${_network}-config/radvd.conf.${_network} .
fi
ssh -l $remote_user ${remote_host} "rm ${_network}-config/bind_${_network}.tar.gz"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/openvpn_${_network}.tar.gz"
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/root-dot-opennvpndir_${_network}.tar.gz ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/root-dot-opennvpndir_${_network}.tar.gz"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/ddclient.conf.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ddclient.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/dhcpd.conf.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/dhcpd.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/dhcpd6.conf.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/dhcpd6.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/isc-dhcp6-server.${_network}" ]; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/isc-dhcp6-server.${_network}"
fi
# - DSL PPP
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/dsl-provider.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/dsl-provider.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/dsl-${_network_name}.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/dsl-${_network_name}.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/pap-secrets.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/pap-secrets.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/chap-secrets.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/chap-secrets.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/email_notice.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/email_notice.${_network}"
fi
# - Postfix
# -
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/generic.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/generic.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/generic.db.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/sasl_passwd.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/sasl_passwd.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/sasl_passwd.db.${_network}"
fi
ssh -l $remote_user ${remote_host} "rm ${_network}-config/mailname.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/main.cf.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/hostname.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/hosts.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/interfaces.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/rc.local.${_network}"
# - Firewall
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ipt-firewall.service.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ipt-firewall.service.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ipt-firewall-gateway.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ipt-firewall-gateway.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ip6t-firewall.service.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ip6t-firewall.service.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ip6t-firewall-gateway.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ip6t-firewall-gateway.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/ipt-firewall.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ipt-firewall.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/ip6t-firewall.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/ip6t-firewall.${_network}"
fi
# - Check Script Onlinestatus
# -
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/check_net.service.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/check_net.service.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/check_net.sh.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/netconfig.sh.${_network}"
ssh -l $remote_user ${remote_host} "rm ${_network}-config/check_net.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/check_net-logrotate.${_network}" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/check_net-logrotate.${_network}"
fi
ssh -l $remote_user ${remote_host} "rm ${_network}-config/resolv.conf.${_network}"
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/cron_root.${_network} ]; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/cron_root.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/igmpproxy.conf.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/igmpproxy.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/aiccu.conf.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/aiccu.conf.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/aiccu.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/aiccu.${_network}"
fi
if ssh -l $remote_user ${remote_host} [ -f ${_network}-config/radvd.conf.${_network} ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/radvd.conf.${_network}"
fi
cat <<EOF > $office_dir/README.txt
Notice:
You have to change some configuration files becaus the because
the configuration of network interfaces must not be equal.
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
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
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/"
fi
if ssh -l $remote_user ${remote_host} [ -f "${_network}-config/" ] ; then
ssh -l $remote_user ${remote_host} "rm ${_network}-config/"
fi