Update porygon-management.sh

This commit is contained in:
2026-10-11 20:13:48 +00:00
parent 6993e41536
commit a5ffe6c7b9
+27 -2
View File
@@ -5,12 +5,15 @@ ROOT=(-e 'ansible_become=false')
HOSTS_FILE="/root/templates/root.ini"
PASSWORD=(-k)
PLAYBOOK=/root/playbooks/master.yml
COLLECTOR_PLAYBOOK=/root/playbooks/update_collector.yml
PORT=22
ANSIBLE_PORT=()
SERVERS_JSON="/root/servers.json"
LXC_JSON="/root/porygon_lxc_servers.json"
PORYGON_KEY=/path/2/key
PORYGON_LXC_IP="1.2.3.4"
PORYGON_LXC_KEY="/path/2/key"
ALL_SERVERS_INI="/root/all_servers.ini"
###########FUNCTIONS#############
@@ -49,6 +52,8 @@ web_handling
echo "running scraper.py"
/root/scraper.py
sed -i "/^\[servers:vars\]/i ${IP} ansible_port=${PORT}" "$ALL_SERVERS_INI"
echo -e "\nall done, all successful\n\\(^0^)/"
TO_ADD=$(sed 's/\$HOSTNAME/'"$HOSTNAME"'/g' /root/templates/main-page-paste.html)
echo -e "place the following into /var/www/porygon/index.html\n\n$TO_ADD"
@@ -167,6 +172,20 @@ exit 0
}
update_collector() {
ansible-playbook -i "$ALL_SERVERS_INI" "$COLLECTOR_PLAYBOOK" --private-key "$PORYGON_KEY" "${APPEND[@]}" || {
echo "failed to run ansible playbook"
exit 1
}
echo -e "\npushed out new collector.py successfully to all servers\n
\\(^0^)/"
exit 0
}
######RUNNING INTRO###########
intro
@@ -183,6 +202,11 @@ while getopts "udkph" flag; do
SUDO=(--become --ask-become-pass)
;;
c)
echo "pushing out the modified collector.py to all servers"
update_collector
;;
d)
echo -e "ansible debug mode chosen\n"
APPEND=(-vvv)
@@ -203,7 +227,8 @@ while getopts "udkph" flag; do
;;
h)
echo -e "Options:\n-d - DEBUG - runs ansible with verbose (-vvv) flags\n\
echo -e "Options:\n-c - COPY - push out the latest collector.py to all servers\n\
-d - DEBUG - runs ansible with verbose (-vvv) flags\n\
-h - HELP - displays this help page\n-k - KEY - specifies connecting over ssh with a private key\n\
-p - PORT - specifies which port to connect over ssh with\n\
-r - REMOVE - specifies which server to remove from porygon monitoring\n\
@@ -220,4 +245,4 @@ while getopts "udkph" flag; do
done
########RUNNING MAIN##########
main
main