From 599430973169edb7e39643fb2475db11345b804e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Thu, 29 Jul 2021 22:30:42 +0200 Subject: [PATCH] Remove deSEC (#2067) --- addons/desec.sh | 4 +- addons/remove_desec.sh | 97 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 addons/remove_desec.sh diff --git a/addons/desec.sh b/addons/desec.sh index 8636787cb8..3a2654bb68 100644 --- a/addons/desec.sh +++ b/addons/desec.sh @@ -13,14 +13,14 @@ msg_box "Please enter the subdomain (*example*.dedyn.io) that you want to use" while : do SUBDEDYN=$(input_box_flow "Please enter the subdomain (*example*.dedyn.io) that you want to use \ -The only allowed characters for the username are: +The only allowed characters for the subdomain are: 'a-z', 'A-Z', and '0-9'") if [[ "$SUBDEDYN" == *" "* ]] then msg_box "Please don't use spaces." elif [ "${SUBDEDYN//[A-Za-z0-9]}" ] then - msg_box "Allowed characters for the username are:\na-z', 'A-Z', and '0-9'\n\nPlease try again." + msg_box "Allowed characters for the subdomain are:\na-z', 'A-Z', and '0-9'\n\nPlease try again." else DEDYNDOMAIN="$SUBDEDYN.dedyn.io" # Check for SOA record diff --git a/addons/remove_desec.sh b/addons/remove_desec.sh new file mode 100644 index 0000000000..40733b0dd1 --- /dev/null +++ b/addons/remove_desec.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ + +true +SCRIPT_NAME="deSEC Removal" +SCRIPT_EXPLAINER="This script lets you remove your deSEC account.\n\nMaybe you want to re-add it again with another domain? In that case this is what you need to run first, since the install script only can handle one email address at the time." +# shellcheck source=lib.sh +source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode + +# Must be root +root_check + +# Check if desec is installed +if ! is_desec_installed +then + exit +fi + +# Check if account exists +if ! curl -sfX GET https://desec.io/api/v1/auth/account/ \ + --header "Authorization: Token $DEDYN_TOKEN" +then + msg_box "It seems like your account doesn't exist. +Please run 'sudo bash $SCRIPTS/menu.sh --> Server Configuration --> deSEC' to configure it." +else + msg_box "Your deSEC account information:\n\n$(curl -X GET https://desec.io/api/v1/auth/account/ --header "Authorization: Token $DEDYN_TOKEN") + +Please copy the email address." +fi + +# Final warning before destruction! +msg_box "WARNING! + +We will now delete your deSEC account and all the domains that are registered with it. This action is irreversible! + +You will now be given the chance to opt out if you wish." + +if ! yesno_box_no "Would you like to delete your deSEC account together with $DEDYN_NAME?" +then + print_text_in_color "$ICyan" "*Peeew* Everything is still intact! :)" + exit +fi + +# Remove domain +print_text_in_color "$ICyan" "Removing $DEDYN_NAME..." +curl -X DELETE https://desec.io/api/v1/domains/"$DEDYN_NAME"/ \ + --header "Authorization: Token $DEDYN_TOKEN" + +# Ask for email and password +VALIDEMAIL=$(input_box_flow "Please enter the email address (from the previous screen) for your deSEC account.") +VALIDPASSWD=$(input_box_flow "Please enter the password for your deSEC account.") + +# Just some info +msg_box "If the correct credentials has been provided, the server will send you an email with a link of the form: +https://desec.io/api/v1/v/delete-account//. + +To finish the deletion, click on that link, which then will take you to the deSEC frontend. + +The link expires after 12 hours. It is also invalidated by certain other account-related activities, such as changing your email address or password." + +# Do the actual removal of the account +while : +do + if ! curl -fX POST https://desec.io/api/v1/auth/account/delete/ --header "Content-Type: application/json" --data @- <