Compare commits
14 Commits
11d2ab22b6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f59158793c | |||
| a36aeeab1b | |||
| 6f8e364dbb | |||
| 16ee308311 | |||
| 71d974131e | |||
| 2d1798ccd9 | |||
| c3dd3448b8 | |||
| 3525154857 | |||
| 051e8dc948 | |||
| 8914e5ba25 | |||
| e6b0a946f4 | |||
| 62cf8ac515 | |||
| 8030091145 | |||
| 7e88f94754 |
@@ -37,6 +37,7 @@ sudo_users="
|
||||
jumpy
|
||||
localadmin
|
||||
marcus
|
||||
marsupilami
|
||||
nd-admin
|
||||
sysadm
|
||||
wadmin
|
||||
@@ -184,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
|
||||
@@ -266,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
|
||||
# -
|
||||
@@ -401,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
|
||||
|
||||
@@ -13,6 +13,50 @@ 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
|
||||
@@ -209,6 +253,7 @@ if [[ -t 1 ]] ; then
|
||||
terminal=true
|
||||
else
|
||||
terminal=false
|
||||
BATCH_MODE=true
|
||||
fi
|
||||
|
||||
|
||||
@@ -269,6 +314,14 @@ 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
|
||||
|
||||
@@ -280,7 +333,7 @@ if ${BATCH_MODE} && ( [[ -z "${IPv4_ADDRESS_OLD}" ]] || [[ -z "${IPv4_ADDRESS_NE
|
||||
fatal "Something wired went wrong.."
|
||||
fi
|
||||
|
||||
if ! ${BATCH_MODE} ; then
|
||||
if ! ${BATCH_MODE} && ${terminal}; then
|
||||
echo ""
|
||||
echo -e "\033[32m--\033[m"
|
||||
echo ""
|
||||
@@ -484,49 +537,53 @@ if ! ${BATCH_MODE} ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#clear
|
||||
echo ""
|
||||
echo ""
|
||||
echo -e "\033[14G\033[32mReplace IP-Address(es) for munin server\033[m"
|
||||
echo ""
|
||||
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"
|
||||
|
||||
|
||||
echo ""
|
||||
OK=
|
||||
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
|
||||
echononl "Parameters ok? [yes/no]: "
|
||||
read OK
|
||||
## - To lower case
|
||||
OK=${OK,,}
|
||||
if [ "X$OK" = "X" ]; then
|
||||
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||
OK=""
|
||||
continue
|
||||
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
|
||||
if [ "$OK" != "yes" -o "$OK" != "no" ] ; then
|
||||
break
|
||||
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 -e "\n\t\033[33m\033[1mWrong entry!\033[m\n"
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal Repeat execution with different parameters
|
||||
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
|
||||
|
||||
@@ -400,7 +400,7 @@ if $found ; then
|
||||
|
||||
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_ENCODED="=?utf-8?B?$(echo ${SUBJECT_UTF8} | base64 --wrap=0)?="
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
cat <<EOF > /root/change_munin_ip.conf
|
||||
cat <<EOF > /root/bin/admin-stuff/conf/change_munin_ip.conf
|
||||
# -------------------------------------------
|
||||
# - Settings for script check-connectivity.sh
|
||||
# -------------------------------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL4wVpkMrF4M5wKBxRAonR4gVngO9+yhBEAyhV03l6Is
|
||||
@@ -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