diff --git a/attach b/attach index 32b181b1..15b368e1 100755 --- a/attach +++ b/attach @@ -1,9 +1,15 @@ #!/usr/bin/env bash -RUNUSER="sudo -u $(logname)" +RUNUSER="sudo -u $SUDO_USER" + +if [ -z "$SUDO_USER" ]; then + echo This script may not be run without sudo! + exit +fi + $RUNUSER bash ./scripts/updater --autoupdater -line=$(pgrep -u $(logname) hl2_linux) +line=$(pgrep -u $SUDO_USER hl2_linux) arr=($line) inst=$1 if [ $# == 0 ]; then diff --git a/attach-gdb b/attach-gdb index 29cf5932..4d0b3b47 100755 --- a/attach-gdb +++ b/attach-gdb @@ -1,6 +1,12 @@ #!/usr/bin/env bash -RUNUSER="sudo -u $(logname)" +RUNUSER="sudo -u $SUDO_USER" + +if [ -z "$SUDO_USER" ]; then + echo This script may not be run without sudo! + exit +fi + $RUNUSER bash ./scripts/updater --autoupdater line=$(pgrep -u $SUDO_USER hl2_linux) diff --git a/attach-libnamed.sh b/attach-libnamed.sh index 53bfb4b8..b113cf04 100755 --- a/attach-libnamed.sh +++ b/attach-libnamed.sh @@ -3,7 +3,13 @@ # Thank you LWSS # https://github.com/LWSS/Fuzion/commit/a53b6c634cde0ed47b08dd587ba40a3806adf3fe -RUNUSER="sudo -u $(logname)" +RUNUSER="sudo -u $SUDO_USER" + +if [ -z "$SUDO_USER" ]; then + echo This script may not be run without sudo! + exit +fi + $RUNUSER bash ./scripts/updater --autoupdater line=$(pgrep -u $SUDO_USER hl2_linux) diff --git a/install-data b/install-data index b200f103..a0188dc4 100755 --- a/install-data +++ b/install-data @@ -1,14 +1,15 @@ #!/usr/bin/env bash +[[ ! -z "$SUDO_USER" ]] && user=$SUDO_USER || user=$LOGNAME if ! [ -d "/opt/cathook/data" ]; then echo "Creating cathook data directory at /opt/cathook/data" mkdir -p "/opt/cathook/data" - chown -R $USER "/opt/cathook/data" + chown -R $user "/opt/cathook/data" chmod -R 777 "/opt/cathook/data" fi echo "Installing cathook data to /opt/cathook/data" rsync -avh --progress "data/" "/opt/cathook/data" rsync -avh --ignore-existing --progress "config_data/" "/opt/cathook/data" -chown -R $(logname) "/opt/cathook/data" +chown -R $user "/opt/cathook/data" chmod -R 777 "/opt/cathook/data" diff --git a/preload b/preload index 4b4fccd3..31a4d78f 100755 --- a/preload +++ b/preload @@ -4,7 +4,7 @@ if [ $EUID == 0 ]; then echo "This script must not be run as root" exit fi -line=$(pgrep -u $(logname) hl2_linux) +line=$(pgrep -u $LOGNAME hl2_linux) arr=($line) if [ ${#arr[@]} != 0 ]; then @@ -12,7 +12,7 @@ if [ ${#arr[@]} != 0 ]; then exit fi -line=$(pgrep -u $(logname) steam) +line=$(pgrep -u $LOGNAME steam) arr=($line) if [ ${#arr[@]} == 0 ]; then