From cbd2427f65c6b9479805728a29263cc168957662 Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Sat, 23 Aug 2025 18:19:39 -0600 Subject: [PATCH] more setuppp 3 --- customscripts/configure_webhook.sh | 36 ++++++++++++++++++++++++------ customscripts/install_script.sh | 16 +++++++++++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/customscripts/configure_webhook.sh b/customscripts/configure_webhook.sh index 6e80892..d500151 100644 --- a/customscripts/configure_webhook.sh +++ b/customscripts/configure_webhook.sh @@ -1,6 +1,16 @@ #!/bin/bash finalDir='/usr/share/customscripts' +fix_perms() { + # fix ownership + echo -e "\nChanging ownership of $finalDir to $username:$username recursively" + sudo chown -R $username:$username $finalDir + + # fix perms + echo -e "\nSetting perms of $finalDir and contents to 775" + sudo chmod -R 775 $finalDir +} + # ta get da right usermayhaps if [[ -z $SUDO_USER ]]; then echo "Using User $USER" @@ -12,6 +22,24 @@ fi echo -e "\nConfigure Discord Webhook Settings" +if [ -f /tmp/tag.txt ] && [ -f /tmp/webhook.txt ] && [ $webhook -eq 0 ]; then + echo -e "\nExisting Webhook and Tag found. Using those values unless you enter new ones.\n" + existing_webhook=$(cat /tmp/webhook.txt) + existing_tag=$(cat /tmp/tag.txt) + + # move em into place + sudo mv /tmp/tag.txt $finalDir/tag.txt + sudo mv /tmp/webhook.txt $finalDir/webhook.txt + + echo -e "Existing Webhook URL: $existing_webhook" + echo -e "Existing Tag: $existing_tag\n" + + # update permissions + fix_perms + + exit 0 # exit ok +fi + # get webhook url echo -e "\nEnter Discord Webhook URL" read webhook_url @@ -24,12 +52,6 @@ read webhook_tag sudo bash -c "echo '$webhook_url' > $finalDir/webhook.txt" sudo bash -c "echo '$webhook_tag' > $finalDir/tag.txt" -# fix ownership -echo -e "\nChanging ownership of $finalDir to $username:$username recursively" -sudo chown -R $username:$username $finalDir - -# fix perms -echo -e "\nSetting perms of $finalDir and contents to 775" -sudo chmod -R 775 $finalDir +fix_perms echo -e "\n\nDone! Restarting shell..." diff --git a/customscripts/install_script.sh b/customscripts/install_script.sh index 22de8ac..f1c3dc8 100644 --- a/customscripts/install_script.sh +++ b/customscripts/install_script.sh @@ -33,13 +33,25 @@ else exit fi -# clean up any existing install +# get the existing tag and webhooks if any +webhook=1 +if [ -f $finalDir/tag.txt ]; then + echo "Found existing tag.txt, backing up" + cp $finalDir/tag.txt /tmp/tag.txt +fi + +if [ -f $finalDir/webhook.txt ]; then +echo "Found existing webhook.txt, backing up" + cp $finalDir/webhook.txt /tmp/webhook.txt +fi + +# clean up any exisiting repo dir if [[ -d "$tmpDir" ]]; then echo "Cleaning Up Existing $tmpDir" rm -rf "$tmpDir" fi -# clean up any exisiting repo dir +# clean up any existing install if [[ -d "$finalDir" ]]; then echo "Cleaning Up Existing $finalDir" rm -rf "$finalDir"