From 23aedfde45345a6cb5eb02a739dbb880cd6da81f Mon Sep 17 00:00:00 2001 From: Eduard Veit Date: Sun, 31 Jul 2022 11:29:27 +0200 Subject: [PATCH] feat(Gitea): add uninstall parameter --- gitea-installer.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gitea-installer.sh b/gitea-installer.sh index a9a0878..6917b0c 100644 --- a/gitea-installer.sh +++ b/gitea-installer.sh @@ -51,9 +51,28 @@ function install_gitea uberspace web backend set / --http --port $DEFAULT_PORT uberspace web backend list install_update_script + echo "This is the file structure for this app" + echo_tree printf "You can now access your $APP_NAME by directing you Browser to: \n https://%s.uber.space \n" "$USER" } +function uninstall_gitea +{ + # If some files do not exist there may be some errors + unset_critical_section + $GITEA_BIN_LOCATION manager flush-queues + supervisorctl stop gitea + sleep 30 + mysql --verbose --execute="DROP DATABASE ${USER}_gitea" + rm ~/etc/services.d/gitea.ini + rm -r ~/gitea + rm ~/bin/gitea + rm ~/bin/gitea-update + supervisorctl reread + supervisorctl update + set_critical_section +} + function process_parameters { while test $# -gt 0 @@ -65,6 +84,13 @@ function process_parameters USE_VERSION="$1" shift ;; + uninstall ) + echo "This command tries to revert the $APP_NAME installation, it will delete all of its scripts, service config, ~/gitea directory with all contents and drop the database" + if yes-no_question "Do you really want to do this?" + then uninstall_gitea + fi + exit 0 + ;; * ) echo "$1 can not be processed, exiting script" exit 1 @@ -303,6 +329,27 @@ end_of_content chmod u+x --verbose ~/bin/gitea-update } +function echo_tree +{ +cat << 'end_of_content' +. +├── bin +│  ├── [-rwxrw-r--] gitea +│  └── [-rwxrw-r--] gitea-update +├── etc +│  ├── services.d +│  │  └── gitea.ini +│  └── ... +├── gitea +│  ├── custom +│  │  └── conf +│  │  └── app.ini +│  ├── data +│  └── [-rwxrw-r--] gitea +└── ... +end_of_content +} + function yes-no_question { local question=$1