Compare commits
17 Commits
9658cf7c09
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f59158793c | |||
| a36aeeab1b | |||
| 6f8e364dbb | |||
| 16ee308311 | |||
| 71d974131e | |||
| 2d1798ccd9 | |||
| c3dd3448b8 | |||
| 3525154857 | |||
| 051e8dc948 | |||
| 8914e5ba25 | |||
| e6b0a946f4 | |||
| 62cf8ac515 | |||
| 8030091145 | |||
| 7e88f94754 | |||
| 11d2ab22b6 | |||
| 588b72f5a8 | |||
| 003fac399e |
@@ -37,6 +37,7 @@ sudo_users="
|
|||||||
jumpy
|
jumpy
|
||||||
localadmin
|
localadmin
|
||||||
marcus
|
marcus
|
||||||
|
marsupilami
|
||||||
nd-admin
|
nd-admin
|
||||||
sysadm
|
sysadm
|
||||||
wadmin
|
wadmin
|
||||||
@@ -184,6 +185,9 @@ if ! id -u "${user_name}" > /dev/null 2>&1 ; then
|
|||||||
elif [[ "$user_name" = 'back' ]]; then
|
elif [[ "$user_name" = 'back' ]]; then
|
||||||
user_uid=1060
|
user_uid=1060
|
||||||
user_gid=1060
|
user_gid=1060
|
||||||
|
elif [[ "$user_name" = 'borg' ]]; then
|
||||||
|
user_uid=1065
|
||||||
|
user_gid=1065
|
||||||
elif [[ "$user_name" = 'cryptpad' ]]; then
|
elif [[ "$user_name" = 'cryptpad' ]]; then
|
||||||
user_uid=1033
|
user_uid=1033
|
||||||
user_gid=1033
|
user_gid=1033
|
||||||
@@ -266,10 +270,15 @@ if $password_needed ; then
|
|||||||
elif [[ "$user_name" = 'back' ]]; then
|
elif [[ "$user_name" = 'back' ]]; then
|
||||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$okMvVb1lmERtmLDa0lAmM1\\\$Gkm9VHgv.IYijNpsTE3sOZ.pg7I0x7siuXPVFbwQc23:\2#" /etc/shadow
|
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$okMvVb1lmERtmLDa0lAmM1\\\$Gkm9VHgv.IYijNpsTE3sOZ.pg7I0x7siuXPVFbwQc23:\2#" /etc/shadow
|
||||||
|
|
||||||
|
# - borg
|
||||||
|
# -
|
||||||
|
elif [[ "$user_name" = 'borg' ]]; then
|
||||||
|
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$SZty9T8ZWbnyHR2S85xaG.\\\$GhxHOKG9fKErT9s5TAehXXyZJSkNaIcXY18Rg1iMyhC:\2#" /etc/shadow
|
||||||
|
|
||||||
# - localadmin
|
# - localadmin
|
||||||
# -
|
# -
|
||||||
elif [[ "$user_name" = 'localadmin' ]]; then
|
elif [[ "$user_name" = 'localadmin' ]]; then
|
||||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$flo5afeu\\\$1Dn/tqIOJIFQbymCzpJk9BgGflQdy2Eg0nTiMBF7VefN7uY/Md1pV2yU0S47kZuH5aDjSdPfKzhHp8Aul/xx90:\2#" /etc/shadow
|
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$a7Pu7Km.0CEyBIz7FiDt91\\\$IdEIMclAswWIX6LMMlOgHSPBXaB226AcIYj6/4F2g35:\2#" /etc/shadow
|
||||||
|
|
||||||
# - axel
|
# - axel
|
||||||
# -
|
# -
|
||||||
@@ -401,6 +410,12 @@ if $password_needed ; then
|
|||||||
elif [[ "$user_name" = 'marcus' ]]; then
|
elif [[ "$user_name" = 'marcus' ]]; then
|
||||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$SPnbZ2Gcf.4iHz93\\\$Vp7fg/xCGls4cPJIiLR5Ogxm2U38RPpPgHLaLIJiOe.PekJCuRsvRLBZLITec2JQhdVTvqpmKURUZrKdXs62z0:\2#" /etc/shadow
|
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$SPnbZ2Gcf.4iHz93\\\$Vp7fg/xCGls4cPJIiLR5Ogxm2U38RPpPgHLaLIJiOe.PekJCuRsvRLBZLITec2JQhdVTvqpmKURUZrKdXs62z0:\2#" /etc/shadow
|
||||||
|
|
||||||
|
|
||||||
|
# - marsupilami (Torbsen IL)
|
||||||
|
# -
|
||||||
|
elif [[ "$user_name" = 'marsupilami' ]]; then
|
||||||
|
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$guTT3egsLUFwxUGCnDJ0o0\\\$WCQt3gXcYIpArTxbn2BunvIWG6w7GZLx./fFGJYCsd/:\2#" /etc/shadow
|
||||||
|
|
||||||
# - root
|
# - root
|
||||||
# -
|
# -
|
||||||
elif [[ "$user_name" = 'root' ]]; then
|
elif [[ "$user_name" = 'root' ]]; then
|
||||||
|
|||||||
657
change_munin_ip.sh
Executable file
657
change_munin_ip.sh
Executable file
@@ -0,0 +1,657 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_name="$(basename $(realpath $0))"
|
||||||
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
|
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||||
|
|
||||||
|
LOCK_DIR="/tmp/${script_name%%.*}.LOCK"
|
||||||
|
log_file="${LOCK_DIR}/${script_name%%.*}.log"
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# 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() {
|
||||||
|
|
||||||
|
# Perform program exit housekeeping
|
||||||
|
rm -rf "$LOCK_DIR"
|
||||||
|
blank_line
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
echononl(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo X\\c > /tmp/shprompt$$
|
||||||
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
echo -e -n " $*\\c" 1>&2
|
||||||
|
else
|
||||||
|
echo -e -n " $*" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fatal(){
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[31m\033[1mFatal\033[m ]: $*"
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[31m\033[1mScript was interupted\033[m!"
|
||||||
|
else
|
||||||
|
echo " [ Fatal ]: $*"
|
||||||
|
echo ""
|
||||||
|
echo " Script was terminated...."
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
clean_up 1
|
||||||
|
}
|
||||||
|
error (){
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[31m\033[1mError\033[m ]: $*"
|
||||||
|
else
|
||||||
|
echo "[ Error ]: $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
warn (){
|
||||||
|
echo ""
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
|
||||||
|
else
|
||||||
|
echo "[ Warning ]: $*"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
warn_only_terminal () {
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
info (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e " [ \033[32m\033[1mInfo\033[m ] $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ok (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e " [ \033[32m\033[1mOk\033[m ] $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_done() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[32mdone\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_ok() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[32mok\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_warn() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[33mwarn\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_failed(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_skipped() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[75G[ \033[90m\033[1mskipped\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_wait(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -en "\033[75G[ \033[5m\033[1m...\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
local var="$*"
|
||||||
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||||
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||||
|
echo -n "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
blank_line() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
containsElement () {
|
||||||
|
local e
|
||||||
|
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
is_number() {
|
||||||
|
|
||||||
|
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||||
|
|
||||||
|
# - also possible
|
||||||
|
# -
|
||||||
|
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||||
|
#return $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||||
|
}
|
||||||
|
|
||||||
|
is_valid_ipv4() {
|
||||||
|
local -a octets=( ${1//\./ } )
|
||||||
|
local RETURNVALUE=0
|
||||||
|
|
||||||
|
# return an error if the IP doesn't have exactly 4 octets
|
||||||
|
[[ ${#octets[@]} -ne 4 ]] && return 1
|
||||||
|
|
||||||
|
for octet in ${octets[@]}
|
||||||
|
do
|
||||||
|
if [[ ${octet} =~ ^[0-9]{1,3}$ ]]
|
||||||
|
then # shift number by 8 bits, anything larger than 255 will be > 0
|
||||||
|
((RETURNVALUE += octet>>8 ))
|
||||||
|
else # octet wasn't numeric, return error
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return ${RETURNVALUE}
|
||||||
|
}
|
||||||
|
|
||||||
|
# - Test if given argument is a valid IPv6 Address
|
||||||
|
# -
|
||||||
|
#is_valid_ipv6() {
|
||||||
|
# local _ipv6=$1
|
||||||
|
#
|
||||||
|
# if [ "$1" != "${1#[0-9a-f]*:}" ] \
|
||||||
|
# && [ "$1" = "${1#*[^0-9a-f:]}" ] \
|
||||||
|
# && [ "${1#*[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]}" = "${1#*:*:*:*:*:*:*:*:*:}" ]; then
|
||||||
|
# return 0
|
||||||
|
# else
|
||||||
|
# return 1
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
|
is_valid_ipv6() {
|
||||||
|
local _ipv6="$1"
|
||||||
|
|
||||||
|
_regex_ipv6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$_ipv6" =~ ${_regex_ipv6} ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Some checks ..
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
# - Running in a terminal?
|
||||||
|
# -
|
||||||
|
if [[ -t 1 ]] ; then
|
||||||
|
terminal=true
|
||||||
|
else
|
||||||
|
terminal=false
|
||||||
|
BATCH_MODE=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Default Values
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
BATCH_MODE=false
|
||||||
|
|
||||||
|
DEFAULT_MUNIN_CONF_FILE='/etc/munin/munin-node.conf'
|
||||||
|
|
||||||
|
DEFAULT_IPT_FIREWALL_MAIN_IPV4_FILE='/etc/ipt-firewall/main_ipv4.conf'
|
||||||
|
DEFAULT_IPT_FIREWALL_MAIN_IPV6_FILE='/etc/ipt-firewall/main_ipv6.conf'
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Read Configuration
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if [[ -f "$conf_file" ]]; then
|
||||||
|
source "$conf_file"
|
||||||
|
else
|
||||||
|
warn_only_terminal "No configuration file '$conf_file' present.\n
|
||||||
|
Loading default values.."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Read commandline parameter
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
while getopts bh opt ; do
|
||||||
|
case $opt in
|
||||||
|
b) BATCH_MODE=true
|
||||||
|
;;
|
||||||
|
h) usage
|
||||||
|
;;
|
||||||
|
\?) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "${IPv4_ADDRESS_OLD}" ]] ; then
|
||||||
|
_IPv4_ADDRESS_OLD="${IPv4_ADDRESS_OLD}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${IPv6_ADDRESS_OLD}" ]] ; then
|
||||||
|
_IPv6_ADDRESS_OLD="${IPv6_ADDRESS_OLD}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${IPv4_ADDRESS_NEW}" ]] ; then
|
||||||
|
_IPv4_ADDRESS_NEW="${IPv4_ADDRESS_NEW}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${IPv6_ADDRESS_NEW}" ]] ; then
|
||||||
|
_IPv6_ADDRESS_NEW="${IPv6_ADDRESS_NEW}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${MUNIN_CONF_FILE}" ]]; then
|
||||||
|
MUNIN_CONF_FILE="${DEFAULT_MUNIN_CONF_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${IPT_FIREWALL_MAIN_IPV4_FILE}" ]]; then
|
||||||
|
IPT_FIREWALL_MAIN_IPV4_FILE="${DEFAULT_IPT_FIREWALL_MAIN_IPV4_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${IPT_FIREWALL_MAIN_IPV6_FILE}" ]]; then
|
||||||
|
IPT_FIREWALL_MAIN_IPV6_FILE="${DEFAULT_IPT_FIREWALL_MAIN_IPV6_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ${BATCH_MODE} && ( [[ -z "${IPv4_ADDRESS_OLD}" ]] || [[ -z "${IPv4_ADDRESS_NEW}" ]] \
|
||||||
|
|| [[ -z "${IPv6_ADDRESS_OLD}" ]] || [[ -z "${IPv6_ADDRESS_NEW}" ]] ) ; then
|
||||||
|
|
||||||
|
[[ -z "${IPv4_ADDRESS_OLD}" ]] && fatal "Variable 'IPv4_ADDRESS_OLD' is empty and we are in batch mode!"
|
||||||
|
[[ -z "${IPv4_ADDRESS_NEW}" ]] && fatal "Variable 'IPv4_ADDRESS_NEW' is empty and we are in batch mode!"
|
||||||
|
[[ -z "${IPv6_ADDRESS_OLD}" ]] && fatal "Variable 'IPv6_ADDRESS_OLD' is empty and we are in batch mode!"
|
||||||
|
[[ -z "${IPv6_ADDRESS_NEW}" ]] && fatal "Variable 'IPv6_ADDRESS_NEW' is empty and we are in batch mode!"
|
||||||
|
|
||||||
|
fatal "Something wired went wrong.."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ${BATCH_MODE} && ${terminal}; then
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo "Insert IPv4-Address which do you want to change (old address)."
|
||||||
|
echo ""
|
||||||
|
echo -e "Type \"\033[33mNone\033[m\" if no IPv4 address should be changed."
|
||||||
|
echo ""
|
||||||
|
IPv4_ADDRESS_OLD=
|
||||||
|
_set_ipv4=true
|
||||||
|
while [ "X$IPv4_ADDRESS_OLD" = "X" ]; do
|
||||||
|
|
||||||
|
if [[ -z "${_IPv4_ADDRESS_OLD}" ]]; then
|
||||||
|
echononl "Old IPv4-Address: "
|
||||||
|
|
||||||
|
read IPv4_ADDRESS_OLD
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv4_ADDRESS_OLD=${IPv4_ADDRESS_OLD,,}
|
||||||
|
|
||||||
|
if [ "X$IPv4_ADDRESS_OLD" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||||
|
IPv4_ADDRESS_OLD=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echononl "Old IPv4-Address: [${_IPv4_ADDRESS_OLD}]: "
|
||||||
|
|
||||||
|
read IPv4_ADDRESS_OLD
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv4_ADDRESS_OLD=${IPv4_ADDRESS_OLD,,}
|
||||||
|
|
||||||
|
if [[ -z "$(trim ${IPv4_ADDRESS_OLD})" ]]; then
|
||||||
|
IPv4_ADDRESS_OLD=${_IPv4_ADDRESS_OLD}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${IPv4_ADDRESS_OLD,,}" = "none" ];then
|
||||||
|
_set_ipv4=false
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_valid_ipv4 $IPv4_ADDRESS_OLD ; then
|
||||||
|
echo -e "\n\t\033[33m\033[1m$IPv4_ADDRESS_OLD\033[m is NOT a valid IPv4 Address\n"
|
||||||
|
IPv4_ADDRESS_OLD=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $_set_ipv4 ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo "Insert IPv4-Address of the new munin server."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
IPv4_ADDRESS_NEW=
|
||||||
|
|
||||||
|
while [ "X$IPv4_ADDRESS_NEW" = "X" ]; do
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -z "${_IPv4_ADDRESS_NEW}" ]]; then
|
||||||
|
echononl "New IPv4-Address: "
|
||||||
|
|
||||||
|
read IPv4_ADDRESS_NEW
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv4_ADDRESS_NEW=${IPv4_ADDRESS_NEW,,}
|
||||||
|
|
||||||
|
if [ "X$IPv4_ADDRESS_NEW" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||||
|
IPv4_ADDRESS_NEW=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
echononl "New IPv4-Address [${_IPv4_ADDRESS_NEW}]: "
|
||||||
|
|
||||||
|
read IPv4_ADDRESS_NEW
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv4_ADDRESS_NEW=${IPv4_ADDRESS_NEW,,}
|
||||||
|
|
||||||
|
if [[ -z "$(trim ${IPv4_ADDRESS_NEW})" ]]; then
|
||||||
|
IPv4_ADDRESS_NEW=${_IPv4_ADDRESS_NEW}
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_valid_ipv4 $IPv4_ADDRESS_NEW ; then
|
||||||
|
echo -e "\n\t\033[33m\033[1m$IPv4_ADDRESS_NEW\033[m is NOT a valid IPv4 Address\n"
|
||||||
|
IPv4_ADDRESS_NEW=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo "Insert IPv6-Address which do you want to change (old address)."
|
||||||
|
echo ""
|
||||||
|
echo -e "Type \"\033[33mnone\033[m\" if no IPv6 address should be changed."
|
||||||
|
echo ""
|
||||||
|
IPv6_ADDRESS_OLD=
|
||||||
|
_set_ipv6=true
|
||||||
|
while [ "X$IPv6_ADDRESS_OLD" = "X" ]; do
|
||||||
|
|
||||||
|
if [[ -z "${_IPv6_ADDRESS_OLD}" ]]; then
|
||||||
|
echononl "Old IPv6-Address: "
|
||||||
|
|
||||||
|
read IPv6_ADDRESS_OLD
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv6_ADDRESS_OLD=${IPv6_ADDRESS_OLD,,}
|
||||||
|
|
||||||
|
if [ "X$IPv6_ADDRESS_OLD" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||||
|
IPv6_ADDRESS_OLD=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echononl "Old IPv6-Address: [${_IPv6_ADDRESS_OLD}]: "
|
||||||
|
|
||||||
|
read IPv6_ADDRESS_OLD
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv6_ADDRESS_OLD=${IPv6_ADDRESS_OLD,,}
|
||||||
|
|
||||||
|
if [[ -z "$(trim ${IPv6_ADDRESS_OLD})" ]]; then
|
||||||
|
IPv6_ADDRESS_OLD=${_IPv6_ADDRESS_OLD}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${IPv6_ADDRESS_OLD,,}" = "none" ];then
|
||||||
|
_set_IPv6=false
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_valid_ipv6 $IPv6_ADDRESS_OLD ; then
|
||||||
|
echo -e "\n\tXX\033[33m\033[1m$IPv6_ADDRESS_OLD\033[mXX is NOT a valid IPv6 Address\n"
|
||||||
|
IPv6_ADDRESS_OLD=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $_set_ipv6 ; then
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo "Insert IPv6-Address iof the new munin server"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
IPv6_ADDRESS_NEW=
|
||||||
|
|
||||||
|
|
||||||
|
while [ "X$IPv6_ADDRESS_NEW" = "X" ]; do
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -z "${_IPv6_ADDRESS_NEW}" ]]; then
|
||||||
|
echononl "New IPv6-Address: "
|
||||||
|
|
||||||
|
read IPv6_ADDRESS_NEW
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv6_ADDRESS_NEW=${IPv6_ADDRESS_NEW,,}
|
||||||
|
|
||||||
|
if [ "X$IPv6_ADDRESS_NEW" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||||
|
IPv6_ADDRESS_NEW=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
echononl "New IPv6-Address [${_IPv6_ADDRESS_NEW}]: "
|
||||||
|
|
||||||
|
read IPv6_ADDRESS_NEW
|
||||||
|
|
||||||
|
## - To lower case
|
||||||
|
IPv6_ADDRESS_NEW=${IPv6_ADDRESS_NEW,,}
|
||||||
|
|
||||||
|
if [[ -z "$(trim ${IPv6_ADDRESS_NEW})" ]]; then
|
||||||
|
IPv6_ADDRESS_NEW=${_IPv6_ADDRESS_NEW}
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_valid_ipv6 $IPv6_ADDRESS_NEW ; then
|
||||||
|
echo -e "\n\t\033[33m\033[1m$IPv6_ADDRESS_NEW\033[m is NOT a valid IPv6 Address\n"
|
||||||
|
IPv6_ADDRESS_NEW=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ${terminal} ; then
|
||||||
|
clear
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[14G\033[32mReplace IP-Address(es) for munin server\033[m"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if $_set_ipv4 ; then
|
||||||
|
echo " Old IPv4 Address...........................: $IPv4_ADDRESS_OLD"
|
||||||
|
echo " New IPv4 Address...........................: $IPv4_ADDRESS_NEW"
|
||||||
|
else
|
||||||
|
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"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
echononl " Replace ${IPv4_ADDRESS_OLD} in file '${MUNIN_CONF_FILE}'.."
|
||||||
|
if [[ -f "${MUNIN_CONF_FILE}" ]] ; then
|
||||||
|
if $(grep -q "${IPv4_ADDRESS_OLD}" "${MUNIN_CONF_FILE}" 2> /dev/null) ; then
|
||||||
|
perl -i -n -p -e "s#${IPv4_ADDRESS_OLD}#${IPv4_ADDRESS_NEW}#g" "${MUNIN_CONF_FILE}" > /dev/null 2>&1
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo_failed
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
|
||||||
|
echononl " Replace ${IPv6_ADDRESS_OLD} in file '${MUNIN_CONF_FILE}'.."
|
||||||
|
if [[ -f "${MUNIN_CONF_FILE}" ]] ; then
|
||||||
|
if $(grep -q "${IPv6_ADDRESS_OLD}" "${MUNIN_CONF_FILE}" 2> /dev/null) ; then
|
||||||
|
perl -i -n -p -e "s#${IPv6_ADDRESS_OLD}#${IPv6_ADDRESS_NEW}#g" "${MUNIN_CONF_FILE}" > /dev/null 2>&1
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo_failed
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echononl " Replace ${IPv4_ADDRESS_OLD} in file '${IPT_FIREWALL_MAIN_IPV4_FILE}'.."
|
||||||
|
if [[ -f "${IPT_FIREWALL_MAIN_IPV4_FILE}" ]] ; then
|
||||||
|
if $(grep -q -E "munin_remote_ip=\"?${IPv4_ADDRESS_OLD}\"?" "${IPT_FIREWALL_MAIN_IPV4_FILE}" 2> /dev/null) ; then
|
||||||
|
perl -i -n -p -e "s#munin_remote_ip=\"?${IPv4_ADDRESS_OLD}\"?#munin_remote_ip=\"${IPv4_ADDRESS_NEW}\"#g" "${IPT_FIREWALL_MAIN_IPV4_FILE}" > /dev/null 2>&1
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo_failed
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
|
||||||
|
echononl " Replace ${IPv6_ADDRESS_OLD} in file '${IPT_FIREWALL_MAIN_IPV6_FILE}'.."
|
||||||
|
if [[ -f "${IPT_FIREWALL_MAIN_IPV6_FILE}" ]] ; then
|
||||||
|
if $(grep -q -E "munin_remote_ip=\"?${IPv6_ADDRESS_OLD}\"?" "${IPT_FIREWALL_MAIN_IPV6_FILE}" 2> /dev/null) ; then
|
||||||
|
perl -i -n -p -e "s#munin_remote_ip=\"?${IPv6_ADDRESS_OLD}\"?#munin_remote_ip=\"${IPv6_ADDRESS_NEW}\"#g" "${IPT_FIREWALL_MAIN_IPV6_FILE}" > /dev/null 2>&1
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo_failed
|
||||||
|
else
|
||||||
|
echo_ok
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean_up 0
|
||||||
@@ -400,7 +400,7 @@ if $found ; then
|
|||||||
|
|
||||||
fi # if $(which lxc-ls > /dev/null)
|
fi # if $(which lxc-ls > /dev/null)
|
||||||
|
|
||||||
SUBJECT="[ Warning ] Hard disk storage on $(hostname -f) exceeds ${WARN_VALUE}%"
|
SUBJECT="[ Warning ] Hard disk usage (${_percent}%) on $(hostname -f) exceeds ${WARN_VALUE}%"
|
||||||
SUBJECT_UTF8="$(echo "${SUBJECT}" | iconv -t UTF8)"
|
SUBJECT_UTF8="$(echo "${SUBJECT}" | iconv -t UTF8)"
|
||||||
SUBJECT_UTF8_ENCODED="=?utf-8?B?$(echo ${SUBJECT_UTF8} | base64 --wrap=0)?="
|
SUBJECT_UTF8_ENCODED="=?utf-8?B?$(echo ${SUBJECT_UTF8} | base64 --wrap=0)?="
|
||||||
|
|
||||||
|
|||||||
56
conf/change_munin_ip.conf.sample
Normal file
56
conf/change_munin_ip.conf.sample
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# -------------------------------------------
|
||||||
|
# - Settings for script check-connectivity.sh
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
# IPv4_ADDRESS_OLD
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv4_ADDRESS_OLD=135.181.136.84
|
||||||
|
#
|
||||||
|
#IPv4_ADDRESS_OLD=
|
||||||
|
|
||||||
|
|
||||||
|
# IPv4_ADDRESS_NEW
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv4_ADDRESS_NEW=37.27.121.227
|
||||||
|
#
|
||||||
|
#IPv4_ADDRESS_NEW=
|
||||||
|
|
||||||
|
|
||||||
|
# IPv6_ADDRESS_OLD
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv6_ADDRESS_OLD='2a01:4f9:3a:1051::84'
|
||||||
|
#
|
||||||
|
# IPv6_ADDRESS_OLD
|
||||||
|
|
||||||
|
|
||||||
|
# IPv6_ADDRESS_NEW
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv6_ADDRESS_NEW='2a01:4f9:3070:2bda::227'
|
||||||
|
#
|
||||||
|
#IPv6_ADDRESS_NEW=
|
||||||
|
|
||||||
|
|
||||||
|
# MUNIN_CONF_FILE
|
||||||
|
#
|
||||||
|
# Defaults to: /etc/munin/munin-node.conf
|
||||||
|
#
|
||||||
|
#MUNIN_CONF_FILE='/etc/munin/munin-node.conf'
|
||||||
|
|
||||||
|
|
||||||
|
# IPT_FIREWALL_MAIN_IPV4_FILE
|
||||||
|
#
|
||||||
|
# Defaults to: /etc/ipt-firewall/main_ipv4.conf
|
||||||
|
#
|
||||||
|
#IPT_FIREWALL_MAIN_IPV4_FILE='/etc/ipt-firewall/main_ipv4.conf'
|
||||||
|
|
||||||
|
|
||||||
|
# IPT_FIREWALL_MAIN_IPV6_FILE
|
||||||
|
#
|
||||||
|
#Defaults to: /etc/ipt-firewall/main_ipv6.conf
|
||||||
|
#
|
||||||
|
#IPT_FIREWALL_MAIN_IPV6_FILE='/etc/ipt-firewall/main_ipv6.conf'
|
||||||
|
|
||||||
62
create_change_munin_ip.conf.sh
Executable file
62
create_change_munin_ip.conf.sh
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
cat <<EOF > /root/bin/admin-stuff/conf/change_munin_ip.conf
|
||||||
|
# -------------------------------------------
|
||||||
|
# - Settings for script check-connectivity.sh
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
# IPv4_ADDRESS_OLD
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv4_ADDRESS_OLD=135.181.136.84
|
||||||
|
#
|
||||||
|
#IPv4_ADDRESS_OLD=
|
||||||
|
IPv4_ADDRESS_OLD=135.181.136.84
|
||||||
|
|
||||||
|
|
||||||
|
# IPv4_ADDRESS_NEW
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv4_ADDRESS_NEW=37.27.121.227
|
||||||
|
#
|
||||||
|
#IPv4_ADDRESS_NEW=
|
||||||
|
IPv4_ADDRESS_NEW=37.27.121.227
|
||||||
|
|
||||||
|
|
||||||
|
# IPv6_ADDRESS_OLD
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv6_ADDRESS_OLD='2a01:4f9:3a:1051::84'
|
||||||
|
#
|
||||||
|
# IPv6_ADDRESS_OLD
|
||||||
|
IPv6_ADDRESS_OLD='2a01:4f9:3a:1051::84'
|
||||||
|
|
||||||
|
|
||||||
|
# IPv6_ADDRESS_NEW
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# IPv6_ADDRESS_NEW='2a01:4f9:3070:2bda::227'
|
||||||
|
#
|
||||||
|
#IPv6_ADDRESS_NEW=
|
||||||
|
IPv6_ADDRESS_NEW='2a01:4f9:3070:2bda::227'
|
||||||
|
|
||||||
|
|
||||||
|
# MUNIN_CONF_FILE
|
||||||
|
#
|
||||||
|
# Defaults to: /etc/munin/munin-node.conf
|
||||||
|
#
|
||||||
|
#MUNIN_CONF_FILE='/etc/munin/munin-node.conf'
|
||||||
|
|
||||||
|
|
||||||
|
# IPT_FIREWALL_MAIN_IPV4_FILE
|
||||||
|
#
|
||||||
|
# Defaults to: /etc/ipt-firewall/main_ipv4.conf
|
||||||
|
#
|
||||||
|
#IPT_FIREWALL_MAIN_IPV4_FILE='/etc/ipt-firewall/main_ipv4.conf'
|
||||||
|
|
||||||
|
|
||||||
|
# IPT_FIREWALL_MAIN_IPV6_FILE
|
||||||
|
#
|
||||||
|
#Defaults to: /etc/ipt-firewall/main_ipv6.conf
|
||||||
|
#
|
||||||
|
#IPT_FIREWALL_MAIN_IPV6_FILE='/etc/ipt-firewall/main_ipv6.conf'
|
||||||
|
EOF
|
||||||
@@ -1,5 +1,174 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_name="$(basename $(realpath $0))"
|
||||||
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
|
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||||
|
|
||||||
|
log_file="$(mktemp)"
|
||||||
|
random_prefix="$(head -c 300 /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c 8)"
|
||||||
|
|
||||||
|
backup_date=$(date +%Y-%m-%d-%H%M)
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Some Variables
|
||||||
|
# =============
|
||||||
|
|
||||||
|
declare -a lx_container_arr=()
|
||||||
|
declare -a lx_running_container_arr=()
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Some Functions
|
||||||
|
# =============
|
||||||
|
|
||||||
|
clean_up() {
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -f "$_backup_crontab_file" ]]; then
|
||||||
|
|
||||||
|
blank_line
|
||||||
|
echononl " (Re)Install Crontab from previously saved crontab file
|
||||||
|
'$_backup_crontab_file'.."
|
||||||
|
|
||||||
|
crontab $_backup_crontab_file >> $log_file 2>&1
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
error "$(cat $log_file)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Perform program exit housekeeping
|
||||||
|
rm -f $log_file
|
||||||
|
rm -rf /tmp/*.${random_prefix}
|
||||||
|
blank_line
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
echononl(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo X\\c > /tmp/shprompt$$
|
||||||
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
echo -e -n "[ \033[5m\033[1m....\033[m ]\033[13G$*\\c" 1>&2
|
||||||
|
else
|
||||||
|
echo -e -n "[ \033[5m\033[1m....\033[m ]\033[13G$*" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_print_command() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo X\\c > /tmp/shprompt$$
|
||||||
|
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||||
|
echo -e -n "\n\033[13G\033[1m$*\\c\033[m" 1>&2
|
||||||
|
else
|
||||||
|
echo -e -n "\n\033[13G\033[1m$*\033[m" 1>&2
|
||||||
|
fi
|
||||||
|
rm /tmp/shprompt$$
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_done() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;32mdone\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_ok() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;32mok\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_ignore() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;33mignore\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_warning() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;33m\033[1mwarn\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_failed(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;31mfail\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_skipped() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "\033[1G[ \033[1;37mskip\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo_wait(){
|
||||||
|
if $terminal ; then
|
||||||
|
echo -en "\033[1G[ \033[5m\033[1m...\033[m ]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fatal (){
|
||||||
|
blank_line
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "[ \033[31m\033[1mFatal\033[m ] \033[13G\033[37m\033[1m$*\033[m"
|
||||||
|
echo ""
|
||||||
|
echo -e " \033[13G\033[31m\033[1mScript will be interrupted..\033[m\033[m"
|
||||||
|
else
|
||||||
|
echo "fatal: $*"
|
||||||
|
echo "Script will be interrupted.."
|
||||||
|
fi
|
||||||
|
clean_up 1
|
||||||
|
}
|
||||||
|
error(){
|
||||||
|
blank_line
|
||||||
|
if $terminal ; then
|
||||||
|
echo -e "[ \033[31m\033[1mFehler\033[m ]\033[13G$*"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "[ Error ]: $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
blank_line
|
||||||
|
}
|
||||||
|
|
||||||
|
warn (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "[ \033[33m\033[1mWarning\033[m ]\033[13G$*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
info (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "[ \033[32m\033[1mInfo\033[m ]\033[13G$*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## - Check if a given array (parameter 2) contains a given string (parameter 1)
|
||||||
|
## -
|
||||||
|
containsElement () {
|
||||||
|
local e
|
||||||
|
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
local var="$*"
|
||||||
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||||
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||||
|
echo -n "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
blank_line() {
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
if [ -n "$1" ];then
|
if [ -n "$1" ];then
|
||||||
echo -e "\n [ Error ]: $1"
|
echo -e "\n [ Error ]: $1"
|
||||||
@@ -15,7 +184,7 @@ cat<<EOF
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
exit 1
|
clean_up 1
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidDate() {
|
isValidDate() {
|
||||||
@@ -48,6 +217,31 @@ isValidDate() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Jobhandling
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
|
||||||
|
# -
|
||||||
|
trap clean_up SIGHUP SIGINT SIGTERM
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# =============
|
||||||
|
# --- Some Checks
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# - Running in a terminal?
|
||||||
|
# -
|
||||||
|
if [[ -t 1 ]] ; then
|
||||||
|
terminal=true
|
||||||
|
else
|
||||||
|
terminal=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
[ $# -ne "1" ] && usage "Wrong number of arguments"
|
[ $# -ne "1" ] && usage "Wrong number of arguments"
|
||||||
|
|
||||||
_date=$1
|
_date=$1
|
||||||
@@ -62,6 +256,114 @@ if ! isValidDate "${__day}-${__month}-${__year}" ; then
|
|||||||
usage "Invalid date: ${_date}"
|
usage "Invalid date: ${_date}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "$(/bin/date +%Y-%m-%d)" == "$_date" ]] && /sbin/poweroff
|
|
||||||
|
|
||||||
|
# ==========
|
||||||
|
# - Begin Main Script
|
||||||
|
# ==========
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Headline
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[1m----------\033[m"
|
||||||
|
echo -e "\033[32m\033[1mRunning script \033[m\033[1m$script_name\033[32m .. \033[m"
|
||||||
|
echo -e "\033[1m----------\033[m"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$(/bin/date +%Y-%m-%d)" != "$_date" ]] ; then
|
||||||
|
|
||||||
|
info "Shutdown Date \\033[1m${_date} \033[mis NOT today. So nothing to do.."
|
||||||
|
|
||||||
|
clean_up 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if $(dpkg -l 2> /dev/null | grep -q "lxc" 2> /dev/null) \
|
||||||
|
|| $(systemctl list-unit-files | grep -q "lxc"); then
|
||||||
|
|
||||||
|
echononl "Get List of \033[1mall existing\033[m LX Contaoner.."
|
||||||
|
|
||||||
|
_failed=false
|
||||||
|
for _container in $(lxc-ls) ; do
|
||||||
|
lx_container_arr+=("$_container")
|
||||||
|
[[ $? -gt 0 ]] && _falied=true
|
||||||
|
done
|
||||||
|
if $_failed ; then
|
||||||
|
echo_failed
|
||||||
|
fatal "Getting list of \033[1mall\033[m LX-Container failed!"
|
||||||
|
else
|
||||||
|
echo_done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
_failed=false
|
||||||
|
echononl "Get List of \033[1mrunning\033[m LX Contaoner.."
|
||||||
|
for _container in $(lxc-ls --running) ; do
|
||||||
|
lx_running_container_arr+=("$_container")
|
||||||
|
[[ $? -gt 0 ]] && _falied=true
|
||||||
|
done
|
||||||
|
if $_failed ; then
|
||||||
|
echo_failed
|
||||||
|
fatal "Getting list of \033[1mrunning\033[m LX-Container failed!"
|
||||||
|
else
|
||||||
|
echo_done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ ${#lx_container_arr[@]} -gt 0 ]]; then
|
||||||
|
|
||||||
|
for _lx_container in "${lx_container_arr[@]}" ; do
|
||||||
|
|
||||||
|
echononl "Stopping Container ${_lx_container}.."
|
||||||
|
|
||||||
|
if containsElement "$_lx_container" "${lx_running_container_arr[@]}" ; then
|
||||||
|
|
||||||
|
lxc-stop -n ${_lx_container} > $log_file 2>&1
|
||||||
|
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo_failed
|
||||||
|
fatal "$(cat $log_file)"
|
||||||
|
else
|
||||||
|
echo_done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
info "NO LX Container on this Host"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[13G\033[1mGoing to power off the system ..\033[m"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
|
||||||
|
from_address="power-off@$(hostname -f)"
|
||||||
|
to_address="root"
|
||||||
|
content_type='Content-Type: text/plain;\n charset="utf-8"'
|
||||||
|
subject="Power OFF System $(hostname -f).."
|
||||||
|
msg=" Going to power off system '$(hostname -f)' .."
|
||||||
|
|
||||||
|
echo -e "To:${to_address}\n${content_type}\nSubject:$subject\n\n${msg}\n" \
|
||||||
|
| /usr/sbin/sendmail -F "Webservice Monitor" -f $from_address $to_address
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
/sbin/poweroff
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -122,3 +122,8 @@ export EDITOR=vim
|
|||||||
## - set beep more quiet
|
## - set beep more quiet
|
||||||
## -
|
## -
|
||||||
#xset b 10 500 50
|
#xset b 10 500 50
|
||||||
|
|
||||||
|
# turn off the beep (only in bash tab-complete ?)
|
||||||
|
# only if interactiv shell
|
||||||
|
[[ "$-" =~ "i" ]] && bind 'set bell-style none'
|
||||||
|
|
||||||
|
|||||||
@@ -171,3 +171,5 @@ set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\
|
|||||||
set laststatus=2
|
set laststatus=2
|
||||||
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||||
|
|
||||||
|
set belloff=all
|
||||||
|
|
||||||
|
|||||||
@@ -122,3 +122,7 @@ export EDITOR=vim
|
|||||||
## - set beep more quiet
|
## - set beep more quiet
|
||||||
## -
|
## -
|
||||||
#xset b 10 500 50
|
#xset b 10 500 50
|
||||||
|
|
||||||
|
# turn off the beep (only in bash tab-complete ?)
|
||||||
|
# only if interactiv shell
|
||||||
|
[[ "$-" =~ "i" ]] && bind 'set bell-style none'
|
||||||
|
|||||||
@@ -171,3 +171,4 @@ set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\
|
|||||||
set laststatus=2
|
set laststatus=2
|
||||||
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||||
|
|
||||||
|
set belloff=all
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL4wVpkMrF4M5wKBxRAonR4gVngO9+yhBEAyhV03l6Is
|
||||||
@@ -69,3 +69,8 @@ export LINES=64
|
|||||||
## - set beep more quiet
|
## - set beep more quiet
|
||||||
## -
|
## -
|
||||||
#xset b 10 500 50
|
#xset b 10 500 50
|
||||||
|
|
||||||
|
# turn off the beep (only in bash tab-complete ?)
|
||||||
|
# only if interactiv shell
|
||||||
|
[[ "$-" =~ "i" ]] && bind 'set bell-style none'
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ if [ -f "/usr/share/mc/bin/mc.sh" ]; then
|
|||||||
source /usr/share/mc/bin/mc.sh
|
source /usr/share/mc/bin/mc.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mesg n
|
if command -v mesg >/dev/null 2>&1; then
|
||||||
|
mesg n
|
||||||
|
fi
|
||||||
|
|||||||
175
supported-files/user_templates/root/.vimrc
Normal file
175
supported-files/user_templates/root/.vimrc
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
" An example for a vimrc file.
|
||||||
|
"
|
||||||
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
" Last change: 1999 Sep 09
|
||||||
|
"
|
||||||
|
" To use it, copy it to
|
||||||
|
" for Unix and OS/2: ~/.vimrc
|
||||||
|
" for Amiga: s:.vimrc
|
||||||
|
" for MS-DOS and Win32: $VIM\_vimrc
|
||||||
|
|
||||||
|
" This line should not be removed as it ensures that various options are
|
||||||
|
" properly set to work with the Vim-related packages available in Debian.
|
||||||
|
runtime! debian.vim
|
||||||
|
|
||||||
|
set nocompatible " Use Vim defaults (much better!)
|
||||||
|
set bs=2 " allow backspacing over everything in insert mode
|
||||||
|
set ai " always set autoindenting on
|
||||||
|
" set backup " keep a backup file
|
||||||
|
"set viminfo='20,\"50 " read/write a .viminfo file, don't store more
|
||||||
|
" than 50 lines of registers
|
||||||
|
set viminfo='20,\"50,:20,%,n~/.viminfo
|
||||||
|
set history=50 " keep 50 lines of command line history
|
||||||
|
set ruler " show the cursor position all the time
|
||||||
|
set ignorecase " suchen case-insenitiv
|
||||||
|
set showmatch " zeige passende klammern
|
||||||
|
set shell=/bin/bash " shell to start with !
|
||||||
|
set expandtab " tabs --> blanks
|
||||||
|
set showmode " anzeige INSERT/REPLACE/...
|
||||||
|
|
||||||
|
" set smartcase " Do smart case matching
|
||||||
|
|
||||||
|
set incsearch " Incremental search
|
||||||
|
" Start searching when you type the first character of
|
||||||
|
" the search string. As you type in more characters, the
|
||||||
|
" search is refined.
|
||||||
|
|
||||||
|
set t_Co=256 " To enable 256 colors in vim, put this your .vimrc before setting the colorscheme
|
||||||
|
|
||||||
|
" einrueckung
|
||||||
|
set shiftwidth=3
|
||||||
|
set tabstop=3
|
||||||
|
" Round indent to multiple of 'shiftwidth' for > and < commands
|
||||||
|
set shiftround
|
||||||
|
|
||||||
|
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
|
||||||
|
" let &guioptions = substitute(&guioptions, "t", "", "g")
|
||||||
|
|
||||||
|
" Don't use Ex mode, use Q for formatting
|
||||||
|
map Q gq
|
||||||
|
|
||||||
|
" Make p in isual Visual mode replace the selected text with the "" register.
|
||||||
|
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
|
||||||
|
|
||||||
|
" Switch syntax highlighting on, when the terminal has colors
|
||||||
|
" Also switch on highlighting the last used search pattern.
|
||||||
|
if &t_Co > 2 || has("gui_running")
|
||||||
|
syntax on
|
||||||
|
set hlsearch
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Only do this part when compiled with support for autocommands.
|
||||||
|
if has("autocmd")
|
||||||
|
|
||||||
|
" In text files, always limit the width of text to 78 characters
|
||||||
|
autocmd BufRead *.txt set tw=78
|
||||||
|
|
||||||
|
augroup cprog
|
||||||
|
" Remove all cprog autocommands
|
||||||
|
au!
|
||||||
|
|
||||||
|
" When starting to edit a file:
|
||||||
|
" For C and C++ files set formatting of comments and set C-indenting on.
|
||||||
|
" For other files switch it off.
|
||||||
|
" Don't change the order, it's important that the line with * comes first.
|
||||||
|
autocmd FileType * set formatoptions=tcql nocindent comments&
|
||||||
|
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
augroup gzip
|
||||||
|
" Remove all gzip autocommands
|
||||||
|
au!
|
||||||
|
|
||||||
|
" Enable editing of gzipped files
|
||||||
|
" set binary mode before reading the file
|
||||||
|
autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin
|
||||||
|
autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip")
|
||||||
|
autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2")
|
||||||
|
autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip")
|
||||||
|
autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2")
|
||||||
|
autocmd FileAppendPre *.gz call GZIP_appre("gunzip")
|
||||||
|
autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2")
|
||||||
|
autocmd FileAppendPost *.gz call GZIP_write("gzip")
|
||||||
|
autocmd FileAppendPost *.bz2 call GZIP_write("bzip2")
|
||||||
|
|
||||||
|
" After reading compressed file: Uncompress text in buffer with "cmd"
|
||||||
|
fun! GZIP_read(cmd)
|
||||||
|
let ch_save = &ch
|
||||||
|
set ch=2
|
||||||
|
execute "'[,']!" . a:cmd
|
||||||
|
set nobin
|
||||||
|
let &ch = ch_save
|
||||||
|
execute ":doautocmd BufReadPost " . expand("%:r")
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" After writing compressed file: Compress written file with "cmd"
|
||||||
|
fun! GZIP_write(cmd)
|
||||||
|
if rename(expand("<afile>"), expand("<afile>:r")) == 0
|
||||||
|
execute "!" . a:cmd . " <afile>:r"
|
||||||
|
endif
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" Before appending to compressed file: Uncompress file with "cmd"
|
||||||
|
fun! GZIP_appre(cmd)
|
||||||
|
execute "!" . a:cmd . " <afile>"
|
||||||
|
call rename(expand("<afile>:r"), expand("<afile>"))
|
||||||
|
endfun
|
||||||
|
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" This is disabled, because it changes the jumplist. Can't use CTRL-O to go
|
||||||
|
" back to positions in previous files more than once.
|
||||||
|
if 0
|
||||||
|
" When editing a file, always jump to the last cursor position.
|
||||||
|
" This must be after the uncompress commands.
|
||||||
|
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif " has("autocmd")
|
||||||
|
|
||||||
|
" toggle syntax highlighting
|
||||||
|
map <F12> :if exists("syntax_on") <Bar> syntax off <Bar> else <Bar> syntax on <Bar> endif <CR><ESC>
|
||||||
|
map <F11> :nohls <CR>
|
||||||
|
|
||||||
|
" use <F6> to toggle line numbers
|
||||||
|
nmap <silent> <F6> :set number!<CR>
|
||||||
|
|
||||||
|
|
||||||
|
" If using a dark background within the editing area and syntax highlighting
|
||||||
|
" turn on this option as well
|
||||||
|
set background=dark
|
||||||
|
|
||||||
|
|
||||||
|
" set color for search
|
||||||
|
hi clear search
|
||||||
|
hi search term=bold,reverse cterm=bold,reverse gui=bold,reverse
|
||||||
|
|
||||||
|
" set color for Comment
|
||||||
|
hi clear Comment
|
||||||
|
"highlight Comment term=bold cterm=bold ctermfg=LightBlue guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=LightBlue guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=bold cterm=bold ctermfg=grey guifg=#80a0ff gui=bold
|
||||||
|
highlight Comment term=none cterm=none ctermfg=grey guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=177 guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=215 guifg=#80a0ff gui=bold
|
||||||
|
|
||||||
|
" Go back to the position the cursor was on the last time this file was edited
|
||||||
|
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
|
||||||
|
|
||||||
|
" visual shifting (does not exit Visual mode)
|
||||||
|
vnoremap < <gv
|
||||||
|
vnoremap > >gv
|
||||||
|
|
||||||
|
" Scroll when cursor gets within 3 characters of top/bottom edge
|
||||||
|
set scrolloff=3
|
||||||
|
|
||||||
|
" Show line, column number, and relative position within a file in the status line
|
||||||
|
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
|
||||||
|
"set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)%(\|\ syntax:\ %{synIDattr(synID(line('.'),col('.'),0),'name')}%)\ \ %=line:\ %l/%L\ \|\ column:\ %c%V\ \|\ relative\:\ %p%%\
|
||||||
|
set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)\ \ %=line:\ %l/%L\ \|\ col:\ %c%V\ \|\ %p%%
|
||||||
|
" Always show status line, even for one window
|
||||||
|
set laststatus=2
|
||||||
|
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||||
|
|
||||||
|
set belloff=all
|
||||||
|
|
||||||
129
supported-files/user_templates/sysadm/.bashrc
Normal file
129
supported-files/user_templates/sysadm/.bashrc
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||||
|
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||||
|
# for examples
|
||||||
|
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
case $- in
|
||||||
|
*i*) ;;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# don't put duplicate lines or lines starting with space in the history.
|
||||||
|
# See bash(1) for more options
|
||||||
|
HISTCONTROL=ignoreboth
|
||||||
|
|
||||||
|
# append to the history file, don't overwrite it
|
||||||
|
shopt -s histappend
|
||||||
|
|
||||||
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||||
|
HISTSIZE=1000
|
||||||
|
HISTFILESIZE=2000
|
||||||
|
|
||||||
|
# check the window size after each command and, if necessary,
|
||||||
|
# update the values of LINES and COLUMNS.
|
||||||
|
shopt -s checkwinsize
|
||||||
|
|
||||||
|
# If set, the pattern "**" used in a pathname expansion context will
|
||||||
|
# match all files and zero or more directories and subdirectories.
|
||||||
|
#shopt -s globstar
|
||||||
|
|
||||||
|
# make less more friendly for non-text input files, see lesspipe(1)
|
||||||
|
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||||
|
|
||||||
|
# set variable identifying the chroot you work in (used in the prompt below)
|
||||||
|
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||||
|
debian_chroot=$(cat /etc/debian_chroot)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||||
|
case "$TERM" in
|
||||||
|
xterm-color) color_prompt=yes;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||||
|
# off by default to not distract the user: the focus in a terminal window
|
||||||
|
# should be on the output of commands, not on the prompt
|
||||||
|
#force_color_prompt=yes
|
||||||
|
|
||||||
|
if [ -n "$force_color_prompt" ]; then
|
||||||
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||||
|
# We have color support; assume it's compliant with Ecma-48
|
||||||
|
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||||
|
# a case would tend to support setf rather than setaf.)
|
||||||
|
color_prompt=yes
|
||||||
|
else
|
||||||
|
color_prompt=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
__hostname="$(hostname -f)"
|
||||||
|
__hostname="${__hostname%.*}"
|
||||||
|
__hostname="${__hostname%.*}"
|
||||||
|
if [ "$color_prompt" = yes ]; then
|
||||||
|
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@${__hostname}:\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
else
|
||||||
|
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\u@${__hostname}:\w\$ '
|
||||||
|
fi
|
||||||
|
unset color_prompt force_color_prompt
|
||||||
|
|
||||||
|
# If this is an xterm set the title to user@host:dir
|
||||||
|
case "$TERM" in
|
||||||
|
xterm*|rxvt*)
|
||||||
|
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# enable color support of ls and also add handy aliases
|
||||||
|
if [ -x /usr/bin/dircolors ]; then
|
||||||
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
#alias dir='dir --color=auto'
|
||||||
|
#alias vdir='vdir --color=auto'
|
||||||
|
|
||||||
|
#alias grep='grep --color=auto'
|
||||||
|
#alias fgrep='fgrep --color=auto'
|
||||||
|
#alias egrep='egrep --color=auto'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# some more ls aliases
|
||||||
|
alias ll='ls -l'
|
||||||
|
alias la='ls -A'
|
||||||
|
alias l='ls -CF'
|
||||||
|
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
alias ....='cd ../../..'
|
||||||
|
|
||||||
|
# Alias definitions.
|
||||||
|
# You may want to put all your additions into a separate file like
|
||||||
|
# ~/.bash_aliases, instead of adding them here directly.
|
||||||
|
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||||
|
|
||||||
|
if [ -f ~/.bash_aliases ]; then
|
||||||
|
. ~/.bash_aliases
|
||||||
|
fi
|
||||||
|
|
||||||
|
# enable programmable completion features (you don't need to enable
|
||||||
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||||
|
# sources /etc/bash.bashrc).
|
||||||
|
if ! shopt -oq posix; then
|
||||||
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||||
|
. /usr/share/bash-completion/bash_completion
|
||||||
|
elif [ -f /etc/bash_completion ]; then
|
||||||
|
. /etc/bash_completion
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
export EDITOR=vim
|
||||||
|
|
||||||
|
## - set beep more quiet
|
||||||
|
## -
|
||||||
|
#xset b 10 500 50
|
||||||
|
|
||||||
|
# turn off the beep (only in bash tab-complete ?)
|
||||||
|
# only if interactiv shell
|
||||||
|
[[ "$-" =~ "i" ]] && bind 'set bell-style none'
|
||||||
|
|
||||||
31
supported-files/user_templates/sysadm/.profile
Normal file
31
supported-files/user_templates/sysadm/.profile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# ~/.profile: executed by the command interpreter for login shells.
|
||||||
|
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
||||||
|
# exists.
|
||||||
|
# see /usr/share/doc/bash/examples/startup-files for examples.
|
||||||
|
# the files are located in the bash-doc package.
|
||||||
|
|
||||||
|
# the default umask is set in /etc/profile; for setting the umask
|
||||||
|
# for ssh logins, install and configure the libpam-umask package.
|
||||||
|
#umask 022
|
||||||
|
|
||||||
|
# if running bash
|
||||||
|
if [ -n "$BASH_VERSION" ]; then
|
||||||
|
# include .bashrc if it exists
|
||||||
|
if [ -f "$HOME/.bashrc" ]; then
|
||||||
|
. "$HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/bin" ] ; then
|
||||||
|
PATH="$HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# this is for the midnight-commander
|
||||||
|
# to become the last directory the midnight commander was in
|
||||||
|
# as the current directory when leaving the midnight commander
|
||||||
|
#
|
||||||
|
#. /usr/lib/mc/bin/mc.sh
|
||||||
|
if [ -f "/usr/share/mc/bin/mc.sh" ]; then
|
||||||
|
source /usr/share/mc/bin/mc.sh
|
||||||
|
fi
|
||||||
175
supported-files/user_templates/sysadm/.vimrc
Normal file
175
supported-files/user_templates/sysadm/.vimrc
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
" An example for a vimrc file.
|
||||||
|
"
|
||||||
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
" Last change: 1999 Sep 09
|
||||||
|
"
|
||||||
|
" To use it, copy it to
|
||||||
|
" for Unix and OS/2: ~/.vimrc
|
||||||
|
" for Amiga: s:.vimrc
|
||||||
|
" for MS-DOS and Win32: $VIM\_vimrc
|
||||||
|
|
||||||
|
" This line should not be removed as it ensures that various options are
|
||||||
|
" properly set to work with the Vim-related packages available in Debian.
|
||||||
|
runtime! debian.vim
|
||||||
|
|
||||||
|
set nocompatible " Use Vim defaults (much better!)
|
||||||
|
set bs=2 " allow backspacing over everything in insert mode
|
||||||
|
set ai " always set autoindenting on
|
||||||
|
" set backup " keep a backup file
|
||||||
|
"set viminfo='20,\"50 " read/write a .viminfo file, don't store more
|
||||||
|
" than 50 lines of registers
|
||||||
|
set viminfo='20,\"50,:20,%,n~/.viminfo
|
||||||
|
set history=50 " keep 50 lines of command line history
|
||||||
|
set ruler " show the cursor position all the time
|
||||||
|
set ignorecase " suchen case-insenitiv
|
||||||
|
set showmatch " zeige passende klammern
|
||||||
|
set shell=/bin/bash " shell to start with !
|
||||||
|
set expandtab " tabs --> blanks
|
||||||
|
set showmode " anzeige INSERT/REPLACE/...
|
||||||
|
|
||||||
|
" set smartcase " Do smart case matching
|
||||||
|
|
||||||
|
set incsearch " Incremental search
|
||||||
|
" Start searching when you type the first character of
|
||||||
|
" the search string. As you type in more characters, the
|
||||||
|
" search is refined.
|
||||||
|
|
||||||
|
set t_Co=256 " To enable 256 colors in vim, put this your .vimrc before setting the colorscheme
|
||||||
|
|
||||||
|
" einrueckung
|
||||||
|
set shiftwidth=3
|
||||||
|
set tabstop=3
|
||||||
|
" Round indent to multiple of 'shiftwidth' for > and < commands
|
||||||
|
set shiftround
|
||||||
|
|
||||||
|
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
|
||||||
|
" let &guioptions = substitute(&guioptions, "t", "", "g")
|
||||||
|
|
||||||
|
" Don't use Ex mode, use Q for formatting
|
||||||
|
map Q gq
|
||||||
|
|
||||||
|
" Make p in isual Visual mode replace the selected text with the "" register.
|
||||||
|
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
|
||||||
|
|
||||||
|
" Switch syntax highlighting on, when the terminal has colors
|
||||||
|
" Also switch on highlighting the last used search pattern.
|
||||||
|
if &t_Co > 2 || has("gui_running")
|
||||||
|
syntax on
|
||||||
|
set hlsearch
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Only do this part when compiled with support for autocommands.
|
||||||
|
if has("autocmd")
|
||||||
|
|
||||||
|
" In text files, always limit the width of text to 78 characters
|
||||||
|
autocmd BufRead *.txt set tw=78
|
||||||
|
|
||||||
|
augroup cprog
|
||||||
|
" Remove all cprog autocommands
|
||||||
|
au!
|
||||||
|
|
||||||
|
" When starting to edit a file:
|
||||||
|
" For C and C++ files set formatting of comments and set C-indenting on.
|
||||||
|
" For other files switch it off.
|
||||||
|
" Don't change the order, it's important that the line with * comes first.
|
||||||
|
autocmd FileType * set formatoptions=tcql nocindent comments&
|
||||||
|
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
augroup gzip
|
||||||
|
" Remove all gzip autocommands
|
||||||
|
au!
|
||||||
|
|
||||||
|
" Enable editing of gzipped files
|
||||||
|
" set binary mode before reading the file
|
||||||
|
autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin
|
||||||
|
autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip")
|
||||||
|
autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2")
|
||||||
|
autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip")
|
||||||
|
autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2")
|
||||||
|
autocmd FileAppendPre *.gz call GZIP_appre("gunzip")
|
||||||
|
autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2")
|
||||||
|
autocmd FileAppendPost *.gz call GZIP_write("gzip")
|
||||||
|
autocmd FileAppendPost *.bz2 call GZIP_write("bzip2")
|
||||||
|
|
||||||
|
" After reading compressed file: Uncompress text in buffer with "cmd"
|
||||||
|
fun! GZIP_read(cmd)
|
||||||
|
let ch_save = &ch
|
||||||
|
set ch=2
|
||||||
|
execute "'[,']!" . a:cmd
|
||||||
|
set nobin
|
||||||
|
let &ch = ch_save
|
||||||
|
execute ":doautocmd BufReadPost " . expand("%:r")
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" After writing compressed file: Compress written file with "cmd"
|
||||||
|
fun! GZIP_write(cmd)
|
||||||
|
if rename(expand("<afile>"), expand("<afile>:r")) == 0
|
||||||
|
execute "!" . a:cmd . " <afile>:r"
|
||||||
|
endif
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" Before appending to compressed file: Uncompress file with "cmd"
|
||||||
|
fun! GZIP_appre(cmd)
|
||||||
|
execute "!" . a:cmd . " <afile>"
|
||||||
|
call rename(expand("<afile>:r"), expand("<afile>"))
|
||||||
|
endfun
|
||||||
|
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" This is disabled, because it changes the jumplist. Can't use CTRL-O to go
|
||||||
|
" back to positions in previous files more than once.
|
||||||
|
if 0
|
||||||
|
" When editing a file, always jump to the last cursor position.
|
||||||
|
" This must be after the uncompress commands.
|
||||||
|
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif " has("autocmd")
|
||||||
|
|
||||||
|
" toggle syntax highlighting
|
||||||
|
map <F12> :if exists("syntax_on") <Bar> syntax off <Bar> else <Bar> syntax on <Bar> endif <CR><ESC>
|
||||||
|
map <F11> :nohls <CR>
|
||||||
|
|
||||||
|
" use <F6> to toggle line numbers
|
||||||
|
nmap <silent> <F6> :set number!<CR>
|
||||||
|
|
||||||
|
|
||||||
|
" If using a dark background within the editing area and syntax highlighting
|
||||||
|
" turn on this option as well
|
||||||
|
set background=dark
|
||||||
|
|
||||||
|
|
||||||
|
" set color for search
|
||||||
|
hi clear search
|
||||||
|
hi search term=bold,reverse cterm=bold,reverse gui=bold,reverse
|
||||||
|
|
||||||
|
" set color for Comment
|
||||||
|
hi clear Comment
|
||||||
|
"highlight Comment term=bold cterm=bold ctermfg=LightBlue guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=LightBlue guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=bold cterm=bold ctermfg=grey guifg=#80a0ff gui=bold
|
||||||
|
highlight Comment term=none cterm=none ctermfg=grey guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=177 guifg=#80a0ff gui=bold
|
||||||
|
"highlight Comment term=none cterm=none ctermfg=215 guifg=#80a0ff gui=bold
|
||||||
|
|
||||||
|
" Go back to the position the cursor was on the last time this file was edited
|
||||||
|
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
|
||||||
|
|
||||||
|
" visual shifting (does not exit Visual mode)
|
||||||
|
vnoremap < <gv
|
||||||
|
vnoremap > >gv
|
||||||
|
|
||||||
|
" Scroll when cursor gets within 3 characters of top/bottom edge
|
||||||
|
set scrolloff=3
|
||||||
|
|
||||||
|
" Show line, column number, and relative position within a file in the status line
|
||||||
|
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
|
||||||
|
"set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)%(\|\ syntax:\ %{synIDattr(synID(line('.'),col('.'),0),'name')}%)\ \ %=line:\ %l/%L\ \|\ column:\ %c%V\ \|\ relative\:\ %p%%\
|
||||||
|
set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)\ \ %=line:\ %l/%L\ \|\ col:\ %c%V\ \|\ %p%%
|
||||||
|
" Always show status line, even for one window
|
||||||
|
set laststatus=2
|
||||||
|
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||||
|
|
||||||
|
set belloff=all
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ if [[ -f "$conf_file" ]]; then
|
|||||||
source "$conf_file"
|
source "$conf_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -z "$GIT_BASE_DIRECTORIES" ]] && GIT_BASE_DIRECTORIES="/usr/local/src /root/bin"
|
[[ -z "$GIT_BASE_DIRECTORIES" ]] && GIT_BASE_DIRECTORIES="/usr/local/src /root/bin /root/crontab"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -131,6 +131,9 @@ fi
|
|||||||
|
|
||||||
for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
||||||
blank_line
|
blank_line
|
||||||
|
|
||||||
|
[[ ! -d "${_git_base_dir}" ]] && continue
|
||||||
|
|
||||||
for _dir in $(ls ${_git_base_dir}/) ; do
|
for _dir in $(ls ${_git_base_dir}/) ; do
|
||||||
[[ ! -d "${_git_base_dir}/$_dir" ]] && continue
|
[[ ! -d "${_git_base_dir}/$_dir" ]] && continue
|
||||||
[[ ! -d "${_git_base_dir}/${_dir}/.git" ]] && continue
|
[[ ! -d "${_git_base_dir}/${_dir}/.git" ]] && continue
|
||||||
@@ -151,17 +154,17 @@ for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
#if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
||||||
blank_line
|
# blank_line
|
||||||
echononl "Update Repository \033[1mbackup-rcopy\033[m.."
|
# echononl "Update Repository \033[1mbackup-rcopy\033[m.."
|
||||||
git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
# git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
# if [[ $? -eq 0 ]] ; then
|
||||||
echo_done
|
# echo_done
|
||||||
else
|
# else
|
||||||
echo_failed
|
# echo_failed
|
||||||
error "$(cat $log_file)"
|
# error "$(cat $log_file)"
|
||||||
fi
|
# fi
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
blank_line
|
blank_line
|
||||||
clean_up
|
clean_up
|
||||||
|
|||||||
Reference in New Issue
Block a user