From c1d2d339e065fb3e73206f8fd3d7ac73f50f9b06 Mon Sep 17 00:00:00 2001 From: RaptaG <77157639+RaptaG@users.noreply.github.com> Date: Tue, 5 Jul 2022 13:32:09 +0300 Subject: [PATCH] Add the ability to select if you want to delete directly the script when finished (version 1.4) --- CAAIS.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/CAAIS.sh b/CAAIS.sh index 1e094d9..b407160 100644 --- a/CAAIS.sh +++ b/CAAIS.sh @@ -5,7 +5,7 @@ set -e # Definitions -ver=1.3 +ver=1.4 fname=$(basename $0) caais-exit() { @@ -38,8 +38,8 @@ caais() { # Checking if Chaotic-AUR is already appended in pacman.conf, if not skip echo 'Appending Chaotic-AUR to the mirrorlist...' - appendInPacmanConf=$(grep 'chaotic-aur' /etc/pacman.conf) + if [ $appendInPacmanConf -eq 0 ]; then echo 'Chaotic-AUR is already append in pacman.conf, skipping...' else @@ -50,9 +50,9 @@ caais() { echo 'Refreshing the mirrorlists...' echo -n 'Doing this is needed for Chaotic-AUR to work, but will also cause a system upgrade. Do you wish to continue? [Y/n] ' - read answer + read answer1 - case "$answer" in + case "$answer1" in [yY]* | "") pacman -Syu ;; @@ -63,7 +63,24 @@ caais() { esac } +# Select if you want to delete the script +delete-caais() { + echo -n 'Since Chaotic-AUR is installed, this program has no use. Would you like to delete it [Y/n] ' + read answer2 + + case "$answer2" in + [yY]* | "") + echo 'Deleting...' + rm $fname + caais-exit + ;; + *) + caais-exit + ;; + esac +} + # Running the script caais "$@" echo 'Done! Now Chaotic-AUR should be installed and working in your system!' -caais-exit +delete-caais "$@"