From f8cf44b39820667b7bab7bfe96e0472942e5eeaa Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 16 Feb 2022 11:22:54 -0500 Subject: [PATCH] Update ha_setup.sh --- setup/ha_setup.sh | 68 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/setup/ha_setup.sh b/setup/ha_setup.sh index 0c5f658e..e03d7fda 100644 --- a/setup/ha_setup.sh +++ b/setup/ha_setup.sh @@ -114,10 +114,14 @@ show_menu(){ printf "${menu}**${number} 1)${safe} Switch to Stable Branch ${normal}\n" printf "${menu}**${number} 2)${number} Switch to Beta Branch ${normal}\n" printf "${menu}**${number} 3)${fgred} Switch to Dev Branch ${normal}\n" - printf "${menu}**${number} 4)${fgred} Edit Home Assistant Configuration ${normal}\n" - printf "${menu}**${number} 5)${safe} Just Update Containers ${normal}\n" - printf "${menu}**${number} 6)${number} Remove Unused Images ${normal}\n" - printf "${menu}**${number} 7)${safe} Update Host OS ${normal}\n" + printf "${menu}**${number} 4)${safe} Backup Home Assistant Data (to root) ${normal}\n" + printf "${menu}**${number} 5)${number} Restore Home Assistant Data ${normal}\n" + printf "${menu}**${number} 6)${fgred} Edit Home Assistant Configuration ${normal}\n" + printf "${menu}**${number} 7)${safe} Restart Home Assistant ${normal}\n" + printf "${menu}**${number} 8)${safe} Just Update Containers ${normal}\n" + printf "${menu}**${number} 9)${number} Remove Unused Images ${normal}\n" + printf "${menu}**${number} 10)${safe} Update Host OS ${normal}\n" + printf "${menu}**${number} 11)${safe} Reboot Host OS ${normal}\n" printf "${menu}*********************************************${normal}\n" printf "Please choose an option from the menu and enter or ${fgred}x to exit. ${normal}" read opt @@ -148,31 +152,77 @@ while [ $opt != '' ] TAG=beta break; ;; - 3) clear; + 3) while true; do + read -p "Are you sure you want to Switch to Dev Branch? Proceed(y/n)?" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done + clear; option_picked "Switching to Dev Branch"; TAG=dev break; ;; 4) clear; + option_picked "Backing up Home Assistant Data to root (hass_config)"; + rm -r hass_config; + cp -pR /var/lib/docker/volumes/hass_config/ /root/; + exit; + ;; + 5) while true; do + read -p "Are you sure you want to Restore Home Assistant Data? Proceed(y/n)?" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done + clear; + option_picked "Restoring Home Assistant Data from root (hass_config)"; + rm -r /var/lib/docker/volumes/hass_config/_data; + cp -pR /root/hass_config/_data /var/lib/docker/volumes/hass_config/; + exit; + ;; + 6) while true; do + read -p "Are you sure you want to Edit Home Assistant Configuration? Proceed(y/n)?" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done + clear; option_picked "Editing Home Assistant Configuration"; nano /var/lib/docker/volumes/hass_config/_data/configuration.yaml; exit; ;; - 5) clear; + 7) clear; + option_picked "Restarting Home Assistant"; + docker restart homeassistant; + exit; + ;; + 8) clear; option_picked "Just Updating Containers"; ./update-containers.sh; exit; ;; - 6) clear; + 9) clear; option_picked "Removing Unused Images"; docker image prune -af; exit; ;; - 7) clear; + 10) clear; option_picked "Updating Host OS"; apt update && apt upgrade -y; exit; ;; + 11) clear; + option_picked "Reboot Host OS"; + reboot; + exit; + ;; x)exit; ;; @@ -230,6 +280,6 @@ ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,3840 EOF systemctl daemon-reload systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - +mkdir /root/hass_config echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" rm -rf /ha_setup.sh /var/{cache,log}/* /var/lib/apt/lists/*