Update nodemgmt-scripts.sh
This commit is contained in:
@@ -19,58 +19,14 @@ source /opt/idssys/nodemgmt/defaults.inc
|
||||
# ========================================================= #
|
||||
|
||||
case "$1" in
|
||||
service)
|
||||
if [ "${NM_SERVICES[${2}]}" = "" ]; then
|
||||
echo -e "${idsCL[Red]}(${2}) is not an allowed service.${idsCL[Default]}"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "start,stop,restart,reload,enable,disable" != *"${3}"* ]] && [ "${2}" != "daemon-reload" ]; then
|
||||
echo -e "${idsCL[Red]}(${3}) is not an allowed service action.${idsCL[Default]}"
|
||||
exit 1
|
||||
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]}[[${NM_SERVICES[${2}]} ${ADISP}ing]]${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
|
||||
|
||||
nid=1
|
||||
for nip in "${NODE_HOSTS[@]}"
|
||||
do
|
||||
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost'
|
||||
NCMD=''
|
||||
else
|
||||
NCMD="ssh root@${nip}"
|
||||
fi
|
||||
echo -en "${ADISP}ing on Node ${nid} ($nip)...${idsCL[Default]}"
|
||||
$NCMD systemctl $3 $2
|
||||
if [[ "enable,disable" = *"${3}"* ]] || [ "${2}" = "daemon-reload" ]; then
|
||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||
elif [[ $(${NCMD} pgrep ${2} | wc -l) -gt "0" ]]; then
|
||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||
elif [ "$3" = "stop" ]; then echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}"
|
||||
else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"
|
||||
fi
|
||||
nid=`expr $nid + 1`
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo -e "${idsCL[Green]}${NM_SERVICES[${2}]} has been ${ADISP}ed${idsCL[Default]}"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
|
||||
|
||||
newcert)
|
||||
echo -e "${idsCL[LightGreen]}Requesting Certificate for '${idsCL[Yellow]}${2}${idsCL[LightGreen]}'...${idsCL[Default]}"
|
||||
do_with_root $CERT_DAEMON certonly --webroot -w /var/www/html -d $2
|
||||
do_with_root chown -R root:letsencrypt /etc/letsencrypt
|
||||
do_with_root chmod -R 6775 /etc/letsencrypt
|
||||
echo -e "${idsCL[LightGreen]}Waiting for Certificate Replication...${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}Waiting for Replication...${idsCL[Default]}"
|
||||
sleep 20
|
||||
"$0" service nginx reload
|
||||
exit 0
|
||||
@@ -135,7 +91,9 @@ case "$1" in
|
||||
include conf.d/include/letsencrypt-acme-challenge.conf;
|
||||
}
|
||||
" > /etc/nginx/sites-available/${NEW_SITE}.conf
|
||||
|
||||
nodemgmt set-permissions ${NEW_SITE}
|
||||
nodemgmt newcert ${NEW_SITE}
|
||||
;;
|
||||
|
||||
update)
|
||||
@@ -262,6 +220,52 @@ case "$1" in
|
||||
done
|
||||
if [ "${NEW_SITE}" != "" ]; then echo ""; fi
|
||||
;;
|
||||
|
||||
service)
|
||||
if [ "${NM_SERVICES[${2}]}" = "" ]; then
|
||||
echo -e "${idsCL[Red]}(${2}) is not an allowed service.${idsCL[Default]}"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "start,stop,restart,reload,enable,disable" != *"${3}"* ]] && [ "${2}" != "daemon-reload" ]; then
|
||||
echo -e "${idsCL[Red]}(${3}) is not an allowed service action.${idsCL[Default]}"
|
||||
exit 1
|
||||
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]}[[${NM_SERVICES[${2}]} ${ADISP}ing]]${idsCL[Default]}"
|
||||
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
|
||||
|
||||
nid=1
|
||||
for nip in "${NODE_HOSTS[@]}"
|
||||
do
|
||||
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then
|
||||
nip='localhost'
|
||||
NCMD=''
|
||||
else
|
||||
NCMD="ssh root@${nip}"
|
||||
fi
|
||||
echo -en "${ADISP}ing on Node ${nid} ($nip)...${idsCL[Default]}"
|
||||
$NCMD systemctl $3 $2
|
||||
if [[ "enable,disable" = *"${3}"* ]] || [ "${2}" = "daemon-reload" ]; then
|
||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||
elif [[ $(${NCMD} pgrep ${2} | wc -l) -gt "0" ]]; then
|
||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||
elif [ "$3" = "stop" ]; then echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}"
|
||||
else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"
|
||||
fi
|
||||
nid=`expr $nid + 1`
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo -e "${idsCL[Green]}${NM_SERVICES[${2}]} has been ${ADISP}ed${idsCL[Default]}"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
echo -e "Usage: ${idsCL[Yellow]}nodemgmt${idsCL[Default]} { ${idsCL[Yellow]}service${idsCL[Default]} [service] [action] | ${idsCL[Yellow]}status${idsCL[Default]} | ${idsCL[Yellow]}newcert${idsCL[Default]} [domain(,s)] | ${idsCL[Yellow]}certrenew${idsCL[Default]} }"
|
||||
|
||||
Reference in New Issue
Block a user