From 16bf930901c8eb9d2af198938e34adb67dadd67d Mon Sep 17 00:00:00 2001 From: OBJNULL Date: Sun, 10 May 2026 02:18:32 -0500 Subject: [PATCH] Priv check & home directory --- install.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 2c51b92..ed7914f 100755 --- a/install.sh +++ b/install.sh @@ -82,6 +82,21 @@ function getFlatpak { displayCmd "flatpak install -y $1" "Installing (flatpak) $1" } +# --- Priv Check --- +if [ $EUID -ne 0 ]; then + displayTitle "FATAL ERROR" + echo -e "Please run the script with $(styleColor "cyan")\`sudo\`$(styleColorRst) or login as $(styleColor "cyan")root$(styleColorRst).\n" + exit +fi + +# --- Variables --- +HOMEDIR="" +if [ -n "$SUDO_USER" ]; then + HOMEDIR="/home/${SUDO_USER}" +else + HOMEDIR="$HOME" +fi + # --- Entry Point --- displayTitle "OBJNULL Dotfile Installer" @@ -120,8 +135,8 @@ getPackage "yazi helix lazygit iamb" # --- Configurations --- displayTitle "Configurations" -displayCmd "mkdir ~/.config" "Creating config directory" -displayCmd "cp -r .config ${PWD}/.config" "Installing configs" -displayCmd "cp .bashrc ${PWD}/.bashrc" "Installing bash profile" -displayCmd "cp -r Pictures ${PWD}/Pictures" "Installing pictures" -displayCmd "cp -r /etc/xdg/quickshell ${PWD}/.config/." "Installing quickshell config" +displayCmd "mkdir ${HOMEDIR}/.config" "Creating config directory" +displayCmd "cp -r .config ${HOMEDIR}/.config" "Installing configs" +displayCmd "cp .bashrc ${HOMEDIR}/.bashrc" "Installing bash profile" +displayCmd "cp -r Pictures ${HOMEDIR}/Pictures" "Installing pictures" +displayCmd "cp -r /etc/xdg/quickshell ${HOMEDIR}/.config/." "Installing quickshell config"