changed app to prompt for sudo instead of running as sudo
This commit is contained in:
2024-11-08 20:26:05 +10:00
parent a2ef9d78f4
commit 68b807c563

200
vargtools
View File

@@ -3,32 +3,36 @@
# Debian XFCE init and setup # Debian XFCE init and setup
# Check for sudo access # Check for sudo access
if [ "$EUID" -ne 0 ] if [[ $(id -u) = 0 ]]; then
then echo "Please run as root" echo "Please run as normal user"
exit exit
fi 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') user_home=$(sudo -u $SUDO_USER sh -c 'echo $HOME')
app_version=24101008 app_version=24101008
init_version=0 init_version=0
base_repo=https://git.tcmeta.net/kurtis base_repo=https://git.tcmeta.net/kurtis
# Depriv
depriv() {
if [[ $SUDO_USER ]]; then
sudo -u "$SUDO_USER" -- "$@"
else
"$@"
fi
}
start() { start() {
if [ -f /etc/vargtools/init ]; then if [ -f /etc/vargtools/init ]; then
init_version=$(</etc/vargtools/init) init_version=$(</etc/vargtools/init)
else else
mkdir -p /etc/vargtools sudo mkdir -p /etc/vargtools
echo "0" > /etc/vargtools/init sudo echo "0" > /etc/vargtools/init
fi fi
if [ "$init_version" -lt "$app_version" ]; then if [ "$init_version" -lt "$app_version" ]; then
menuItems=( menuItems=(
@@ -156,18 +160,18 @@ doInit() {
logo logo
if [ "$init_version" -lt 24092720 ]; then if [ "$init_version" -lt 24092720 ]; then
echo Removing cdrom from apt echo Removing cdrom from apt
sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list sudo sed -i "/^deb cdrom:/s/^/#/" /etc/apt/sources.list
apt update sudo apt update
echo Installing base software 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 echo installing console python apps
depriv pipx ensurepath pipx ensurepath
depriv pipx install thefuck pipx install thefuck
depriv pipx install sshch pipx install sshch
fi fi
if [ "$init_version" -lt 24101008 ]; then if [ "$init_version" -lt 24101008 ]; then
echo installing file explorer backend echo installing file explorer backend
apt install -y gvfs-backends sudo apt install -y gvfs-backends
fi fi
echo "$app_version" > /etc/vargtools/init echo "$app_version" > /etc/vargtools/init
echo Should be all upto date now .. press any key to continue echo Should be all upto date now .. press any key to continue
@@ -178,8 +182,8 @@ doInit() {
updateVargtools() { updateVargtools() {
logo logo
echo [vargtools] Updating echo [vargtools] Updating
wget "$base_repo/vargtools/raw/branch/main/vargtools" -O /usr/local/bin/vargtools sudo wget "$base_repo/vargtools/raw/branch/main/vargtools" -O /usr/local/bin/vargtools
chmod +x /usr/local/bin/vargtools sudo chmod +x /usr/local/bin/vargtools
echo [vargtools] Done, restarting echo [vargtools] Done, restarting
exec /usr/local/bin/vargtools exec /usr/local/bin/vargtools
} }
@@ -188,7 +192,7 @@ setTcmetaKey() {
logo logo
echo [TCMeta] please enter the git key echo [TCMeta] please enter the git key
read -r key read -r key
echo $key > /etc/vargtools/tcmeta sudo echo $key > /etc/vargtools/tcmeta
echo [TCMeta] Key Applied echo [TCMeta] Key Applied
return 1 return 1
} }
@@ -197,91 +201,91 @@ installChicago95() {
logo logo
echo [Chicago95] Installing prereqs 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 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 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 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 echo [Chicago95] Installing system wide
cp -r /tmp/Chicago95/Theme/Chicago95 /usr/share/themes/ sudo cp -r /tmp/Chicago95/Theme/Chicago95 /usr/share/themes/
cp -r /tmp/Chicago95/Icons/* /usr/share/icons/ sudo cp -r /tmp/Chicago95/Icons/* /usr/share/icons/
cp -v /tmp/Chicago95/Fonts/vga_font/LessPerfectDOSVGA.ttf /usr/share/fonts sudo 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/Fonts/bitmap/cronyx-cyrillic /usr/share/fonts
echo [Chicago95] Installing fonts echo [Chicago95] Installing fonts
mv /etc/fonts/conf.d/70-no-bitmaps.conf /etc/fonts/conf.d/70-no-bitmaps.conf.bak sudo mv /etc/fonts/conf.d/70-no-bitmaps.conf /etc/fonts/conf.d/70-no-bitmaps.conf.bak
fc-cache -fv sudo fc-cache -fv
echo [Chicago95] Installing Login Screen echo [Chicago95] Installing Login Screen
sed -i 's/\#greeter-session/greeter-session/g' /etc/lightdm/lightdm.conf sudo sed -i 's/\#greeter-session/greeter-session/g' /etc/lightdm/lightdm.conf
sed -i 's/\#user-session/user-session/g' /etc/lightdm/lightdm.conf sudo 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 sudo sed -i -e "s/\(greeter-session *= *\).*/\1lightdm-webkit2-greeter/" /etc/lightdm/lightdm.conf
sed -i -e "s/\(user-session *= *\).*/\1xfce/" /etc/lightdm/lightdm.conf sudo sed -i -e "s/\(user-session *= *\).*/\1xfce/" /etc/lightdm/lightdm.conf
cp -r /tmp/Chicago95/Lightdm/Chicago95 /usr/share/lightdm-webkit/themes/ sudo cp -r /tmp/Chicago95/Lightdm/Chicago95 /usr/share/lightdm-webkit/themes/
echo [Chicago95] Generating Config echo [Chicago95] Generating Config
echo "#" > /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "#" > /etc/lightdm/lightdm-webkit2-greeter.conf
echo "# [greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "# [greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "# debug_mode = Greeter theme debug mode." >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo 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 sudo 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 sudo 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 sudo 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 sudo 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 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
echo "# webkit_theme = Webkit theme to use." >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "# webkit_theme = Webkit theme to use." >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo 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 sudo 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 sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "[greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "[greeter]" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "debug_mode = false" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "debug_mode = false" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "detect_theme_errors = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "detect_theme_errors = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "screensaver_timeout = 300" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "screensaver_timeout = 300" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "secure_mode = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "secure_mode = true" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "time_format = LT" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "time_format = LT" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "time_language = auto" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "time_language = auto" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "webkit_theme = Chicago95" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "webkit_theme = Chicago95" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "# [branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo 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 sudo 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 sudo 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 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
echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo 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 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
echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "#" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "[branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo echo "[branding]" >> /etc/lightdm/lightdm-webkit2-greeter.conf
echo "background_images = /usr/share/backgrounds" >> /etc/lightdm/lightdm-webkit2-greeter.conf sudo 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 sudo 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 sudo 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
echo [Chicago95] Installing boot screen echo [Chicago95] Installing boot screen
cp -r /tmp/Chicago95/Plymouth/Chicago95 /usr/share/plymouth/themes/ sudo cp -r /tmp/Chicago95/Plymouth/Chicago95 /usr/share/plymouth/themes/
cp -r /tmp/Chicago95/Plymouth/RetroTux /usr/share/plymouth/themes/ sudo cp -r /tmp/Chicago95/Plymouth/RetroTux /usr/share/plymouth/themes/
plymouth-set-default-theme -R Chicago95 sudo plymouth-set-default-theme -R Chicago95
echo [Chicago95] Modifying grub echo [Chicago95] Modifying grub
sed -i -e "s/\(GRUB_TIMEOUT *= *\).*/\10/" /etc/default/grub sudo sed -i -e "s/\(GRUB_TIMEOUT *= *\).*/\10/" /etc/default/grub
sed -i 's/\quiet/quiet splash/g' /etc/default/grub sudo sed -i 's/\quiet/quiet splash/g' /etc/default/grub
sed -i 's/\#GRUB_TERMINAL/GRUB_TERMINAL/g' /etc/default/grub sudo sed -i 's/\#GRUB_TERMINAL/GRUB_TERMINAL/g' /etc/default/grub
echo [Chicago95] Updating Grub echo [Chicago95] Updating Grub
update-grub2 sudo update-grub2
echo [Chicago95] Running Client installer echo [Chicago95] Running Client installer
depriv python3 /tmp/Chicago95/installer.py python3 /tmp/Chicago95/installer.py
read -n 1 read -n 1
echo [Chicago95] Installing startup sound / wallpapers 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" 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 mkdir -p $user_home/.config/autostart
depriv echo "[Desktop Entry]" > "$user_home/.config/autostart/Windows Logon Sound.desktop" echo "[Desktop Entry]" > "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv echo "Encoding=UTF-8" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" 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" 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" 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" 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" 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" 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" echo "OnlyShowIn=XFCE;" >> "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv echo "RunHook=0" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" echo "RunHook=0" >> "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv echo "StartupNotify=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" echo "StartupNotify=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv echo "Terminal=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" echo "Terminal=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv echo "Hidden=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop" echo "Hidden=false" >> "$user_home/.config/autostart/Windows Logon Sound.desktop"
depriv cp -r /tmp/Chicago95/Extras/Backgrounds $user_home/.themes/Chicago95/misc cp -r /tmp/Chicago95/Extras/Backgrounds $user_home/.themes/Chicago95/misc
echo [Chicago95] Okay done echo [Chicago95] Okay done
return 1 return 1
} }