change_munin_ip.sh: Some minor changes..

This commit is contained in:
Christoph 2024-11-15 20:10:40 +01:00
parent 11d2ab22b6
commit 7e88f94754

View File

@ -13,6 +13,50 @@ log_file="${LOCK_DIR}/${script_name%%.*}.log"
# Base Function(s) # Base Function(s)
# ---------- # ----------
usage() {
[[ -n "$1" ]] && error "$1"
[[ $terminal ]] && echo -e "
\033[1mUsage:\033[m
$(basename $0) [-b]
\033[1mDescription\033[m
Script changes munin server ips (IPv4 and IPv6) in munin and in firewall configuration. All
parameters can be given interactivly if not running in batch mode.
\033[1mOptions\033[m
-b
script acts in batch mode. All required parameters must be given in configuration filer
-h
Prints this help.
\033[1mFiles\033[m
$conf_file: Configuration file
\033[1mExample:\033[m
Change munin server ip addresses.
\033[1m$(basename $0)\033[m
Same, but act in batch mode
\033[1m$(basename $0) -b\033[m
"
clean_up 1
}
clean_up() { clean_up() {
# Perform program exit housekeeping # Perform program exit housekeeping
@ -209,6 +253,7 @@ if [[ -t 1 ]] ; then
terminal=true terminal=true
else else
terminal=false terminal=false
BATCH_MODE=true
fi fi
@ -280,7 +325,7 @@ if ${BATCH_MODE} && ( [[ -z "${IPv4_ADDRESS_OLD}" ]] || [[ -z "${IPv4_ADDRESS_NE
fatal "Something wired went wrong.." fatal "Something wired went wrong.."
fi fi
if ! ${BATCH_MODE} ; then if ! ${BATCH_MODE} && ${terminal}; then
echo "" echo ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
@ -484,49 +529,53 @@ if ! ${BATCH_MODE} ; then
fi fi
fi fi
#clear if ${terminal} ; then
echo "" clear
echo "" echo ""
echo -e "\033[14G\033[32mReplace IP-Address(es) for munin server\033[m" echo ""
echo "" echo -e "\033[14G\033[32mReplace IP-Address(es) for munin server\033[m"
echo ""
if $_set_ipv4 ; then if $_set_ipv4 ; then
echo " Old IPv4 Address...........................: $IPv4_ADDRESS_OLD" echo " Old IPv4 Address...........................: $IPv4_ADDRESS_OLD"
echo " New IPv4 Address...........................: $IPv4_ADDRESS_NEW" echo " New IPv4 Address...........................: $IPv4_ADDRESS_NEW"
else else
echo -e " IPv4 Address(es)...........................: \033[33mNone\033[m" echo -e " IPv4 Address(es)...........................: \033[33mNone\033[m"
fi
echo ""
if $_set_ipv6 ; then
echo " Old IPv6 Address...........................: $IPv6_ADDRESS_OLD"
echo " New IPv6 Address...........................: $IPv6_ADDRESS_NEW"
else
echo -e " IPv6 Address(es)........................: \033[33mNone\033[m"
fi
echo ""
echo -e " Munin Node configuration file..............: \033[33m${MUNIN_CONF_FILE}\033[m"
echo -e " ipt firewall main IPv4 file................: \033[33m${IPT_FIREWALL_MAIN_IPV4_FILE}\033[m"
echo -e " ipt firewall main IPv6 file................: \033[33m${IPT_FIREWALL_MAIN_IPV6_FILE}\033[m"
echo ""
OK=
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
echononl "Parameters ok? [yes/no]: "
read OK
## - To lower case
OK=${OK,,}
if [ "X$OK" = "X" ]; then
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
OK=""
continue
fi fi
if [ "$OK" != "yes" -o "$OK" != "no" ] ; then echo ""
break if $_set_ipv6 ; then
echo " Old IPv6 Address...........................: $IPv6_ADDRESS_OLD"
echo " New IPv6 Address...........................: $IPv6_ADDRESS_NEW"
else
echo -e " IPv6 Address(es)........................: \033[33mNone\033[m"
fi fi
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n" echo ""
done echo -e " Munin Node configuration file..............: \033[33m${MUNIN_CONF_FILE}\033[m"
[[ $OK = "yes" ]] || fatal Repeat execution with different parameters echo -e " ipt firewall main IPv4 file................: \033[33m${IPT_FIREWALL_MAIN_IPV4_FILE}\033[m"
echo -e " ipt firewall main IPv6 file................: \033[33m${IPT_FIREWALL_MAIN_IPV6_FILE}\033[m"
if ! ${BATCH_MODE} ; then
blank_line
OK=
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
echononl "Parameters ok? [yes/no]: "
read OK
## - To lower case
OK=${OK,,}
if [ "X$OK" = "X" ]; then
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
OK=""
continue
fi
if [ "$OK" != "yes" -o "$OK" != "no" ] ; then
break
fi
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n"
done
[[ $OK = "yes" ]] || fatal Repeat execution with different parameters
fi
fi
blank_line blank_line
blank_line blank_line