From 51485562ecd5276550f4e0832ecd1b0ffa8bff8b Mon Sep 17 00:00:00 2001 From: clsty Date: Tue, 11 Feb 2025 22:07:55 +0800 Subject: [PATCH 1/2] Prevent sudo (#1109) --- diagnose | 4 ++++ manual-install-helper.sh | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/diagnose b/diagnose index 0bf96e9bd..b073353c4 100755 --- a/diagnose +++ b/diagnose @@ -6,6 +6,10 @@ cd "$(dirname "$0")";export base="$(pwd)" output_file=diagnose.result;rm $output_file export LANG=C;export LC_ALL=C +case $(whoami) in + root)echo -e "\e[31m[$0]: This script is NOT to be executed with sudo or as root. Aborting...\e[0m";exit 1;; +esac + x() { ii_exec "$@" 2>&1 | tee -a $output_file ; } e() { ii_box "$@" | tee -a $output_file ; } diff --git a/manual-install-helper.sh b/manual-install-helper.sh index aabfd6943..663f3009a 100755 --- a/manual-install-helper.sh +++ b/manual-install-helper.sh @@ -5,19 +5,20 @@ cd "$(dirname "$0")" export base="$(pwd)" +source ./scriptdata/environment-variables source ./scriptdata/functions source ./scriptdata/installers -source ./scriptdata/environment-variables +prevent_sudo_or_root if command -v pacman >/dev/null 2>&1;then printf "\e[31m[$0]: pacman found, it seems that the system is ArchLinux or Arch-based distro. Aborting...\e[0m\n";exit 1;fi -install-agsv1 -install-Rubik -install-Gabarito -install-OneUI -install-bibata -install-MicroTeX -install-uv -install-python-packages +v install-agsv1 +v install-Rubik +v install-Gabarito +v install-OneUI +v install-bibata +v install-MicroTeX +v install-uv +v install-python-packages if [[ -z "${ILLOGICAL_IMPULSE_VIRTUAL_ENV}" ]]; then printf "\n\e[31m[$0]: \!! Important \!! : Please ensure environment variable \e[0m \$ILLOGICAL_IMPULSE_VIRTUAL_ENV \e[31m is set to proper value (by default \"~/.local/state/ags/.venv\"), or AGS config will not work. We have already provided this configuration in ~/.config/hypr/hyprland/env.conf, but you need to ensure it is included in hyprland.conf, and also a restart is needed for applying it.\e[0m\n" From 33983fbc2e2c560e9f3c6c22e91cdff7461284a7 Mon Sep 17 00:00:00 2001 From: clsty Date: Tue, 11 Feb 2025 22:10:01 +0800 Subject: [PATCH 2/2] Prevent sudo --- uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index 68ab595a9..a2fbbfcc2 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash cd "$(dirname "$0")" source ./scriptdata/environment-variables +source ./scriptdata/functions +prevent_sudo_or_root function v() { echo -e "[$0]: \e[32mNow executing:\e[0m"