Uninstall option

develop
Dominik Dzienia 3 weeks ago
parent d9f3745dd1
commit 35e2e2801d

@ -40,6 +40,7 @@ Options:
-r, --restart Restart containers -r, --restart Restart containers
--update-ns Update Nightscout and Mongo containers --update-ns Update Nightscout and Mongo containers
--force-check Force update check in UI mode --force-check Force update check in UI mode
--uninstall Uninstall Nightscout, containers, data, config and tool
-h, --help Show this help message -h, --help Show this help message
EOF EOF
} }
@ -50,7 +51,7 @@ parse_commandline_args() {
CMDARGS=$(getopt --quiet \ CMDARGS=$(getopt --quiet \
-o wvldpuc:srh \ -o wvldpuc:srh \
--long watchdog,version,loud,develop,production,update,force-check,channel:,cleanup,restart,update-ns,help \ --long watchdog,version,loud,develop,production,update,force-check,channel:,cleanup,restart,update-ns,uninstall,help \
-n 'nightscout-tool' -- "$@") -n 'nightscout-tool' -- "$@")
# shellcheck disable=SC2181 # shellcheck disable=SC2181
@ -129,6 +130,12 @@ parse_commandline_args() {
action="update-ns" action="update-ns"
shift shift
;; ;;
--uninstall)
#shellcheck disable=SC2034
NONINTERACTIVE_MODE=true
action="uninstall"
shift
;;
-h | --help) -h | --help)
action="help" action="help"
shift shift
@ -184,6 +191,10 @@ parse_commandline_args() {
do_update_ns do_update_ns
exit 0 exit 0
;; ;;
uninstall)
do_uninstall
exit 0
;;
esac esac
if [ "$WATCHDOGMODE" = "true" ]; then if [ "$WATCHDOGMODE" = "true" ]; then

@ -20,3 +20,19 @@ source_admin() {
msgok "Imported admin config" msgok "Imported admin config"
fi fi
} }
do_uninstall() {
msgok "Uninstalling..."
uninstall_containers
ohai "Usuwanie plików, proszę czekać..."
uninstall_cron
rm -r "${MONGO_DB_DIR:?}/data"
rm -r "${CONFIG_ROOT_DIR:?}"
rm "$TOOL_LINK"
rm -r "${NIGHTSCOUT_ROOT_DIR:?}/tools"
rm -r "${NIGHTSCOUT_ROOT_DIR:?}/updates"
do_cleanup_diagnostics
do_cleanup_app_logs
do_cleanup_app_state
event_mark "uninstall"
}

Loading…
Cancel
Save