update
This commit is contained in:
@@ -9,3 +9,12 @@ IFS=,
|
||||
NODE_HOSTS=(${NODE_HOSTS})
|
||||
NODE_SERVICES=(${NODE_SERVICES})
|
||||
unset IFS
|
||||
|
||||
declare -A idsNMservices
|
||||
idsNMservices[mysql]='MySQL'
|
||||
idsNMservices[nginx]='NGINX'
|
||||
idsNMservices[gogs]='Gogs'
|
||||
idsNMservices[gitea]='Gitea'
|
||||
idsNMservices[haproxy]='HAProxy'
|
||||
idsNMservices[keepalived]='Keepalived'
|
||||
idsNMservices[maxscale]='MaxScale'
|
||||
|
||||
@@ -18,22 +18,14 @@ case "$1" in
|
||||
echo -e "${idsCL[Red]}(${3}) is not an allowed service action.${idsCL[Default]}"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$2" = "mysql" ]; then SER='MySQL'
|
||||
elif [ "$2" = "nginx" ]; then SER='NGINX'
|
||||
elif [ "$2" = "gogs" ]; then SER='Gogs'
|
||||
elif [ "$2" = "gitea" ]; then SER='Gitea'
|
||||
elif [ "$2" = "haproxy" ]; then SER='HAProxy'
|
||||
elif [ "$2" = "keepalived" ]; then SER='Keepalived'
|
||||
elif [ "$2" = "maxscale" ]; then SER='MaxScale'
|
||||
else SER="${2}"
|
||||
fi
|
||||
if [ "${idsNMservices[${2}]}" = "" ]; then idsNMservices[${2}]="${srvc}"; fi
|
||||
if [ "$3" = "stop" ]; then ADISP='Stopp';
|
||||
elif [ "$3" = "enable" ]; then ADISP='Enabl';
|
||||
elif [ "$3" = "disable" ]; then ADISP='Disabl';
|
||||
else ADISP="$(tr '[:lower:]' '[:upper:]' <<< ${3:0:1})${3:1}"; fi
|
||||
if [ "$3" = "start" ] && [ "$2" = "haproxy" ]; then TACT='restart'; else TACT="${3}"; fi
|
||||
|
||||
echo -e "${idsCL[LightGreen]}[[${SER} ${ADISP}ing]]${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}[[${idsNMservices[${srvc}]} ${ADISP}ing]]${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
|
||||
|
||||
nid=1
|
||||
@@ -58,7 +50,7 @@ case "$1" in
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo -e "${idsCL[Green]}${SER} has been ${ADISP}ed${idsCL[Default]}"
|
||||
echo -e "${idsCL[Green]}${idsNMservices[${srvc}]} has been ${ADISP}ed${idsCL[Default]}"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
@@ -118,16 +110,8 @@ case "$1" in
|
||||
|
||||
for srvc in "${NODE_SERVICES[@]}"
|
||||
do
|
||||
if [ "${srvc}" = "mysql" ]; then SER='MySQL: '
|
||||
elif [ "${srvc}" = "nginx" ]; then SER='NGINX: '
|
||||
elif [ "${srvc}" = "gogs" ]; then SER='Gogs: '
|
||||
elif [ "${srvc}" = "gitea" ]; then SER='Gitea: '
|
||||
elif [ "${srvc}" = "haproxy" ]; then SER='HAProxy:'
|
||||
elif [ "${srvc}" = "keepalived" ]; then SER='Keepalived:'
|
||||
elif [ "${srvc}" = "maxscale" ]; then SER='MaxScale:'
|
||||
else SER="${2}"
|
||||
fi
|
||||
echo -en "${SER} "
|
||||
if [ "${idsNMservices[${srvc}]}" = "" ]; then idsNMservices[${srvc}]="${srvc}"; fi
|
||||
echo -en "${idsNMservices[${srvc}]} "
|
||||
if [ $(${NCMD} pgrep ${srvc} | wc -l) -gt "0" ]; then
|
||||
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
|
||||
else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
||||
@@ -149,18 +133,10 @@ case "$1" in
|
||||
fi
|
||||
for srvc in "${NODE_SERVICES[@]}"
|
||||
do
|
||||
if [ "${srvc}" = "mysql" ]; then SER='MySQL: '
|
||||
elif [ "${srvc}" = "nginx" ]; then SER='NGINX: '
|
||||
elif [ "${srvc}" = "gogs" ]; then SER='Gogs: '
|
||||
elif [ "${srvc}" = "gitea" ]; then SER='Gitea: '
|
||||
elif [ "${srvc}" = "haproxy" ]; then SER='HAProxy:'
|
||||
elif [ "${srvc}" = "keepalived" ]; then SER='Keepalived:'
|
||||
elif [ "${srvc}" = "maxscale" ]; then SER='MaxScale:'
|
||||
else SER="${2}"
|
||||
fi
|
||||
if [ "${idsNMservices[${srvc}]}" = "" ]; then idsNMservices[${srvc}]="${srvc}"; fi
|
||||
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then
|
||||
if [ $(${NCMD} pgrep ${srvc} | wc -l) -lt "1" ]; then
|
||||
echo "${SER} is down" | mail -s "iDS-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}
|
||||
echo "${idsNMservices[${srvc}]} is down" | mail -s "iDS-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
12
run.sh
12
run.sh
@@ -14,16 +14,8 @@ if [ "$1" != "service" ] && [ "$1" != "status" ] && [ "$1" != "status-check" ];
|
||||
echo -e "Node hostname: ${NODE_HOSTNAME}"
|
||||
for srvc in "${NODE_SERVICES[@]}"
|
||||
do
|
||||
if [ "${srvc}" = "mysql" ]; then SER='MySQL: '
|
||||
elif [ "${srvc}" = "nginx" ]; then SER='NGINX: '
|
||||
elif [ "${srvc}" = "gogs" ]; then SER='Gogs: '
|
||||
elif [ "${srvc}" = "gitea" ]; then SER='Gitea: '
|
||||
elif [ "${srvc}" = "haproxy" ]; then SER='HAProxy:'
|
||||
elif [ "${srvc}" = "keepalived" ]; then SER='Keepalived:'
|
||||
elif [ "${srvc}" = "maxscale" ]; then SER='MaxScale:'
|
||||
else SER="${2}"
|
||||
fi
|
||||
echo -en "${SER} "
|
||||
if [ "${idsNMservices[${srvc}]}" = "" ]; then idsNMservices[${srvc}]="${srvc}"; fi
|
||||
echo -en "${idsNMservices[${srvc}]} "
|
||||
if [ $(pgrep ${srvc} | wc -l) -gt "0" ]; then
|
||||
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
|
||||
else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
||||
|
||||
Reference in New Issue
Block a user