79 lines
1.2 KiB
Bash
Executable File
79 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
do_with_root() {
|
|
if [[ `whoami` = 'root' ]]; then
|
|
$*
|
|
elif [[ -x /bin/sudo || -x /usr/bin/sudo ]]; then
|
|
echo "sudo $*"
|
|
sudo $*
|
|
else
|
|
echo -e "${BOrange}Please run this script as root.${Color_Off}"
|
|
exit 1
|
|
fi
|
|
}
|
|
EXIT1() {
|
|
clear
|
|
exit 0
|
|
}
|
|
is_service_running() {
|
|
local result=$(ssh root@${1} pgrep $2 | wc -l);
|
|
echo $result
|
|
}
|
|
containsElement () {
|
|
local e match="$1"
|
|
shift
|
|
for e; do [[ "$e" == "$match" ]] && return 0; done
|
|
return 1
|
|
}
|
|
|
|
if type apt &>/dev/null; then
|
|
ATYPE="apt"
|
|
if [ "$EUID" -ne 0 ]; then APTFUNC='sudo apt'
|
|
else APTFUNC='apt'
|
|
fi
|
|
elif type apt-get &>/dev/null; then
|
|
ATYPE="apt-get"
|
|
if [ "$EUID" -ne 0 ]; then APTFUNC='sudo apt-get'
|
|
else APTFUNC='apt-get'
|
|
fi
|
|
elif type yum &>/dev/null; then
|
|
ATYPE="yum"
|
|
if [ "$EUID" -ne 0 ]; then APTFUNC='sudo yum'
|
|
else APTFUNC='yum'
|
|
fi
|
|
else
|
|
ATYPE="unknown"
|
|
#exit 1
|
|
fi
|
|
|
|
|
|
|
|
|
|
declare -A abet
|
|
abet[0]="a"
|
|
abet[1]="b"
|
|
abet[2]="c"
|
|
abet[3]="d"
|
|
abet[4]="e"
|
|
abet[5]="f"
|
|
abet[6]="g"
|
|
abet[7]="h"
|
|
abet[8]="i"
|
|
abet[9]="i"
|
|
abet[10]="k"
|
|
abet[11]="l"
|
|
abet[12]="m"
|
|
abet[13]="n"
|
|
abet[14]="o"
|
|
abet[15]="p"
|
|
abet[16]="q"
|
|
abet[17]="r"
|
|
abet[18]="s"
|
|
abet[19]="v"
|
|
abet[20]="u"
|
|
abet[21]="v"
|
|
abet[22]="w"
|
|
abet[23]="x"
|
|
abet[24]="y"
|
|
abet[25]="z"
|