From 1aa3ed1558d473bba15b88ba697e66ba3051cdc1 Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 16:24:52 +0200 Subject: [PATCH 01/10] Test cache Trying to make caches work --- .gitignore | 2 ++ setup.sh | 14 ++++++++++++-- src/updater.sh | 14 +++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1787e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +src/utils/.cache +src/utils/.md5 \ No newline at end of file diff --git a/setup.sh b/setup.sh index 54fbf65..bbac554 100755 --- a/setup.sh +++ b/setup.sh @@ -3,11 +3,20 @@ source src/utils/global.sh printProgress "Setup: starting" +if [[ -f "src/utils/.cache" ]]; then + md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 +else + echo "create .cache test" + echo "create .cache test" > src/utils/.cache + md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 +fi +chmod 775 src/utils/.cache +chmod 775 src/utils/.md5 + EXST=$(cat ~/.bashrc | grep -c "updater.sh") if [[ $EXST -ne 0 ]]; then - printProgress "Alias 'up' already exists. Use 'up' or run './src/updater.sh'." - printProgress "Setup completed" + printProgress "Setup completed." exit 0 else echo "alias up='bash $(pwd)/src/updater.sh'" >> ~/.bashrc @@ -15,6 +24,7 @@ else printProgress "Alias 'up' added.\nUse 'up' or run './src/updater.sh'." printProgress "Setup completed." fi + printf "${RED}" read -p "Press enter, the process will be killed:\nif your terminal closes, open a new one to see changes." text printf "${NORMAL}" diff --git a/src/updater.sh b/src/updater.sh index db9467e..00c08a2 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -3,6 +3,19 @@ src_path=$(dirname "$(readlink -f "$0")") source "$src_path"/utils/global.sh +if [[ -f "$src_path/utils/.cache" ]]; then + echo "found .cache test" + HASH=$(md5sum "$src_path/utils/.cache" | cut -d " " -f1) + if [[ $HASH != $(cat $src_path/utils/.md5) ]]; then + echo "found .cache, but changed test" + md5sum "$src_path"/utils/.cache | cut -d " " -f1 > "$src_path"/utils/.md5 + fi +else + echo "no .cache test" + echo "no .cache test" > src/utils/.cache + md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 +fi + printf "${LOGO}" if [[ $(stty size | awk '{print $2}') -ge 69 ]]; then cat "$src_path"/utils/.logo @@ -51,5 +64,4 @@ fi # check trash source "$src_path"/utils/trash.sh -printf "\n" exit 0 From 241f1a711cb58e684f8b60a7293cf6c66e233732 Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 17:04:18 +0200 Subject: [PATCH 02/10] Add cache Trying to add a cache system, so that we can set user preferences from there --- setup.sh | 3 +-- src/updater.sh | 51 ++++++++----------------------------------- src/utils/cachegen.sh | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 44 deletions(-) create mode 100755 src/utils/cachegen.sh diff --git a/setup.sh b/setup.sh index bbac554..6176ba2 100755 --- a/setup.sh +++ b/setup.sh @@ -6,8 +6,7 @@ printProgress "Setup: starting" if [[ -f "src/utils/.cache" ]]; then md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 else - echo "create .cache test" - echo "create .cache test" > src/utils/.cache + src/utils/cachegen.sh > src/utils/.cache md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 fi chmod 775 src/utils/.cache diff --git a/src/updater.sh b/src/updater.sh index 00c08a2..6619e7e 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -4,17 +4,16 @@ src_path=$(dirname "$(readlink -f "$0")") source "$src_path"/utils/global.sh if [[ -f "$src_path/utils/.cache" ]]; then - echo "found .cache test" HASH=$(md5sum "$src_path/utils/.cache" | cut -d " " -f1) if [[ $HASH != $(cat $src_path/utils/.md5) ]]; then - echo "found .cache, but changed test" md5sum "$src_path"/utils/.cache | cut -d " " -f1 > "$src_path"/utils/.md5 fi else - echo "no .cache test" - echo "no .cache test" > src/utils/.cache - md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 + "$src_path"/utils/cachegen.sh > "$src_path"/utils/.cache + md5sum "$src_path"/utils/.cache | cut -d " " -f1 > "$src_path"/utils/.md5 + chmod 775 "$src_path"/utils/.cache fi +chmod 775 "$src_path"/utils/.md5 printf "${LOGO}" if [[ $(stty size | awk '{print $2}') -ge 69 ]]; then @@ -22,44 +21,12 @@ if [[ $(stty size | awk '{print $2}') -ge 69 ]]; then fi printf "Running on: $(uname -rs)\n${NORMAL}" -# termux -if [[ $(command -v pkg) ]]; then - source "$src_path"/package/termux.sh - source "$src_path"/utils/trash.sh - exit 0; -#gentoo -elif [[ $(command -v emerge) ]]; then - source "$src_path"/package/gentoo.sh - source "$src_path"/utils/trash.sh - exit 0; -fi - -# check privileges source "$src_path"/utils/privileges.sh - -# snap -if [[ $(command -v snap) ]]; then - source "$src_path"/package/snap.sh -fi - -# flatpak -if [[ $(command -v flatpak) ]]; then - source "$src_path"/package/flatpak.sh -fi - -# debian -if [[ $(command -v apt-get) ]]; then - source "$src_path"/package/debian.sh -# rpm -elif [[ $(command -v yum) ]]; then - source "$src_path"/package/rpm.sh -# arch -elif [[ $(command -v pacman) ]]; then - source "$src_path"/package/archlinux.sh -# not found -else - printf "${RED}System not supported${NORMAL}" -fi +while read line; do + if [[ "$line" != "" ]]; then + source "$src_path"/package/"$line".sh; + fi +done < $src_path/utils/.cache # check trash source "$src_path"/utils/trash.sh diff --git a/src/utils/cachegen.sh b/src/utils/cachegen.sh new file mode 100755 index 0000000..afc8c4b --- /dev/null +++ b/src/utils/cachegen.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +### generates default caches ### +OUT="" + +# arch +if [[ $(command -v pacman) ]]; then + OUT+="archlinux\n" +fi + +# debian +if [[ $(command -v apt-get) ]]; then + OUT+="debian\n" +fi + +# flatpak +if [[ $(command -v flatpak) ]]; then + OUT+="flatpak\n" +fi + +#gentoo +if [[ $(command -v emerge) ]]; then + OUT+="gentoo\n" +fi + +# rpm +if [[ $(command -v yum) ]]; then + OUT+="rpm\n" +fi + +# snap +if [[ $(command -v snap) ]]; then + OUT+="snap\n" +fi + +# termux +if [[ $(command -v pkg) ]]; then + OUT+="termux" +fi + +echo -e "$OUT" \ No newline at end of file From 7e82e1c8c049d70a3eb3c42479c02ec31a4c65ef Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 17:18:26 +0200 Subject: [PATCH 03/10] Add trash to cache Added the trash to caches --- src/updater.sh | 5 +---- src/utils/cachegen.sh | 16 +++++++++------- src/utils/trash.sh | 10 ++-------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/updater.sh b/src/updater.sh index 6619e7e..fe55f22 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -24,11 +24,8 @@ printf "Running on: $(uname -rs)\n${NORMAL}" source "$src_path"/utils/privileges.sh while read line; do if [[ "$line" != "" ]]; then - source "$src_path"/package/"$line".sh; + source "$src_path"/"$line".sh; fi done < $src_path/utils/.cache -# check trash -source "$src_path"/utils/trash.sh - exit 0 diff --git a/src/utils/cachegen.sh b/src/utils/cachegen.sh index afc8c4b..d0fa3fe 100755 --- a/src/utils/cachegen.sh +++ b/src/utils/cachegen.sh @@ -5,37 +5,39 @@ OUT="" # arch if [[ $(command -v pacman) ]]; then - OUT+="archlinux\n" + OUT+="package/archlinux\n" fi # debian if [[ $(command -v apt-get) ]]; then - OUT+="debian\n" + OUT+="package/debian\n" fi # flatpak if [[ $(command -v flatpak) ]]; then - OUT+="flatpak\n" + OUT+="package/flatpak\n" fi #gentoo if [[ $(command -v emerge) ]]; then - OUT+="gentoo\n" + OUT+="package/gentoo\n" fi # rpm if [[ $(command -v yum) ]]; then - OUT+="rpm\n" + OUT+="package/rpm\n" fi # snap if [[ $(command -v snap) ]]; then - OUT+="snap\n" + OUT+="package/snap\n" fi # termux if [[ $(command -v pkg) ]]; then - OUT+="termux" + OUT+="package/termux\n" fi +OUT+="utils/trash" + echo -e "$OUT" \ No newline at end of file diff --git a/src/utils/trash.sh b/src/utils/trash.sh index 9d10a17..773fa91 100755 --- a/src/utils/trash.sh +++ b/src/utils/trash.sh @@ -5,14 +5,8 @@ source $(dirname "$(readlink -f "$0")")/utils/global.sh if [[ -d ~/.local/share/Trash/files ]]; then printf "${RED}\nShowing files in .local/share/Trash/files${NORMAL}\n" ls -hl ~/.local/share/Trash/files - printf "Should I clean Trash? " - read -p "[y/n]: " ANSW - if [[ "$ANSW" == "y" ]]; then - sudo rm -rf ~/.local/share/Trash/* - printProgress "Trash: cleaned" - else - printProgress "Trash: not cleaned" - fi + sudo rm -rf ~/.local/share/Trash/* + printProgress "Trash: cleaned" else printProgress "\nTrash is empty, nothing to clean" fi \ No newline at end of file From 2f22461635a34ff17c76993569f7cada95d4e944 Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 17:23:51 +0200 Subject: [PATCH 04/10] Add privileges Privileges added to cache: remove them from .cache if you want to run this script without them --- src/updater.sh | 1 - src/utils/cachegen.sh | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/updater.sh b/src/updater.sh index fe55f22..628b110 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -21,7 +21,6 @@ if [[ $(stty size | awk '{print $2}') -ge 69 ]]; then fi printf "Running on: $(uname -rs)\n${NORMAL}" -source "$src_path"/utils/privileges.sh while read line; do if [[ "$line" != "" ]]; then source "$src_path"/"$line".sh; diff --git a/src/utils/cachegen.sh b/src/utils/cachegen.sh index d0fa3fe..bebb2bd 100755 --- a/src/utils/cachegen.sh +++ b/src/utils/cachegen.sh @@ -3,6 +3,8 @@ ### generates default caches ### OUT="" +OUT+="utils/privileges\n" + # arch if [[ $(command -v pacman) ]]; then OUT+="package/archlinux\n" From 88e61db7633b06cf3156fcb35aefd1421f0ba492 Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 17:35:52 +0200 Subject: [PATCH 05/10] Change variable name Changed variable 'src_path' name and simplified code --- src/updater.sh | 30 +++++++++++++++--------------- src/utils/global.sh | 4 ++-- src/utils/trash.sh | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/updater.sh b/src/updater.sh index 628b110..61750a4 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -1,30 +1,30 @@ #!/bin/bash -src_path=$(dirname "$(readlink -f "$0")") -source "$src_path"/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh -if [[ -f "$src_path/utils/.cache" ]]; then - HASH=$(md5sum "$src_path/utils/.cache" | cut -d " " -f1) - if [[ $HASH != $(cat $src_path/utils/.md5) ]]; then - md5sum "$src_path"/utils/.cache | cut -d " " -f1 > "$src_path"/utils/.md5 +if [[ -f "$SRC/utils/.cache" ]]; then + HASH=$(md5sum "$SRC/utils/.cache" | cut -d " " -f1) + if [[ $HASH != $(cat $SRC/utils/.md5) ]]; then + md5sum $SRC/utils/.cache | cut -d " " -f1 > $SRC/utils/.md5 fi else - "$src_path"/utils/cachegen.sh > "$src_path"/utils/.cache - md5sum "$src_path"/utils/.cache | cut -d " " -f1 > "$src_path"/utils/.md5 - chmod 775 "$src_path"/utils/.cache + $SRC/utils/cachegen.sh > $SRC/utils/.cache + md5sum $SRC/utils/.cache | cut -d " " -f1 > $SRC/utils/.md5 + chmod 775 $SRC/utils/.cache fi -chmod 775 "$src_path"/utils/.md5 +chmod 775 $SRC/utils/.md5 -printf "${LOGO}" +printf "$LOGO" if [[ $(stty size | awk '{print $2}') -ge 69 ]]; then - cat "$src_path"/utils/.logo + cat $SRC/utils/.logo fi -printf "Running on: $(uname -rs)\n${NORMAL}" +printf "Running on: $(uname -rs)\n$NORMAL" while read line; do if [[ "$line" != "" ]]; then - source "$src_path"/"$line".sh; + source $SRC/$line.sh; fi -done < $src_path/utils/.cache +done < $SRC/utils/.cache exit 0 diff --git a/src/utils/global.sh b/src/utils/global.sh index bfcb010..4f5b39c 100755 --- a/src/utils/global.sh +++ b/src/utils/global.sh @@ -7,8 +7,8 @@ RED="\e[1;91;49m" printProgress() { if [[ "$1" == *starting ]] || [[ "$1" == *privileges ]] || [[ "$1" == *already* ]] || [[ "$1" == *aborting* ]]; then - printf "${RED}\n$1\n${NORMAL}" + printf "$RED\n$1\n$NORMAL" else - printf "${GREEN}$1\n${NORMAL}" + printf "$GREEN$1\n$NORMAL" fi } \ No newline at end of file diff --git a/src/utils/trash.sh b/src/utils/trash.sh index 773fa91..42373c3 100755 --- a/src/utils/trash.sh +++ b/src/utils/trash.sh @@ -3,7 +3,7 @@ source $(dirname "$(readlink -f "$0")")/utils/global.sh if [[ -d ~/.local/share/Trash/files ]]; then - printf "${RED}\nShowing files in .local/share/Trash/files${NORMAL}\n" + printf "$RED\nShowing files in .local/share/Trash/files$NORMAL\n" ls -hl ~/.local/share/Trash/files sudo rm -rf ~/.local/share/Trash/* printProgress "Trash: cleaned" From 9701fc371337080a308bec257c5a4a9ce5f8061f Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 17:48:34 +0200 Subject: [PATCH 06/10] Change UI Better Trash listing --- src/utils/trash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/trash.sh b/src/utils/trash.sh index 42373c3..772f768 100755 --- a/src/utils/trash.sh +++ b/src/utils/trash.sh @@ -4,7 +4,7 @@ source $(dirname "$(readlink -f "$0")")/utils/global.sh if [[ -d ~/.local/share/Trash/files ]]; then printf "$RED\nShowing files in .local/share/Trash/files$NORMAL\n" - ls -hl ~/.local/share/Trash/files + ls -Ahl ~/.local/share/Trash/files sudo rm -rf ~/.local/share/Trash/* printProgress "Trash: cleaned" else From bce70ab008d71e1547fbde6f721ece791b27adbd Mon Sep 17 00:00:00 2001 From: archetipico Date: Wed, 23 Jun 2021 18:29:22 +0200 Subject: [PATCH 07/10] Bug fix Now every command can be run with privileges, it just has to check before running --- setup.sh | 8 ++------ src/package/archlinux.sh | 10 ++++++---- src/package/debian.sh | 12 +++++++----- src/package/flatpak.sh | 10 +++++++--- src/package/gentoo.sh | 10 ++++++---- src/package/rpm.sh | 12 +++++++----- src/package/snap.sh | 7 ++++++- src/package/termux.sh | 10 ++++++---- src/utils/checkpwr.sh | 8 ++++++++ 9 files changed, 55 insertions(+), 32 deletions(-) create mode 100755 src/utils/checkpwr.sh diff --git a/setup.sh b/setup.sh index 6176ba2..fdb63bf 100755 --- a/setup.sh +++ b/setup.sh @@ -3,12 +3,8 @@ source src/utils/global.sh printProgress "Setup: starting" -if [[ -f "src/utils/.cache" ]]; then - md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 -else - src/utils/cachegen.sh > src/utils/.cache - md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 -fi +src/utils/cachegen.sh > src/utils/.cache +md5sum src/utils/.cache | cut -d " " -f1 > src/utils/.md5 chmod 775 src/utils/.cache chmod 775 src/utils/.md5 diff --git a/src/package/archlinux.sh b/src/package/archlinux.sh index b2ebe9a..8af2a83 100755 --- a/src/package/archlinux.sh +++ b/src/package/archlinux.sh @@ -1,21 +1,23 @@ #!/bin/bash -source $(dirname "$(readlink -f "$0")")/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh +PWR=$(source $SRC/utils/checkpwr.sh) PKG="pacman" printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "update: starting" -sudo $PKG -Syy +$PWR $PKG -Syy printProgress "update: completed" printProgress "upgrade: starting" -sudo $PKG -Syu +$PWR $PKG -Syu printProgress "upgrade: completed" printProgress "clean all: starting" -sudo $PKG -R $($PKG -Qtdq) +$PWR $PKG -R $($PKG -Qtdq) printProgress "clean all: completed" diff --git a/src/package/debian.sh b/src/package/debian.sh index 69753fd..3561310 100755 --- a/src/package/debian.sh +++ b/src/package/debian.sh @@ -1,7 +1,9 @@ #!/bin/bash -source $(dirname "$(readlink -f "$0")")/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh +PWR=$(source $SRC/utils/checkpwr.sh) PKG="apt-get" if [[ $(command -v apt) ]]; then @@ -12,19 +14,19 @@ printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "update: starting" -sudo $PKG update +$PWR $PKG update printProgress "update: completed" printProgress "upgrade: starting" -sudo $PKG upgrade +$PWR $PKG upgrade printProgress "upgrade: completed" printProgress "autoclean: starting" -sudo $PKG autoclean +$PWR $PKG autoclean printProgress "autoclean: completed" printProgress "autoremove: starting" -sudo $PKG autoremove +$PWR $PKG autoremove printProgress "autoremove: completed" printf "\n" diff --git a/src/package/flatpak.sh b/src/package/flatpak.sh index 8ea6d49..a2f3c91 100755 --- a/src/package/flatpak.sh +++ b/src/package/flatpak.sh @@ -1,19 +1,23 @@ #!/bin/bash +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh + +PWR=$(source $SRC/utils/checkpwr.sh) PKG="flatpak" printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "flatpak update: starting" -sudo $PKG update +$PWR $PKG update printProgress "flatpak update: completed" printProgress "flatpak repair: starting" -sudo $PKG repair +$PWR $PKG repair printProgress "flatpak repair: completed" printProgress "flatpak uninstall unused extensions: starting" -sudo $PKG uninstall --unused +$PWR $PKG uninstall --unused printProgress "flatpak uninstall unused extensions: completed" printf "\n" diff --git a/src/package/gentoo.sh b/src/package/gentoo.sh index 129f18f..669e023 100755 --- a/src/package/gentoo.sh +++ b/src/package/gentoo.sh @@ -1,21 +1,23 @@ #!/bin/bash -source $(dirname "$(readlink -f "$0")")/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh +PWR=$(source $SRC/utils/checkpwr.sh) PKG="emerge" printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "syncing: starting" -$PKG --sync +$PWR $PKG --sync printProgress "syncing: completed" printProgress "update: starting" -$PKG --update --deep --newuse --with-bdeps y @world --ask +$PWR $PKG --update --deep --newuse --with-bdeps y @world --ask printProgress "update: completed" printProgress "deepclean: starting" -$PKG --depclean --ask +$PWR $PKG --depclean --ask revdep-rebuild printProgress "deepclean: completed" diff --git a/src/package/rpm.sh b/src/package/rpm.sh index e5d66a0..0bb6a7e 100755 --- a/src/package/rpm.sh +++ b/src/package/rpm.sh @@ -1,7 +1,9 @@ #!/bin/bash -source $(dirname "$(readlink -f "$0")")/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh +PWR=$(source $SRC/utils/checkpwr.sh) PKG="yum" if [[ $(command -v dnf) ]]; then @@ -11,19 +13,19 @@ fi printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "update: starting" -sudo $PKG update +$PWR $PKG update printProgress "update: completed" printProgress "upgrade: starting" -sudo $PKG upgrade +$PWR $PKG upgrade printProgress "upgrade: completed" printProgress "autoremove: starting" -sudo $PKG autoremove +$PWR $PKG autoremove printProgress "autoremove: completed" printProgress "clean all: starting" -sudo $PKG clean all +$PWR $PKG clean all printProgress "clean all: completed" printf "\n" diff --git a/src/package/snap.sh b/src/package/snap.sh index c131562..912d226 100755 --- a/src/package/snap.sh +++ b/src/package/snap.sh @@ -1,9 +1,14 @@ #!/bin/bash +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh + +PWR=$(source $SRC/utils/checkpwr.sh) + printf "${GREEN}\nPackage manager detected: ${RED}Using snap${NORMAL}" printProgress "snap refresh: starting" -sudo snap refresh +$PWR snap refresh printProgress "snap refresh: completed" printf "\n" diff --git a/src/package/termux.sh b/src/package/termux.sh index 78a44cd..2034b53 100755 --- a/src/package/termux.sh +++ b/src/package/termux.sh @@ -1,21 +1,23 @@ #!/bin/bash -source $(dirname "$(readlink -f "$0")")/utils/global.sh +SRC=$(dirname "$(readlink -f "$0")") +source $SRC/utils/global.sh +PWR=$(source $SRC/utils/checkpwr.sh) PKG="pkg" printf "${GREEN}\nPackage manager detected: ${RED}Using $PKG${NORMAL}" printProgress "update: starting" -$PKG update +$PWR $PKG update printProgress "update: completed" printProgress "upgrade: starting" -$PKG upgrade +$PWR $PKG upgrade printProgress "upgrade: completed" printProgress "autoclean: starting" -$PKG autoclean +$PWR $PKG autoclean printProgress "autoclean: completed" printf "\n" diff --git a/src/utils/checkpwr.sh b/src/utils/checkpwr.sh new file mode 100755 index 0000000..755810d --- /dev/null +++ b/src/utils/checkpwr.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +PWR="" +if [[ $(grep -c "utils/privileges" $(dirname "$(readlink -f "$0")")/utils/.cache) -gt 0 ]]; then + PWR="sudo" +fi + +echo "$PWR" \ No newline at end of file From 4ca368f8e0005ade9cdae1ae301603535c7e788e Mon Sep 17 00:00:00 2001 From: Roberto Date: Wed, 23 Jun 2021 18:56:53 +0200 Subject: [PATCH 08/10] Update indentation tabs --- src/updater.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/updater.sh b/src/updater.sh index 61750a4..a63c5ae 100755 --- a/src/updater.sh +++ b/src/updater.sh @@ -11,7 +11,7 @@ if [[ -f "$SRC/utils/.cache" ]]; then else $SRC/utils/cachegen.sh > $SRC/utils/.cache md5sum $SRC/utils/.cache | cut -d " " -f1 > $SRC/utils/.md5 - chmod 775 $SRC/utils/.cache + chmod 775 $SRC/utils/.cache fi chmod 775 $SRC/utils/.md5 @@ -23,7 +23,7 @@ printf "Running on: $(uname -rs)\n$NORMAL" while read line; do if [[ "$line" != "" ]]; then - source $SRC/$line.sh; + source $SRC/$line.sh; fi done < $SRC/utils/.cache From 4441743d6adeba3c6702f5075903e3caadfdb1de Mon Sep 17 00:00:00 2001 From: Roberto Date: Wed, 23 Jun 2021 19:01:54 +0200 Subject: [PATCH 09/10] Fix colour It was printing without colours. --- setup.sh | 2 +- uninstall.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index fdb63bf..8950c95 100755 --- a/setup.sh +++ b/setup.sh @@ -12,7 +12,7 @@ EXST=$(cat ~/.bashrc | grep -c "updater.sh") if [[ $EXST -ne 0 ]]; then printProgress "Alias 'up' already exists. Use 'up' or run './src/updater.sh'." printProgress "Setup completed." - exit 0 + exit 0 else echo "alias up='bash $(pwd)/src/updater.sh'" >> ~/.bashrc chmod +x src/updater.sh diff --git a/uninstall.sh b/uninstall.sh index 171ff32..83c56fa 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,7 @@ source src/utils/global.sh sed -i "/alias up=/d" ~/.bashrc printf "Alias 'up' removed\n" -printf "\nUninstallation completed\n" +printf "\n${RED}Uninstallation completed\n" read -p "Press enter, the process will be killed.\nIf your terminal closes, open a new one." text printf "${NORMAL}" From 5259350fff87fab5e88821d9cfdcbf3df33cef29 Mon Sep 17 00:00:00 2001 From: Roberto Date: Wed, 23 Jun 2021 19:09:46 +0200 Subject: [PATCH 10/10] Fix string --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 83c56fa..ee8a282 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -7,7 +7,7 @@ printf "Alias 'up' removed\n" printf "\n${RED}Uninstallation completed\n" -read -p "Press enter, the process will be killed.\nIf your terminal closes, open a new one." text +read -p "Press enter, the process will be killed.If your terminal closes, open a new one." text printf "${NORMAL}" kill -9 $PPID