From 68b807c5631f46310db8a6e1f7493473897e0210 Mon Sep 17 00:00:00 2001 From: Kurtis Andrews Date: Fri, 8 Nov 2024 20:26:05 +1000 Subject: [PATCH] Update changed app to prompt for sudo instead of running as sudo --- vargtools | 200 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 102 insertions(+), 98 deletions(-) diff --git a/vargtools b/vargtools index 526f849..86d16a1 100644 --- a/vargtools +++ b/vargtools @@ -3,32 +3,36 @@ # Debian XFCE init and setup # Check for sudo access -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit +if [[ $(id -u) = 0 ]]; then + echo "Please run as normal user" + exit fi +sudoFunc () { + + # Must be running as sudo + if [[ $(id -u) != 0 ]]; then + echo "Sudo authentication failed. Please try again" + exit + fi +} + +# Prompt for elevated prompt for scripts + +FUNC=$(declare -f sudoFunc) +sudo -H bash -c "$FUNC; sudoFunc $*;" + user_home=$(sudo -u $SUDO_USER sh -c 'echo $HOME') app_version=24101008 init_version=0 base_repo=https://git.tcmeta.net/kurtis -# Depriv - -depriv() { - if [[ $SUDO_USER ]]; then - sudo -u "$SUDO_USER" -- "$@" - else - "$@" - fi -} - start() { if [ -f /etc/vargtools/init ]; then init_version=$( /etc/vargtools/init + sudo mkdir -p /etc/vargtools + sudo echo "0" > /etc/vargtools/init fi if [ "$init_version" -lt "$app_version" ]; then menuItems=( @@ -156,18 +160,18 @@ doInit() { logo if [ "$init_version" -lt 24092720 ]; then echo Removing cdrom from apt - sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list - apt update + sudo sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list + sudo apt update echo Installing base software - apt install -y git python3 python3-pip pipx stow btop duf + sudo apt install -y git python3 python3-pip pipx stow btop duf echo installing console python apps - depriv pipx ensurepath - depriv pipx install thefuck - depriv pipx install sshch + pipx ensurepath + pipx install thefuck + pipx install sshch fi if [ "$init_version" -lt 24101008 ]; then echo installing file explorer backend - apt install -y gvfs-backends + sudo apt install -y gvfs-backends fi echo "$app_version" > /etc/vargtools/init echo Should be all upto date now .. press any key to continue @@ -178,8 +182,8 @@ doInit() { updateVargtools() { logo echo [vargtools] Updating - wget "$base_repo/vargtools/raw/branch/main/vargtools" -O /usr/local/bin/vargtools - chmod +x /usr/local/bin/vargtools + sudo wget "$base_repo/vargtools/raw/branch/main/vargtools" -O /usr/local/bin/vargtools + sudo chmod +x /usr/local/bin/vargtools echo [vargtools] Done, restarting exec /usr/local/bin/vargtools } @@ -188,7 +192,7 @@ setTcmetaKey() { logo echo [TCMeta] please enter the git key read -r key - echo $key > /etc/vargtools/tcmeta + sudo echo $key > /etc/vargtools/tcmeta echo [TCMeta] Key Applied return 1 } @@ -197,91 +201,91 @@ installChicago95() { logo echo [Chicago95] Installing prereqs wget "https://github.com/MerkeX/Lightdm-webkit2-greeter/releases/download/v2.2.5-1/lightdm-webkit2-greeter_2.2.5-1_amd64.deb" -O /tmp/lightdm-webkit2-greeter.deb - apt install -y /tmp/lightdm-webkit2-greeter.deb + sudo apt install -y /tmp/lightdm-webkit2-greeter.deb rm /tmp/lightdm-webkit2-greeter.deb - apt install -y xfce4-panel-profiles gnome-session-canberra sox libcanberra-gtk3-module libcanberra-gtk-module dbus-x11 + sudo apt install -y xfce4-panel-profiles gnome-session-canberra sox libcanberra-gtk3-module libcanberra-gtk-module dbus-x11 echo [Chicago95] Downloading theme - depriv git clone https://github.com/grassmunk/Chicago95.git /tmp/Chicago95 + git clone https://github.com/grassmunk/Chicago95.git /tmp/Chicago95 echo [Chicago95] Installing system wide - cp -r /tmp/Chicago95/Theme/Chicago95 /usr/share/themes/ - cp -r /tmp/Chicago95/Icons/* /usr/share/icons/ - cp -v /tmp/Chicago95/Fonts/vga_font/LessPerfectDOSVGA.ttf /usr/share/fonts - cp -r /tmp/Chicago95/Fonts/bitmap/cronyx-cyrillic /usr/share/fonts + sudo cp -r /tmp/Chicago95/Theme/Chicago95 /usr/share/themes/ + sudo cp -r /tmp/Chicago95/Icons/* /usr/share/icons/ + sudo cp -v /tmp/Chicago95/Fonts/vga_font/LessPerfectDOSVGA.ttf /usr/share/fonts + sudo cp -r /tmp/Chicago95/Fonts/bitmap/cronyx-cyrillic /usr/share/fonts echo [Chicago95] Installing fonts - mv /etc/fonts/conf.d/70-no-bitmaps.conf /etc/fonts/conf.d/70-no-bitmaps.conf.bak - fc-cache -fv + sudo mv /etc/fonts/conf.d/70-no-bitmaps.conf /etc/fonts/conf.d/70-no-bitmaps.conf.bak + sudo fc-cache -fv echo [Chicago95] Installing Login Screen - sed -i 's/\#greeter-session/greeter-session/g' /etc/lightdm/lightdm.conf - sed -i 's/\#user-session/user-session/g' /etc/lightdm/lightdm.conf - sed -i -e "s/\(greeter-session *= *\).*/\1lightdm-webkit2-greeter/" /etc/lightdm/lightdm.conf - sed -i -e "s/\(user-session *= *\).*/\1xfce/" /etc/lightdm/lightdm.conf - cp -r /tmp/Chicago95/Lightdm/Chicago95 /usr/share/lightdm-webkit/themes/ + sudo sed -i 's/\#greeter-session/greeter-session/g' /etc/lightdm/lightdm.conf + sudo sed -i 's/\#user-session/user-session/g' /etc/lightdm/lightdm.conf + sudo sed -i -e "s/\(greeter-session *= *\).*/\1lightdm-webkit2-greeter/" /etc/lightdm/lightdm.conf + sudo sed -i -e "s/\(user-session *= *\).*/\1xfce/" /etc/lightdm/lightdm.conf + sudo cp -r /tmp/Chicago95/Lightdm/Chicago95 /usr/share/lightdm-webkit/themes/ echo [Chicago95] Generating Config - echo "#" > /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# [greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# debug_mode = Greeter theme debug mode." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# detect_theme_errors = Provide an option to load a fallback theme when theme errors are detected." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# screensaver_timeout = Blank the screen after this many seconds of inactivity." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# secure_mode = Don't allow themes to make remote http requests." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# time_format = A moment.js format string so the greeter can generate localized time for display." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# time_language = Language to use when displaying the time or "auto" to use the system's language." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# webkit_theme = Webkit theme to use." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# NOTE: See moment.js documentation for format string options: http://momentjs.com/docs/#/displaying/format/" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "[greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "debug_mode = false" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "detect_theme_errors = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "screensaver_timeout = 300" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "secure_mode = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "time_format = LT" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "time_language = auto" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "webkit_theme = Chicago95" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# [branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# background_images = Path to directory that contains background images for use by themes." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# logo = Path to logo image for use by greeter themes." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# user_image = Default user image/avatar. This is used by themes for users that have no .face image." >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "# NOTE: Paths must be accessible to the lightdm system user account (so they cannot be anywhere in /home)" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "[branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "background_images = /usr/share/backgrounds" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "logo = /usr/share/lightdm-webkit/themes/antergos/img/antergos.png" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "user_image = /usr/share/lightdm-webkit/themes/antergos/img/antergos-logo-user.png" >> /etc/lightdm/lightdm-webkit2-greeter.conf - echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" > /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# [greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# debug_mode = Greeter theme debug mode." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# detect_theme_errors = Provide an option to load a fallback theme when theme errors are detected." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# screensaver_timeout = Blank the screen after this many seconds of inactivity." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# secure_mode = Don't allow themes to make remote http requests." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# time_format = A moment.js format string so the greeter can generate localized time for display." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# time_language = Language to use when displaying the time or "auto" to use the system's language." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# webkit_theme = Webkit theme to use." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# NOTE: See moment.js documentation for format string options: http://momentjs.com/docs/#/displaying/format/" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "[greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "debug_mode = false" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "detect_theme_errors = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "screensaver_timeout = 300" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "secure_mode = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "time_format = LT" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "time_language = auto" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "webkit_theme = Chicago95" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# [branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# background_images = Path to directory that contains background images for use by themes." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# logo = Path to logo image for use by greeter themes." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# user_image = Default user image/avatar. This is used by themes for users that have no .face image." >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "# NOTE: Paths must be accessible to the lightdm system user account (so they cannot be anywhere in /home)" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "[branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "background_images = /usr/share/backgrounds" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "logo = /usr/share/lightdm-webkit/themes/antergos/img/antergos.png" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "user_image = /usr/share/lightdm-webkit/themes/antergos/img/antergos-logo-user.png" >> /etc/lightdm/lightdm-webkit2-greeter.conf + sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf echo [Chicago95] Installing boot screen - cp -r /tmp/Chicago95/Plymouth/Chicago95 /usr/share/plymouth/themes/ - cp -r /tmp/Chicago95/Plymouth/RetroTux /usr/share/plymouth/themes/ - plymouth-set-default-theme -R Chicago95 + sudo cp -r /tmp/Chicago95/Plymouth/Chicago95 /usr/share/plymouth/themes/ + sudo cp -r /tmp/Chicago95/Plymouth/RetroTux /usr/share/plymouth/themes/ + sudo plymouth-set-default-theme -R Chicago95 echo [Chicago95] Modifying grub - sed -i -e "s/\(GRUB_TIMEOUT *= *\).*/\10/" /etc/default/grub - sed -i 's/\quiet/quiet splash/g' /etc/default/grub - sed -i 's/\#GRUB_TERMINAL/GRUB_TERMINAL/g' /etc/default/grub + sudo sed -i -e "s/\(GRUB_TIMEOUT *= *\).*/\10/" /etc/default/grub + sudo sed -i 's/\quiet/quiet splash/g' /etc/default/grub + sudo sed -i 's/\#GRUB_TERMINAL/GRUB_TERMINAL/g' /etc/default/grub echo [Chicago95] Updating Grub - update-grub2 + sudo update-grub2 echo [Chicago95] Running Client installer - depriv python3 /tmp/Chicago95/installer.py + python3 /tmp/Chicago95/installer.py read -n 1 echo [Chicago95] Installing startup sound / wallpapers - depriv cp "/tmp/Chicago95/Extras/Microsoft Windows 95 Startup Sound.ogg" "$user_home/.themes/Chicago95/misc/Microsoft Windows 95 Startup Sound.ogg" - depriv mkdir -p $user_home/.config/autostart - depriv echo "[Desktop Entry]" > "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Encoding=UTF-8" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Version=0.9.4" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Type=Application" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Name=Windows Logon Sound" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Comment=Plays the windows 95 logon music" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Exec=play \"$user_home/.themes/Chicago95/misc/Microsoft Windows 95 Startup Sound.ogg\"" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "OnlyShowIn=XFCE;" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "RunHook=0" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "StartupNotify=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Terminal=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv echo "Hidden=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" - depriv cp -r /tmp/Chicago95/Extras/Backgrounds $user_home/.themes/Chicago95/misc + cp "/tmp/Chicago95/Extras/Microsoft Windows 95 Startup Sound.ogg" "$user_home/.themes/Chicago95/misc/Microsoft Windows 95 Startup Sound.ogg" + mkdir -p $user_home/.config/autostart + echo "[Desktop Entry]" > "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Encoding=UTF-8" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Version=0.9.4" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Type=Application" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Name=Windows Logon Sound" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Comment=Plays the windows 95 logon music" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Exec=play \"$user_home/.themes/Chicago95/misc/Microsoft Windows 95 Startup Sound.ogg\"" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "OnlyShowIn=XFCE;" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "RunHook=0" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "StartupNotify=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Terminal=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + echo "Hidden=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" + cp -r /tmp/Chicago95/Extras/Backgrounds $user_home/.themes/Chicago95/misc echo [Chicago95] Okay done return 1 }