Compare commits
31 Commits
3b719c200e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f59158793c | |||
| a36aeeab1b | |||
| 6f8e364dbb | |||
| 16ee308311 | |||
| 71d974131e | |||
| 2d1798ccd9 | |||
| c3dd3448b8 | |||
| 3525154857 | |||
| 051e8dc948 | |||
| 8914e5ba25 | |||
| e6b0a946f4 | |||
| 62cf8ac515 | |||
| 8030091145 | |||
| 7e88f94754 | |||
| 11d2ab22b6 | |||
| 588b72f5a8 | |||
| 003fac399e | |||
| 9658cf7c09 | |||
| 0702feb22b | |||
| 67afd2d6d3 | |||
| 2b541538b6 | |||
| 526f32fab5 | |||
| 7209a56245 | |||
| ca999897be | |||
| eede408c92 | |||
| 581b5269ef | |||
| 3be0ec3310 | |||
| bd3281890d | |||
| 7d304b4a97 | |||
| a80f530438 | |||
| 472a6698e8 |
117
add_new_user.sh
117
add_new_user.sh
@@ -20,22 +20,28 @@ templates_base_dir="${working_dir}/supported-files/user_templates"
|
||||
templates_all_dir="${templates_base_dir}/all"
|
||||
|
||||
sudo_users="
|
||||
sysadm
|
||||
localadmin
|
||||
chris
|
||||
erik
|
||||
wadmin
|
||||
ilker
|
||||
ilker-sudo
|
||||
ckubu
|
||||
alex
|
||||
alis
|
||||
defa
|
||||
init
|
||||
marcus
|
||||
xmatti
|
||||
c3po
|
||||
chris
|
||||
ckubu
|
||||
defa
|
||||
dolphin
|
||||
eris
|
||||
erik
|
||||
hedwig
|
||||
ilker
|
||||
ilker-sudo
|
||||
init
|
||||
jason
|
||||
jumpy
|
||||
localadmin
|
||||
marcus
|
||||
marsupilami
|
||||
nd-admin
|
||||
sysadm
|
||||
wadmin
|
||||
xmatti
|
||||
"
|
||||
|
||||
|
||||
@@ -119,7 +125,11 @@ fi
|
||||
|
||||
if [[ -f "/etc/adduser.conf" ]]; then
|
||||
. /etc/adduser.conf
|
||||
home_base_dir="$DHOME"
|
||||
if [[ -z "$DHOME" ]] ; then
|
||||
home_base_dir=/home
|
||||
else
|
||||
home_base_dir="$DHOME"
|
||||
fi
|
||||
min_uid=$FIRST_UID
|
||||
skel_dir="$SKEL"
|
||||
else
|
||||
@@ -155,6 +165,17 @@ if ! id -u "${user_name}" > /dev/null 2>&1 ; then
|
||||
user_uid=1040
|
||||
user_gid=1040
|
||||
home_dir="/var/www"
|
||||
elif [[ "$user_name" = 'nd-web-prod' ]]; then
|
||||
user_uid=1041
|
||||
user_gid=1041
|
||||
home_dir="/var/www/nd-web-prod"
|
||||
elif [[ "$user_name" = 'nd-web-demo' ]]; then
|
||||
user_uid=1042
|
||||
user_gid=1042
|
||||
home_dir="/var/www/nd-web-demo"
|
||||
elif [[ "$user_name" = 'nd-admin' ]]; then
|
||||
user_uid=1045
|
||||
user_gid=1045
|
||||
elif [[ "$user_name" = 'sysadm' ]]; then
|
||||
user_uid=1050
|
||||
user_gid=1050
|
||||
@@ -164,6 +185,9 @@ if ! id -u "${user_name}" > /dev/null 2>&1 ; then
|
||||
elif [[ "$user_name" = 'back' ]]; then
|
||||
user_uid=1060
|
||||
user_gid=1060
|
||||
elif [[ "$user_name" = 'borg' ]]; then
|
||||
user_uid=1065
|
||||
user_gid=1065
|
||||
elif [[ "$user_name" = 'cryptpad' ]]; then
|
||||
user_uid=1033
|
||||
user_gid=1033
|
||||
@@ -221,6 +245,21 @@ if $password_needed ; then
|
||||
if [[ "$user_name" = 'webadmin' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$P1UvKv/0\\\$0hWHiUXQTrNl5SFf52iAY1qDYsJFhjHaVC6F6BuvazcNXkzjAcnuX5PMml5DLh4tyFpqVdPpCyAyd92YypNbu/:\2#" /etc/shadow
|
||||
|
||||
# - nd-admin
|
||||
# -
|
||||
elif [[ "$user_name" = 'nd-admin' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$1YJwHY0qdLimgtdOKlTxR1\\\$/O9QWTpr0Y41TduR2GZ0FMCiIxFqOaXWSM9hmHRnv80:\2#" /etc/shadow
|
||||
|
||||
# - nd-web-prod
|
||||
# -
|
||||
elif [[ "$user_name" = 'nd-web-prod' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$boxWdtKmOp7AKHEAFj1.1/\\\$jlhYI62N5u6P.jRxAgmmDGVvGnfrPKTcKelYC3Z2sM4:\2#" /etc/shadow
|
||||
|
||||
# - nd-web-demo
|
||||
# -
|
||||
elif [[ "$user_name" = 'nd-web-demo' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$uqzyF.BYEZrgJlDnGTH/x/\\\$abn3RCkx5SAz.f9B5Iqvaw/LWRncoyS40Lx2uGj2xQ.:\2#" /etc/shadow
|
||||
|
||||
# - sysadm
|
||||
# -
|
||||
elif [[ "$user_name" = 'sysadm' ]]; then
|
||||
@@ -231,10 +270,15 @@ if $password_needed ; then
|
||||
elif [[ "$user_name" = 'back' ]]; then
|
||||
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
|
||||
# -
|
||||
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
|
||||
# -
|
||||
@@ -282,26 +326,51 @@ if $password_needed ; then
|
||||
elif [[ "$user_name" = 'erik' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$GntX81EP\\\$O1GEmQF.BbOQfTMMw/m/BDKSXmANVpqmz0nyzw4O4R2/iK9huGOAjT/2eq8FVdMghvNOvdwrWtwohO.Mg4V9n.:\2#" /etc/shadow
|
||||
|
||||
# - eris
|
||||
# -
|
||||
elif [[ "$user_name" = 'eris' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$2k/ZZEdYqay2oIoW00eSn0\\\$u0E/KBTI07end/gRq31sJdf3A8hbqh42e7apGVMn9d1:\2#" /etc/shadow
|
||||
|
||||
# - c3po
|
||||
# -
|
||||
elif [[ "$user_name" = 'c3po' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$z0yywBoF\\\$VtusXNrSvL4s4kQSeCl/6rZoCcAOz0aSINm0ArntILNvLnurVDGk9nJz42ZMya/DFe8snlf5kLymeAmNRiyDK/:\2#" /etc/shadow
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$RE5/J41tiT9VGR1EEUG1v0\\\$b6vffdjY5qTHZAKAMh093ohujBUhV6rnVmzS/ctRl7D:\2#" /etc/shadow
|
||||
|
||||
# - hedwig
|
||||
# -
|
||||
elif [[ "$user_name" = 'hedwig' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$JtS8/Okj5I8yg8.kFTFA6.\\\$9RS.N9A8oVOhwyT0eILDRoKzqDjOCAYft9j0ofwqcqD:\2#" /etc/shadow
|
||||
|
||||
# - jumpy
|
||||
# -
|
||||
elif [[ "$user_name" = 'jumpy' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$fOtCqi5egKR9qvH0adBVs0\\\$8uiduG3.8nDk2lHmlRDK2.tCKg4yEU91S.xZgSONCL3:\2#" /etc/shadow
|
||||
# - dolphin
|
||||
# -
|
||||
elif [[ "$user_name" = 'dolphin' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$4LaHObIvOTyXyoEEEljzP/\\\$Vjp2akP.EPg/LZmKPurvYbCOCOf7fP//oRU6EkcMvK6:\2#" /etc/shadow
|
||||
|
||||
# - xmatti
|
||||
# - $y$j9T$z1Zz8bCDJro64/upmwFk..$nG9EDG1sk0Prf2cyj1ylnILFTbSrQJwfosHYSmssWd7
|
||||
# -
|
||||
elif [[ "$user_name" = 'xmatti' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$z1Zz8bCDJro64/upmwFk..\\\$nG9EDG1sk0Prf2cyj1ylnILFTbSrQJwfosHYSmssWd7:\2#" /etc/shadow
|
||||
|
||||
# - jason
|
||||
# -
|
||||
# - $y$j9T$OXib1uJhr.zU/H9/XnLGd0$Bd4t8mBcQXQZ6K6U/IiarTCD1sbKhFnMWm/5JDnzTV/
|
||||
# - 2Gw/FY6N-K.Ate-R
|
||||
elif [[ "$user_name" = 'c3po' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$.L0YWnREcDrMep6Irp44e/\\\$NW1LV7tMssSJ.ot5if9wM5vm2XoulnlM9mETZldUuy.:\2#" /etc/shadow
|
||||
elif [[ "$user_name" = 'jason' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$OXib1uJhr.zU/H9/XnLGd0\\\$Bd4t8mBcQXQZ6K6U/IiarTCD1sbKhFnMWm/5JDnzTV/:\2#" /etc/shadow
|
||||
|
||||
# - chris
|
||||
# -
|
||||
elif [[ "$user_name" = 'chris' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$4tHDBpAXsLybUcR3EkGsN1\\\$FztD35vOLJ2wkdcMMyWVjx7H6vCYAXK2Sik9RVx6iF6:\2#" /etc/shadow
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$JPKlR6kIk7GJStSdmAQWq/\\\$e1vJER6KL/dk1diFNtC.COw9lu2uT6ZdrUgGcNVb912:\2#" /etc/shadow
|
||||
|
||||
# - ckubu
|
||||
# -
|
||||
elif [[ "$user_name" = 'ckubu' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$nmAWOQHZ\\\$PRx3FAGI4.X4ah7nmuTFJi0iFMwlWwTz.iM9B4yjLGcnQ/hg3K0O0lSDXOOn7yRJlhwRejVq2XSNvrmSGwJw//:\2#" /etc/shadow
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$rgPmWh7b8x1ROMjvKYjoi0\\\$KCAw3Bb6B7GH9Zm6yf7RS7DzKHniUfabYum1JGRwAWA:\2#" /etc/shadow
|
||||
|
||||
# - alex
|
||||
# -
|
||||
@@ -333,7 +402,7 @@ if $password_needed ; then
|
||||
# - wadmin
|
||||
# -
|
||||
elif [[ "$user_name" = 'wadmin' ]]; then
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$vaVNOPYp\\\$RbV6/phKDZRSa4TQGlJVOF/HQqyxAK7BeQmir8Kr8pwy7ATlHGvcPzJkuldNNp4O4t2q3EJRW2uVpjsng4ZhH1:\2#" /etc/shadow
|
||||
perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$y\\\$j9T\\\$YarN7tuuR4Q4iGCUundvp.\\\$Cj7hN5UAaigmXCZrNQbeIIq40MmYX66.Jiu0QmDYY6.:\2#" /etc/shadow
|
||||
|
||||
|
||||
# - marcus Opferperspektive
|
||||
@@ -341,6 +410,12 @@ if $password_needed ; then
|
||||
elif [[ "$user_name" = 'marcus' ]]; then
|
||||
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
|
||||
# -
|
||||
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
|
||||
415
check-disc-usage.sh
Executable file
415
check-disc-usage.sh
Executable file
@@ -0,0 +1,415 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ----------
|
||||
# - Some script variables (Default values other variables see below)
|
||||
# ----------
|
||||
|
||||
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) [-c <integer>}
|
||||
|
||||
\033[1mDescription\033[m
|
||||
|
||||
Script wwarns if disk usage exceeds a given or default value (percent)
|
||||
|
||||
\033[1mOptions\033[m
|
||||
|
||||
-c <integer)
|
||||
a critical value in percent. if disc usage reaches this value, a warn e-mail
|
||||
to given e-mail adresse(s) will be send.
|
||||
|
||||
Default e-mail adresse(s):
|
||||
${DEFAULT_ALERT_EMAIL_ADDRESSES}
|
||||
|
||||
-h
|
||||
Prints this help.
|
||||
|
||||
\033[1mFiles\033[m
|
||||
|
||||
$conf_file: Configuration file
|
||||
|
||||
\033[1mExample:\033[m
|
||||
|
||||
warn if disc usage exceeds 80%
|
||||
|
||||
$(basename $0) -c 80
|
||||
|
||||
"
|
||||
|
||||
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 " [ \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
|
||||
}
|
||||
|
||||
is_number() {
|
||||
|
||||
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||
|
||||
# - also possible
|
||||
# -
|
||||
i#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||
#retuon $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||
}
|
||||
|
||||
|
||||
# ----------
|
||||
# - Some checks ..
|
||||
# ----------
|
||||
|
||||
# - Running in a terminal?
|
||||
# -
|
||||
if [[ -t 1 ]] ; then
|
||||
terminal=true
|
||||
else
|
||||
terminal=false
|
||||
fi
|
||||
|
||||
|
||||
# ==========
|
||||
# - Begin Main Script
|
||||
# ==========
|
||||
|
||||
# ----------
|
||||
# - Headline
|
||||
# ----------
|
||||
|
||||
if $terminal ; then
|
||||
clear
|
||||
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"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# ----------
|
||||
# Read Configurations from $conf_file
|
||||
# ----------
|
||||
|
||||
# - Give your default values here
|
||||
# -
|
||||
DEFAULT_ADMIN_EMAIL="argus@oopen.de"
|
||||
|
||||
DEFAULT_COMPANY="O.OPEN"
|
||||
|
||||
DEFAULT_CONTENT_TYPE='Content-Type: text/plain;\n charset="utf-8"'
|
||||
DEFAULT_SENDER_ADDRESS="${script_name%%.*}@$(hostname -f)"
|
||||
DEFAULT_ALERT_EMAIL_ADDRESSES="ckubu@oopen.de"
|
||||
DEFAULT_WARN_VALUE=85%
|
||||
|
||||
# - Print help?
|
||||
# -
|
||||
if [[ "$(trim $*)" = "--help" ]] || [[ "$(trim $*)" = "-help" ]] || [[ "$(trim $*)" = "help" ]] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
source "$conf_file"
|
||||
else
|
||||
warn_only_terminal "No configuration file '$conf_file' present.\n
|
||||
Loading default values.."
|
||||
fi
|
||||
|
||||
[[ -n "${WARN_VALUE}" ]] || WARN_VALUE="${DEFAULT_WARN_VALUE}"
|
||||
|
||||
[[ -n "${ADMIN_EMAIL}" ]] || ADMIN_EMAIL="${DEFAULT_ADMIN_EMAIL}"
|
||||
[[ -n "${COMPANY}" ]] || COMPANY="${DEFAULT_COMPANY}"
|
||||
|
||||
[[ -n "${ALERT_EMAIL_ADDRESSES}" ]] || ALERT_EMAIL_ADDRESSES="${DEFAULT_ALERT_EMAIL_ADDRESSES}"
|
||||
[[ -n "${CONTENT_TYPE}" ]] || CONTENT_TYPE="${DEFAULT_CONTENT_TYPE}"
|
||||
[[ -n "${SENDER_ADDRESS}" ]] || SENDER_ADDRESS="${DEFAULT_SENDER_ADDRESS}"
|
||||
|
||||
|
||||
WARN_VALUE="${WARN_VALUE%\%}"
|
||||
|
||||
if ! $(is_number ${WARN_VALUE}) ; then
|
||||
fatal "Given value for \033[1mWARN_VALUE\033[m (\033[1m${WARN_VALUE}\033[m) isn't a number!"
|
||||
fi
|
||||
|
||||
SUBJECT="[ Warning ] Hard disk storage on $(hostname -f) exceeds ${WARN_VALUE}%"
|
||||
|
||||
# ----------
|
||||
# - Read commandline parameter
|
||||
# ----------
|
||||
|
||||
while getopts c:h opt ; do
|
||||
case $opt in
|
||||
c) WARN_VALUE="${OPTARG}"
|
||||
WARN_VALUE="${WARN_VALUE%\%}"
|
||||
;;
|
||||
h) usage
|
||||
;;
|
||||
\?) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# - Commandline parameter overwrites those given at configuration file
|
||||
# -
|
||||
if ! $(is_number ${WARN_VALUE}) ; then
|
||||
fatal "Given value for \033[1mWARN_VALUE\033[m at commandline option \033[1m-c\033[m (\033[1m${WARN_VALUE}\033[m) isn't a number!"
|
||||
fi
|
||||
|
||||
|
||||
if [[ -n "$(trim ${ALERT_EMAIL_ADDRESSES})" ]] ; then
|
||||
for _email in $ALERT_EMAIL_ADDRESSES ; do
|
||||
alert_email_arr+=("$_email")
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# - Jobhandling
|
||||
# ----------
|
||||
|
||||
# - If job already runs, stop execution..
|
||||
# -
|
||||
if mkdir "$LOCK_DIR" 2> /dev/null ; then
|
||||
|
||||
## - Remove lockdir when the script finishes, or when it receives a signal
|
||||
trap "clean_up 1" SIGHUP SIGINT SIGTERM
|
||||
|
||||
else
|
||||
|
||||
datum="$(date +"%d.%m.%Y %H:%M")"
|
||||
|
||||
msg="[ Error ]: A previos instance of \"`basename $0`\" seems already be running.\n\n Exiting now.."
|
||||
|
||||
echo ""
|
||||
echo "[ Error ]: A previos instance of that script \"`basename $0`\" seems already be running."
|
||||
echo ""
|
||||
echo -e " Exiting now.."
|
||||
echo ""
|
||||
|
||||
echo -e "To:${ADMIN_EMAIL}\n${CONTENT_TYPE}\nSubject:Error cronjob `basename $0` -- $datum\n${msg}\n" \
|
||||
| sendmail -F "Error `hostname -f`" -f ${SENDER_ADDRESS} ${ADMIN_EMAIL}
|
||||
|
||||
exit 1
|
||||
|
||||
fi
|
||||
blank_line
|
||||
|
||||
msg=""
|
||||
found=false
|
||||
while IFS='' read -r _line || [[ -n $_line ]] ; do
|
||||
|
||||
read -ra _addr <<< "$_line"
|
||||
|
||||
_device="${_addr[1]}"
|
||||
_dir="${_addr[2]}"
|
||||
|
||||
_tmp_percent="${_addr[0]}"
|
||||
declare -i _percent="${_tmp_percent%\%}"
|
||||
|
||||
|
||||
if [[ ${_percent} -gt ${WARN_VALUE} ]] ; then
|
||||
|
||||
#echo -e "\033[3G${_device}\033[15G -> ${_dir}\033[25G ${_percent}%"
|
||||
if [[ -z "${msg}" ]]; then
|
||||
msg="\n The hard disk space on Device '${_device}' mounted at '${_dir}' is '${_percent}'% full!\n"
|
||||
else
|
||||
msg+="\n The hard disk space on Device '${_device}' mounted at '${_dir}' is '${_percent}'% full!\n"
|
||||
fi
|
||||
|
||||
if ! ${found} && ${terminal} ; then
|
||||
echo -e " Host: \033[1m$(hostname -f)\033[m"
|
||||
fi
|
||||
warn_only_terminal "The hard disk space on Device \033[1m${_device}\033[m mounted at \033[1m${_dir}\033[m is \033[1;31m${_percent}% full!\033[m"
|
||||
|
||||
found=true
|
||||
|
||||
fi
|
||||
|
||||
done < <(df -H | grep -vE '^Dateisystem|Filesystem|tmpfs|cdrom|loop|udev' | awk '{ print $5 " " $1 " " $6 }')
|
||||
|
||||
if $found ; then
|
||||
|
||||
if $(which lxc-ls > /dev/null) ; then
|
||||
|
||||
_guest_machines="$(lxc-ls)"
|
||||
|
||||
|
||||
if [[ ${#_guest_machines} -gt 0 ]]; then
|
||||
|
||||
if ${terminal}; then
|
||||
echo -e " LX Guest Systems:"
|
||||
fi
|
||||
|
||||
msg_guests="LX Guest Systems:"
|
||||
|
||||
for _name in ${_guest_machines} ; do
|
||||
|
||||
_state="$(lxc-info -n ${_name} | grep -i 'State:' | awk '{print$2}')"
|
||||
|
||||
msg_guests="${msg_guests}\n (${_state}:) ${_name}"
|
||||
|
||||
if ${terminal}; then
|
||||
echo -e " (${_state}:) ${_name}"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
fi # if [[ ${#_guest_machines} -gt 0 ]]
|
||||
|
||||
fi # if $(which lxc-ls > /dev/null)
|
||||
|
||||
SUBJECT="[ Warning ] Hard disk usage (${_percent}%) on $(hostname -f) exceeds ${WARN_VALUE}%"
|
||||
SUBJECT_UTF8="$(echo "${SUBJECT}" | iconv -t UTF8)"
|
||||
SUBJECT_UTF8_ENCODED="=?utf-8?B?$(echo ${SUBJECT_UTF8} | base64 --wrap=0)?="
|
||||
|
||||
for _email in ${alert_email_arr[@]} ; do
|
||||
echo -e "To:${_email}\n${CONTENT_TYPE}\nSubject:${SUBJECT_UTF8_ENCODED}\n\nHost: $(hostname -f)\n${msg}\n${msg_guests}" | /usr/sbin/sendmail -F "${COMPANY} -- hard disk usage" -f ${SENDER_ADDRESS} ${_email}
|
||||
done
|
||||
|
||||
else
|
||||
info "Harddisk usage on host \033[1m$(hostname -f)\033[m is fine."
|
||||
fi
|
||||
|
||||
clean_up 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'
|
||||
|
||||
49
conf/check-disc-usage.conf.sample
Normal file
49
conf/check-disc-usage.conf.sample
Normal file
@@ -0,0 +1,49 @@
|
||||
# -----------------------------------------
|
||||
# - Settings for script check-disk-usage.sh
|
||||
# -----------------------------------------
|
||||
|
||||
# - WARN_VALUE
|
||||
# -
|
||||
# - warn if if the hard disk usage has reached this value.
|
||||
# -
|
||||
# - Defaults to: WARN_VALUE=80
|
||||
# -
|
||||
#WARN_VALUE=80
|
||||
|
||||
# - COMPANY
|
||||
# -
|
||||
# - Defaults to: COMPANY="O.OPEN"
|
||||
# -
|
||||
#COMPANY="O.OPEN"
|
||||
|
||||
|
||||
# ---
|
||||
# Alert E-Mail stuff
|
||||
# ---
|
||||
|
||||
# - ADMIN_EMAIL
|
||||
# -
|
||||
# - Defaults to: ADMIN_EMAIL="argus@oopen.de"
|
||||
# -
|
||||
#ADMIN_EMAIL="argus@oopen.de"
|
||||
|
||||
# - ALERT_EMAIL_ADDRESSES
|
||||
# -
|
||||
# - Blank separated liost of e-mail adresses you want to inform
|
||||
# - about to high disk usage
|
||||
# -
|
||||
# - Defaults to an empty string: ALERT_EMAIL_ADDRESSES="ckubu@oopen.de"
|
||||
# -
|
||||
#ALERT_EMAIL_ADDRESSES="ckubu@oopen.de"
|
||||
|
||||
# - CONTENT_TYPE
|
||||
# -
|
||||
# - Defaults to: CONTENT_TYPE='Content-Type: text/plain;\n charset="utf-8"'
|
||||
# -
|
||||
#CONTENT_TYPE='Content-Type: text/plain;\n charset="utf-8"'
|
||||
|
||||
# - SENDER_ADDRESS
|
||||
# -
|
||||
# - Defaults to: SENDER_ADDRESS="${script_name%%.*}@$(hostname -f)"
|
||||
# -
|
||||
#SENDER_ADDRESS="${script_name%%.*}@$(hostname -f)"
|
||||
23
create-rsyslogd-postfix.sh
Executable file
23
create-rsyslogd-postfix.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -f "/etc/rsyslog.d/postfix.conf" ]] ; then
|
||||
cat << EOF > /etc/rsyslog.d/postfix.conf
|
||||
# Create an additional socket in postfix's chroot in order not to break
|
||||
# mail logging when rsyslog is restarted. If the directory is missing,
|
||||
# rsyslog will silently skip creating the socket.
|
||||
\$AddUnixListenSocket /var/spool/postfix/dev/log
|
||||
|
||||
#
|
||||
# Logging for the mail system. Split it up so that
|
||||
# it is easy to write scripts to parse these files.
|
||||
#
|
||||
#mail.info -/var/log/mail.info
|
||||
#mail.warn -/var/log/mail.warn
|
||||
#mail.err /var/log/mail.err
|
||||
|
||||
mail.* -/var/log/mail.log
|
||||
& stop
|
||||
EOF
|
||||
fi
|
||||
|
||||
exit 0
|
||||
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
|
||||
|
||||
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() {
|
||||
if [ -n "$1" ];then
|
||||
echo -e "\n [ Error ]: $1"
|
||||
@@ -15,7 +184,7 @@ cat<<EOF
|
||||
|
||||
EOF
|
||||
|
||||
exit 1
|
||||
clean_up 1
|
||||
}
|
||||
|
||||
isValidDate() {
|
||||
@@ -48,6 +217,31 @@ isValidDate() {
|
||||
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"
|
||||
|
||||
_date=$1
|
||||
@@ -62,6 +256,114 @@ if ! isValidDate "${__day}-${__month}-${__year}" ; then
|
||||
usage "Invalid date: ${_date}"
|
||||
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
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDinfnbnVooKT0iFpkZeRZMj8JpYJk+EkgGHyK2xhb0HNoYvDoG06Clckm0vauuRlSYnWkZC0dLIbqHlACA
|
||||
+jbCKa2w/5yOjCXmJiJEO04YCMhkQH08It+wpWZb/Bx2O6DB3cY+3mHwPocp/la8caYW4NIE5+67AnHxIQifJLXM44TgkmFEhXSBMIZj8b8wL+MA0zKD0LXw
|
||||
gEH9Wllcccq6D5lfsrUSLvTRHq362pE+ZtVXh2peVkS4r98HNtYVUjBMgOIIPEypopceUzXC0L+vB7s2SolAsh3CGjqyjYW8x3fWnAewlfa5TbgIC+11e+KJ
|
||||
KFr5+tVfwSgHC+TtfuXDU5Ws80ETejbuwx2iRVfHG0fDcjPzaVUXGmY+j8OR4jACz5KY5+VMJgMuXJTbZBEf1C5O3lCTaEf/Pmw50SHrshT/bhdrMBUaS+AO
|
||||
TFHrI3WOu+ujWMXJK3pRdROXDFDtPfc1afaJkMuKO5Uay/qwTEKd8NwXNoAGkXjowKBerNgJRy5JwhmbHMA6xsCDEjXMVy+yiMw+58JE76g5HVVu7dpyz0bj
|
||||
XD3LrpB+lclQHRLxNajWAjVsAu/eI2zQDDS7YHi1IZVUGdYD0g0qXdeNQ//KA7FVr22VFUP8xtbseZfOZpKFGVEMVkIOcYHZoYhOYxZDVNNmvle13F4PU1zO
|
||||
iQ== c3po@riseup.net
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDinfnbnVooKT0iFpkZeRZMj8JpYJk+EkgGHyK2xhb0HNoYvDoG06Clckm0vauuRlSYnWkZC0dLIbqHlACA+jbCKa2w/5yOjCXmJiJEO04YCMhkQH08It+wpWZb/Bx2O6DB3cY+3mHwPocp/la8caYW4NIE5+67AnHxIQifJLXM44TgkmFEhXSBMIZj8b8wL+MA0zKD0LXwgEH9Wllcccq6D5lfsrUSLvTRHq362pE+ZtVXh2peVkS4r98HNtYVUjBMgOIIPEypopceUzXC0L+vB7s2SolAsh3CGjqyjYW8x3fWnAewlfa5TbgIC+11e+KJKFr5+tVfwSgHC+TtfuXDU5Ws80ETejbuwx2iRVfHG0fDcjPzaVUXGmY+j8OR4jACz5KY5+VMJgMuXJTbZBEf1C5O3lCTaEf/Pmw50SHrshT/bhdrMBUaS+AOTFHrI3WOu+ujWMXJK3pRdROXDFDtPfc1afaJkMuKO5Uay/qwTEKd8NwXNoAGkXjowKBerNgJRy5JwhmbHMA6xsCDEjXMVy+yiMw+58JE76g5HVVu7dpyz0bjXD3LrpB+lclQHRLxNajWAjVsAu/eI2zQDDS7YHi1IZVUGdYD0g0qXdeNQ//KA7FVr22VFUP8xtbseZfOZpKFGVEMVkIOcYHZoYhOYxZDVNNmvle13F4PU1zOiQ== c3po@riseup.net
|
||||
|
||||
@@ -122,3 +122,8 @@ 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'
|
||||
|
||||
|
||||
@@ -171,3 +171,5 @@ set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\
|
||||
set laststatus=2
|
||||
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||
|
||||
set belloff=all
|
||||
|
||||
|
||||
@@ -122,3 +122,7 @@ 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'
|
||||
|
||||
@@ -171,3 +171,4 @@ set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\
|
||||
set laststatus=2
|
||||
highlight StatusLine cterm=none ctermfg=white ctermbg=blue
|
||||
|
||||
set belloff=all
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDqi25sXeJHJ/TtRTJwrApyJGmIKynlOvTo8idRHvzWkvfNoLaK4NCjikARfAQtCUyLlfRsz8QvYgx1Oj6eqsaHcJTMs3Gn0Ewnj1mb1U1jmTn8PAz6beULBevcS84z40gH9GoGy+a23tmboSTA2yxmze5oEuFtkqY7kQMQ62kmmSKAG4yWbXK7EWjhbd6PlWv4DnHivOOqI/9X1m8StAYqixgzetSk4kpvFrJaQV96mfL+2FBATD6ykBEsb/Pnd/VW6DBjqGW+SkmAZo6TPsTlGt4sqt8ukcX38g+0Hng4s7ykfLW3np9BsxJkiOZIjRj9odPPB6K9yhtg3qoX+o2qhrE+lf4+QaUJpzWnO4gux7SijHS2/hIIrUfUEQSc8bLBzHp/JsgyYWfPkZ8r/miSfLTAz3U8mTb51qkg06msQ/srPNYIOJqmVOKhXe/sL/pAeBxCQVT2V1pU1sWti91yyXYP3Uhjkx32jidk3PjWm/jIL+MzBdEzdc4yD4+rB82z4LOyooXRe0wcAOLLRgvoBH0RIvz9/Ixa6OPFGDS8NUuqMy0GMJ8WZ6inc6YsUm5IpH7HWgse66cY6pkhzOyug9uKYaXaBNyPbaDmiXYJi+yRs3YBSrt8rU6M7/IjD/5GVfpQ1ZXXLevqpupH+JtayBrvRVzJkQ/kOpeGQUXhww== dolphin
|
||||
2
supported-files/user_templates/eris/.ssh/authorized_keys
Normal file
2
supported-files/user_templates/eris/.ssh/authorized_keys
Normal file
@@ -0,0 +1,2 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDrkNmAz0sS8nmVCsw12nZqr8z86sifGSVfR1skzdXoE+gHwiaB0vIuCEvcANqnAILe3de/CLnBz72xLAfGCMzlHZNXusaUUuGPC/VbF0FwIwYj2i6JA0fVYAx9cS2iQJGdc6Iwfr31P/5mrrZTN+L1zlFTPC82H/c22GC8CMvCm72wZLuinwTreKZ32bzk3zXijM1b2dFZfUyPKgzvRRiys7DQwnHfQYhf2qq9k6+GtBdKJCnru58v+B0lHNszJiRaHts5BsO1yPYgJ5cIFadmnhwnQ6XuXydjV8ooK6hdtURfI5BAzC/adQQK2i8eHX4X4u2sEz2MlmkxDUNdgzQVc2yyeNBkXRqYRKU8H8/ioyWj10FfhF/YPsWYWLyx40uO+73kgiSyHo1ZctMrFDfbDBVUuAf1OKixqSfCz+mETziONqUvkBngbMNAVkIwvvKmQtklhR4ogrQ665kZ2r9BaJK7eEJXWGB0m7aTgdLgeKF1HKzyjdWxtBjFicNAE0Af8Nu0kI7FNjx96srkxpWC8ZxSDmh1aGBlw4CcOLB+XHqr89wmI7RpkTrZfsLpuvD2u2G/3ONLN8jaw6sGuTP9lG0oScY+oZrDJsFvC6u1mTy7n4+QwkOR6ZnvlJ7CYVUlHMMccHfZI9pqXM9TZSDbgU3YHGPzpCJNkNucobM2pw== chemo@mailbox.org
|
||||
@@ -0,0 +1,2 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAgEAhXpLxU+TcMf/0ETcjQg/RqhqhEm0BivB/O1oN+7IVcmPjpBYBBySFgt48v+SGxhQ8Yh0vEmwx0QRHf/JtbA7dKI94rn1heQeXewMvLOAjOsElTNEMlO1f5VPMUUeDib7QPzHOym4COKMpjP2Gefwh2q9RKu61sJ/pRGMolzqgu5OJbMDWOtBwSiTZJrvHsp/mIlkEmXER5jLcJEWUab9tGtoddCKzg2z3gI0Zewy90+IJa72xVTbgAtDfV/htc+g4MhoiGadWWOIanrJtsZj1cAcYuPCfEKgGbK9ZK3+V/utliLxW5S8lLRO3UJcJ9XTxO0GV76rpiE68Tnu2L6fiju9ek3AOg3Sf3f5QnR1jIVyGEqFMk/RnDceHAgOGLpDHLy1W6r7ljmLk2HNvDhuo4lqbgrr6MAgBchHxne8G/jp33Dmzfac2qboWGaAth1jHsAcKe4Eo5TzjXUu0yL1me6K8LH+cRn0G3+CO+TR04ZIriDFUMcTFFiOjK0bRoPBX//a0UEDIjnoW2keqdImlQ7yTOc9t1XLLkGIfTcu3ik9hSTZwc5j+7njx47qQJcNdEjhM6gOBHNr2GJe4m8An1bsL+SWVVTjYKxW0BT/Scd1j8EJwHgPWcEVVYbqSd7T6kWC933HMDz3QySAMTX17iP1/FHDsN0UdZMPf5RAzlM= rsa-key-20211122
|
||||
@@ -0,0 +1,2 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCV9TRyzQGa3xjoqmRVEAlotUr1RK7mm1eMilJxj/XkCPmluINvkdhlMhhrCuuJVgC0jzp+BNU/KPMYQnujDE7VAVSIXA/oTDo9Q+Q+RpLytPBGntwTcVc0wE95hXx9Zy5XMPjxxThuVGZ4MrBcI+iwaEoMCvWEd7SSyjit+EBJtW5YhV3uu9TNyHptwEcQ1ZsYV0n3j9XDdo8pqh5woUC8FXF5vyumsv4rijJgCUoamDbUFBFBa12Xpj0/uIha/TogLExz96sjP76MX8UEUM+prya4KCIVYReA5s0qNYfaP+WymZxYO111NC981YW4wIhGYX74W/BWP9kAXTsXT4OLAljOxr8us0rcWUTR0+EOOhNt9QMRBOXgDmsH37HJHjiP/Ns1+HBuk2JVMhRQr3kPlHGvpu2DHYjG2oPrzxf34LKHvV+2I1YuvGM0EE/ts9PmJUS8a4eY9PrfKlAIXnPH+cmLWHz8KgA0UfUmgfBNL1bHGw4Nbh+jBr6rcFpZ3kU=
|
||||
@@ -0,0 +1,2 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL4wVpkMrF4M5wKBxRAonR4gVngO9+yhBEAyhV03l6Is
|
||||
@@ -0,0 +1,3 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQHMUKlDh2ufno5pZOhUY5xFljC1R5zQ/GjOHDkS58D root@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKTjd4XFBdF/V9VdSZjy9G7nupBwaMqsrtQSP4Uctkrz org@rdsgn.de
|
||||
@@ -0,0 +1,4 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQHMUKlDh2ufno5pZOhUY5xFljC1R5zQ/GjOHDkS58D root@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKTjd4XFBdF/V9VdSZjy9G7nupBwaMqsrtQSP4Uctkrz org@rdsgn.de
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMClTmBQGPp1FFKA3n+ANJ9XuEYfR/ALXcoBVclV3eVP datenlieferung@nd-online.de
|
||||
@@ -0,0 +1,4 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQHMUKlDh2ufno5pZOhUY5xFljC1R5zQ/GjOHDkS58D root@sol
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKTjd4XFBdF/V9VdSZjy9G7nupBwaMqsrtQSP4Uctkrz org@rdsgn.de
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJA+YbWWoJpn6w5wsyzy3/g91nyesWoHGw9+eFdB3V9p datenlieferung@nd-online.de
|
||||
@@ -69,3 +69,8 @@ export LINES=64
|
||||
## - 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'
|
||||
|
||||
|
||||
@@ -23,4 +23,6 @@ if [ -f "/usr/share/mc/bin/mc.sh" ]; then
|
||||
source /usr/share/mc/bin/mc.sh
|
||||
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"
|
||||
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
|
||||
blank_line
|
||||
|
||||
[[ ! -d "${_git_base_dir}" ]] && continue
|
||||
|
||||
for _dir in $(ls ${_git_base_dir}/) ; do
|
||||
[[ ! -d "${_git_base_dir}/$_dir" ]] && continue
|
||||
[[ ! -d "${_git_base_dir}/${_dir}/.git" ]] && continue
|
||||
@@ -151,17 +154,17 @@ for _git_base_dir in $GIT_BASE_DIRECTORIES ; do
|
||||
done
|
||||
done
|
||||
|
||||
if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
||||
blank_line
|
||||
echononl "Update Repository \033[1mbackup-rcopy\033[m.."
|
||||
git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
echo_done
|
||||
else
|
||||
echo_failed
|
||||
error "$(cat $log_file)"
|
||||
fi
|
||||
fi
|
||||
#if [[ -d "/root/crontab/backup-rcopy" ]]; then
|
||||
# blank_line
|
||||
# echononl "Update Repository \033[1mbackup-rcopy\033[m.."
|
||||
# git -C "/root/crontab/backup-rcopy" pull > $log_file 2>&1
|
||||
# if [[ $? -eq 0 ]] ; then
|
||||
# echo_done
|
||||
# else
|
||||
# echo_failed
|
||||
# error "$(cat $log_file)"
|
||||
# fi
|
||||
#fi
|
||||
|
||||
blank_line
|
||||
clean_up
|
||||
|
||||
Reference in New Issue
Block a user