Change output, improve error handling.

This commit is contained in:
root 2017-02-25 05:08:48 +01:00
parent 81dd5e7a2a
commit 16d09fb42a

View File

@ -4,6 +4,8 @@
base_dir=/root/Office_Networks base_dir=/root/Office_Networks
chown -R root:root $base_dir chown -R root:root $base_dir
logfile=$(mktemp)
function usage() { function usage() {
if [ -n "$1" ];then if [ -n "$1" ];then
echo -e "\nError: $1" echo -e "\nError: $1"
@ -55,10 +57,43 @@ Notice:
remountro remountro
EOF EOF
rm -rf $logfile
exit exit
} }
error(){
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
else
echo "Error: $*"
fi
echo ""
}
warn (){
echo ""
if $terminal ; then
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
else
echo "Warning: $*"
fi
echo ""
}
info (){
echo ""
if $terminal ; then
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
else
echo "Info: $*"
fi
echo ""
}
echo_OK() { echo_OK() {
echo -en "\\033[45G[ \\033[1;32mOK\\033[0;39m ]\n" echo -en "\\033[45G[ \\033[1;32mOK\\033[0;39m ]\n"
} }
@ -68,7 +103,7 @@ echo_FAILED() {
} }
echo_SKIPPED() { echo_SKIPPED() {
echo -en "\\033[45G[ \\033[1;37mFAIL\\033[0;39m ]\n" echo -en "\\033[45G[ \\033[37mSkipped\\033[0;39m ]\n"
} }
[ $# -ne "1" ] && usage "wrong number of arguments" [ $# -ne "1" ] && usage "wrong number of arguments"
@ -96,6 +131,7 @@ case $1 in
esac esac
echo "" echo ""
echo "Configure gateway for network \"$network\".." echo "Configure gateway for network \"$network\".."
echo ""
# - Nameserver Bind # - Nameserver Bind
# - /etc/bind/* # - /etc/bind/*
@ -129,9 +165,10 @@ if [[ -d "/etc/openvpn" ]]; then
echo -en "\tVPN settings.." echo -en "\tVPN settings.."
/etc/init.d/openvpn stop > /dev/null /etc/init.d/openvpn stop > /dev/null
rm -rf /etc/openvpn rm -rf /etc/openvpn
cp -a ${base_dir}/${network}/openvpn /etc/openvpn cp -a ${base_dir}/${network}/openvpn /etc/openvpn > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -139,9 +176,10 @@ fi
if [ -d "/root/.openvpn" ]; then if [ -d "/root/.openvpn" ]; then
echo -en "\tCleanup private VPN settings for user root.." echo -en "\tCleanup private VPN settings for user root.."
rm -rf /root/.openvpn rm -r /root/.openvpn > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -149,9 +187,10 @@ fi
if [ -d "${base_dir}/${network}/.openvpn" ];then if [ -d "${base_dir}/${network}/.openvpn" ];then
echo -en "\tPrivate VPN settings for root user.." echo -en "\tPrivate VPN settings for root user.."
cp -a ${base_dir}/${network}/.openvpn /root/.openvpn cp -a ${base_dir}/${network}/.openvpn /root/.openvpn > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -168,9 +207,10 @@ fi
# - /etc/ddclient.conf # - /etc/ddclient.conf
if [ -f ${base_dir}/${network}/ddclient.conf.${network} ];then if [ -f ${base_dir}/${network}/ddclient.conf.${network} ];then
echo -en "\tConfigure DynDNS.." echo -en "\tConfigure DynDNS.."
cp -a ${base_dir}/${network}/ddclient.conf.${network} /etc/ddclient.conf cp -a ${base_dir}/${network}/ddclient.conf.${network} /etc/ddclient.conf > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -191,14 +231,14 @@ for file in $files ; do
file_real_name="${file%.*}" file_real_name="${file%.*}"
if [[ -f "${base_dir}/${network}/$file" ]]; then if [[ -f "${base_dir}/${network}/$file" ]]; then
if [[ -d /etc/dhcp ]]; then if [[ -d /etc/dhcp ]]; then
cp -a ${base_dir}/${network}/$file /etc/dhcp/ cp -a ${base_dir}/${network}/$file /etc/dhcp/ > $logfile 2>&1
if [[ "$?" = "0" ]]; then if [[ "$?" = "0" ]]; then
success=true success=true
else else
failed=true failed=true
fi fi
elif [[ -d /etc/dhcp3 ]] ;then elif [[ -d /etc/dhcp3 ]] ;then
cp -a ${base_dir}/${network}/$file /etc/dhcp3/ cp -a ${base_dir}/${network}/$file /etc/dhcp3/ > $logfile 2>&1
if [[ "$?" = "0" ]]; then if [[ "$?" = "0" ]]; then
success=true success=true
else else
@ -209,6 +249,7 @@ for file in $files ; do
done done
if $failed ; then if $failed ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
elif $success ; then elif $success ; then
echo_OK echo_OK
else else
@ -235,7 +276,7 @@ echo -en "\tDSL settings.."
if [[ -d "/etc/ppp/peers" ]]; then if [[ -d "/etc/ppp/peers" ]]; then
if [[ -d "{base_dir}/${network}/peers" ]]; then if [[ -d "{base_dir}/${network}/peers" ]]; then
cp -a ${base_dir}/${network}/peers/* /etc/ppp/peers/ cp -a ${base_dir}/${network}/peers/* /etc/ppp/peers/ > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
@ -243,21 +284,22 @@ if [[ -d "/etc/ppp/peers" ]]; then
fi fi
if [[ -f "{base_dir}/${network}/email_notice.${network}" ]] ; then if [[ -f "{base_dir}/${network}/email_notice.${network}" ]] ; then
cp -a ${base_dir}/${network}/email_notice.${network} /etc/ppp/ip-up.d/email_notice cp -a ${base_dir}/${network}/email_notice.${network} /etc/ppp/ip-up.d/email_notice >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
fi fi
cp -a ${base_dir}/${network}/pap-secrets.${network} /etc/ppp/pap-secrets cp -a ${base_dir}/${network}/pap-secrets.${network} /etc/ppp/pap-secrets >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/chap-secrets.${network} /etc/ppp/chap-secrets cp -a ${base_dir}/${network}/chap-secrets.${network} /etc/ppp/chap-secrets >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -271,33 +313,34 @@ fi
echo -en "\tConfigure Postfix SMTP Server.." echo -en "\tConfigure Postfix SMTP Server.."
_rval=true _rval=true
/etc/init.d/postfix stop > /dev/null /etc/init.d/postfix stop > /dev/null
cp -a ${base_dir}/${network}/main.cf.${network} /etc/postfix/main.cf cp -a ${base_dir}/${network}/main.cf.${network} /etc/postfix/main.cf > $logfile 2>&1
if [ -f ${base_dir}/${network}/generic.${network} ]; then if [ -f ${base_dir}/${network}/generic.${network} ]; then
cp -a ${base_dir}/${network}/generic.${network} /etc/postfix/generic cp -a ${base_dir}/${network}/generic.${network} /etc/postfix/generic >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/generic.db.${network} /etc/postfix/generic.db cp -a ${base_dir}/${network}/generic.db.${network} /etc/postfix/generic.db >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
fi fi
if [ -f ${base_dir}/${network}/sasl_passwd.${network} ]; then if [ -f ${base_dir}/${network}/sasl_passwd.${network} ]; then
cp -a ${base_dir}/${network}/sasl_passwd.${network} /etc/postfix/sasl_passwd cp -a ${base_dir}/${network}/sasl_passwd.${network} /etc/postfix/sasl_passwd >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/sasl_passwd.db.${network} /etc/postfix/sasl_passwd.db cp -a ${base_dir}/${network}/sasl_passwd.db.${network} /etc/postfix/sasl_passwd.db >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
fi fi
cp -a ${base_dir}/${network}/mailname.${network} /etc/mailname cp -a ${base_dir}/${network}/mailname.${network} /etc/mailname >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -310,24 +353,25 @@ fi
# - /etc/hosts # - /etc/hosts
echo -en "\tConfigure network settings.." echo -en "\tConfigure network settings.."
_rval=true _rval=true
cp -a ${base_dir}/${network}/interfaces.${network} /etc/network/interfaces cp -a ${base_dir}/${network}/interfaces.${network} /etc/network/interfaces > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/resolv.conf.${network} /etc/resolv.conf cp -a ${base_dir}/${network}/resolv.conf.${network} /etc/resolv.conf >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/hosts.${network} /etc/hosts cp -a ${base_dir}/${network}/hosts.${network} /etc/hosts >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
cp -a ${base_dir}/${network}/hostname.${network} /etc/hostname cp -a ${base_dir}/${network}/hostname.${network} /etc/hostname >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -338,11 +382,12 @@ fi
echo -en "\t/root/bin directory" echo -en "\t/root/bin directory"
if [[ -d "${base_dir}/${network}/bin" ]]; then if [[ -d "${base_dir}/${network}/bin" ]]; then
if [[ ! -d "/root/bin" ]]; then if [[ ! -d "/root/bin" ]]; then
mkdir /root/bin mkdir /root/bin > $logfile 2>&1
fi fi
cp -a ${base_dir}/${network}/bin/* /root/bin/ cp -a ${base_dir}/${network}/bin/* /root/bin/ > $logfile 2>&1
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -355,9 +400,10 @@ fi
# - # -
echo -en "\t/usr/local/src directory" echo -en "\t/usr/local/src directory"
if [[ -d "${base_dir}/${network}/src" ]]; then if [[ -d "${base_dir}/${network}/src" ]]; then
cp -a ${base_dir}/${network}/src/* /usr/local/src/ cp -a ${base_dir}/${network}/src/* /usr/local/src/ > $logfile 2>&1
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -370,9 +416,10 @@ fi
# - # -
echo -en "\t/usr/local/sbin directory" echo -en "\t/usr/local/sbin directory"
if [[ -d "${base_dir}/${network}/sbin" ]]; then if [[ -d "${base_dir}/${network}/sbin" ]]; then
cp -a ${base_dir}/${network}/sbin/* /usr/local/sbin/ cp -a ${base_dir}/${network}/sbin/* /usr/local/sbin/ > $logfile 2>&1
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -392,43 +439,41 @@ if [[ -d "${base_dir}/${network}/ipt-firewall" ]]; then
rm -rf /etc/ipt-firewall rm -rf /etc/ipt-firewall
fi fi
mkdir -p /etc/ipt-firewall mkdir -p /etc/ipt-firewall
cp -a ${base_dir}/${network}/ipt-firewall /etc/ cp -a ${base_dir}/${network}/ipt-firewall /etc/ > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -d "/etc/ipt-firewall" ]]; then if [[ -d "/etc/ipt-firewall" ]]; then
rm -rf /etc/ipt-firewall rm -rf /etc/ipt-firewall >> $logfile 2>&1
fi fi
fi fi
if [ -f ${base_dir}/${network}/ipt-firewall.${network} ]; then if [ -f ${base_dir}/${network}/ipt-firewall.${network} ]; then
cp -a ${base_dir}/${network}/ipt-firewall.${network} /etc/init.d/ipt-firewall cp -a ${base_dir}/${network}/ipt-firewall.${network} /etc/init.d/ipt-firewall >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
rm -f /etc/init.d/ipt-firewall rm -f /etc/init.d/ipt-firewall >> $logfile 2>&1
fi fi
if [ -f ${base_dir}/${network}/ip6t-firewall.${network} ]; then if [ -f ${base_dir}/${network}/ip6t-firewall.${network} ]; then
cp -a ${base_dir}/${network}/ip6t-firewall.${network} /etc/init.d/ip6t-firewall cp -a ${base_dir}/${network}/ip6t-firewall.${network} /etc/init.d/ip6t-firewall >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [ -f "/etc/init.d/ip6t-firewall" ]; then if [ -f "/etc/init.d/ip6t-firewall" ]; then
rm -f /etc/init.d/ip6t-firewall rm -f /etc/init.d/ip6t-firewall >> $logfile 2>&1
fi fi
fi fi
if [ -f ${base_dir}/${network}/ip6t-firewall.${network} ]; then if [ -f ${base_dir}/${network}/ip6t-firewall.${network} ]; then
echo -en "\tFirewall IPv6.." echo -en "\tFirewall IPv6.."
cp -a ${base_dir}/${network}/ip6t-firewall.${network} /etc/init.d/ip6t-firewall cp -a ${base_dir}/${network}/ip6t-firewall.${network} /etc/init.d/ip6t-firewall >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED _rval=false
else
echo_OK
fi fi
else else
if [ -f "/etc/init.d/ip6t-firewall" ]; then if [ -f "/etc/init.d/ip6t-firewall" ]; then
@ -437,47 +482,48 @@ else
fi fi
if [[ -f "${base_dir}/${network}/ipt-firewall.service.${network}" ]]; then if [[ -f "${base_dir}/${network}/ipt-firewall.service.${network}" ]]; then
cp ${base_dir}/${network}/ipt-firewall.service.${network} /etc/systemd/system/ipt-firewall.service cp ${base_dir}/${network}/ipt-firewall.service.${network} /etc/systemd/system/ipt-firewall.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
systemctl daemon-reload systemctl daemon-reload >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
systemctl enable ipt-firewall.service systemctl enable ipt-firewall.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -f "/etc/systemd/system/ipt-firewall.service" ]]; then if [[ -f "/etc/systemd/system/ipt-firewall.service" ]]; then
systemctl disable ipt-firewall.service systemctl disable ipt-firewall.service >> $logfile 2>&1
rm /etc/systemd/system/ipt-firewall.service rm /etc/systemd/system/ipt-firewall.service >> $logfile 2>&1
fi fi
fi fi
if [[ -f "${base_dir}/${network}/ip6t-firewall.service.${network}" ]]; then if [[ -f "${base_dir}/${network}/ip6t-firewall.service.${network}" ]]; then
cp ${base_dir}/${network}/ip6t-firewall.service.${network} /etc/systemd/system/ip6t-firewall.service cp ${base_dir}/${network}/ip6t-firewall.service.${network} /etc/systemd/system/ip6t-firewall.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
systemctl daemon-reload systemctl daemon-reload >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
systemctl enable ip6t-firewall.service systemctl enable ip6t-firewall.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -f "/etc/systemd/system/ip6t-firewall.service" ]]; then if [[ -f "/etc/systemd/system/ip6t-firewall.service" ]]; then
systemctl disable ip6t-firewall.service systemctl disable ip6t-firewall.service >> $logfile 2>&1
rm /etc/systemd/system/ip6t-firewall.service rm /etc/systemd/system/ip6t-firewall.service >> $logfile 2>&1
fi fi
fi fi
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -491,50 +537,51 @@ _rval=true
if [[ -d "${base_dir}/${network}/check_net" ]]; then if [[ -d "${base_dir}/${network}/check_net" ]]; then
if [[ -d "/etceck_net" ]]; then if [[ -d "/etceck_net" ]]; then
rm -rf /etc/check_net rm -rf /etc/check_net > $logfile 2>&1
fi fi
mkdir -p /etc/check_net mkdir -p /etc/check_net
cp -a ${base_dir}/${network}/check_net /etc/ cp -a ${base_dir}/${network}/check_net /etc/ >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -d "/etc/check_net" ]]; then if [[ -d "/etc/check_net" ]]; then
rm -rf /etc/check_net rm -rf /etc/check_net >> $logfile 2>&1
fi fi
fi fi
if [ -f ${base_dir}/${network}/check_net.service.${_network} ] ; then 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 cp -a ${base_dir}/${network}/check_net.service.${_network} /etc/systemd/system/check_net.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
systemctl daemon-reload systemctl daemon-reload >> $logfile 2>&1
systemctl enable check_net.service systemctl enable check_net.service >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -f "/etc/systemd/system/check_net.service" ]]; then if [[ -f "/etc/systemd/system/check_net.service" ]]; then
systemctl disable check_net.service systemctl disable check_net.service >> $logfile 2>&1
rm /etc/systemd/system/check_net.service rm /etc/systemd/system/check_net.service >> $logfile 2>&1
systemctl daemon-reload systemctl daemon-reload
fi fi
fi fi
if [[ -f "${base_dir}/${network}/check_net-logrotate.${_network}" ]]; then if [[ -f "${base_dir}/${network}/check_net-logrotate.${_network}" ]]; then
cp -a ${base_dir}/${network}/check_net-logrotate.${_network} /etc/logrotated.d/check_net cp -a ${base_dir}/${network}/check_net-logrotate.${_network} /etc/logrotated.d/check_net >> $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_rval=false _rval=false
fi fi
else else
if [[ -f "/etc/logrotated.d/check_net" ]]; then if [[ -f "/etc/logrotated.d/check_net" ]]; then
rm /etc/logrotated.d/check_net rm /etc/logrotated.d/check_net >> $logfile 2>&1
fi fi
fi fi
if ! $_rval ; then if ! $_rval ; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -547,9 +594,10 @@ if [ -f ${base_dir}/${network}/igmpproxy.conf.${network} ];then
echo -en "\tConfigure igmproxy (Entertain TV).." echo -en "\tConfigure igmproxy (Entertain TV).."
PID=`ps aux | grep "/igmpproxy " | grep -v grep | awk '{print$2}'` PID=`ps aux | grep "/igmpproxy " | grep -v grep | awk '{print$2}'`
kill -9 $PID > /dev/null 2>&1 kill -9 $PID > /dev/null 2>&1
cp -a ${base_dir}/${network}/igmpproxy.conf.${network} /usr/local/igmpproxy/etc/igmpproxy.conf cp -a ${base_dir}/${network}/igmpproxy.conf.${network} /usr/local/igmpproxy/etc/igmpproxy.conf > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -557,18 +605,20 @@ fi
if [ -f ${base_dir}/${network}/aiccu.conf.${network} ]; then if [ -f ${base_dir}/${network}/aiccu.conf.${network} ]; then
echo -en "\tConfigure aiccu (IPv6 Tunnel).." echo -en "\tConfigure aiccu (IPv6 Tunnel).."
cp -a ${base_dir}/${network}/aiccu.conf.${network} /etc/aiccu.conf cp -a ${base_dir}/${network}/aiccu.conf.${network} /etc/aiccu.conf > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
fi fi
if [ -f ${base_dir}/${network}/aiccu.${network} ]; then if [ -f ${base_dir}/${network}/aiccu.${network} ]; then
echo -en "\tSetting /etc/defaults/aiccu.." echo -en "\tSetting /etc/defaults/aiccu.."
cp -a ${base_dir}/${network}/aiccu.${network} /etc/default/aiccu cp -a ${base_dir}/${network}/aiccu.${network} /etc/default/aiccu > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -576,9 +626,10 @@ fi
if [ -f ${base_dir}/${network}/radvd.conf.${network} ]; then if [ -f ${base_dir}/${network}/radvd.conf.${network} ]; then
echo -en "\tConfigure radvd (Router Advertisment Daemon).." echo -en "\tConfigure radvd (Router Advertisment Daemon).."
cp -a ${base_dir}/${network}/radvd.conf.${network} /etc/radvd.conf cp -a ${base_dir}/${network}/radvd.conf.${network} /etc/radvd.conf > $logfile 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
@ -614,45 +665,56 @@ fi
## - Cron (root) ## - Cron (root)
## - ## -
echo -en "\tSetting up cronjobs.." echo -en "\tSetting up cronjobs.."
if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" ];then if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" -o "$network" = "GA-Ersatz" ];then
cp -a ${base_dir}/crontab_root.NONE /var/spool/cron/crontabs/root cp -a ${base_dir}/crontab_root.NONE /var/spool/cron/crontabs/root > $logfile 2>&1
else else
if [ -f ${base_dir}/${network}/cron_root.${network} ];then if [ -f ${base_dir}/${network}/cron_root.${network} ];then
cp -a ${base_dir}/${network}/cron_root.${network} /var/spool/cron/crontabs/root cp -a ${base_dir}/${network}/cron_root.${network} /var/spool/cron/crontabs/root > $logfile 2>&1
fi fi
fi fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi fi
echo -en "\tSetting up rc.local.." echo -en "\tSetting up rc.local.."
if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" -o "$network" = "GA-Ersatz" ];then if [ "$network" = "NONE-CKUBU" -o "$network" = "NONE-WF" -o "$network" = "GA-Ersatz" ];then
cp -a ${base_dir}/rc.local.NONE /etc/rc.local cp -a ${base_dir}/rc.local.NONE /etc/rc.local > $logfile 2>&1
else else
#cp -a ${base_dir}/rc.local /etc/rc.local #cp -a ${base_dir}/rc.local /etc/rc.local
cp -a ${base_dir}/${network}/rc.local.${network} /etc/rc.local cp -a ${base_dir}/${network}/rc.local.${network} /etc/rc.local > $logfile 2>&1
fi fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo_FAILED echo_FAILED
error $(cat $logfile)
else else
echo_OK echo_OK
fi 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 if $_add_support_if ; then
echo -e " After restarting, you can reach that device" echo -e " After restarting, you can reach that device"
echo -e " at ip-address: \\033[1;33m172.16.1.1\\033[0;39m" echo -e " at ip-address: \\033[1;33m172.16.1.1\\033[0;39m"
fi fi
echo ""
echo "" if [ "$(stat -c %d:%i /)" = "$(stat -c %d:%i /proc/1/root/.)" ]; then
echo -e " \\033[1;33mExit from chroot environment and restart to make changes active..\\033[0;39m"
echo "" warn "This is NOT a chrooted environment. Maybe thats ok. \n\n\t\033[1;37mIf this is a readonly system, take care, you are chrooted into /ro.\n\tOtherwise changes are not persistent.\033[m"
#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 ""
else
info "Programm was running in a chrooted environment.\n\n\t\033[1;37mExit from chroot environment and restart to make changes active..\033[m"
#echo ""
#echo ""
#echo -e " \\033[1;33mExit from chroot environment and restart to make changes active..\\033[0;39m"
#echo ""
fi
exit 0 exit 0