diff --git a/install-all b/install-all index ac0d2444..a71d9ce0 100755 --- a/install-all +++ b/install-all @@ -1,12 +1,9 @@ #!/usr/bin/env bash -[[ ! -z "$SUDO_USER" ]] && RUNUSER="$SUDO_USER" || RUNUSER="$LOGNAME" -RUNCMD="sudo -u $RUNUSER" - set -e # # Build cathook # -$RUNCMD ./scripts/updater false true true +./scripts/updater false true true diff --git a/scripts/dependencycheck b/scripts/dependencycheck index 6712d265..aad5fdd5 100755 --- a/scripts/dependencycheck +++ b/scripts/dependencycheck @@ -3,6 +3,7 @@ # $1 Git only GIT=${1:-false} +SUDO=${CH_SUDO:-sudo} arch_packages=(git boost cmake make gcc gdb lib32-sdl2 lib32-glew lib32-freetype2 rsync lib32-libglvnd dialog) ubuntu_packages=(software-properties-common build-essential git g++ g++-multilib libboost-all-dev gdb libsdl2-dev:i386 libglew-dev:i386 libfreetype6-dev:i386 cmake dialog rsync) @@ -58,26 +59,21 @@ if [ "$OS" == "arch" ]; then out=$? if [ "$out" == 1 ]; then requestPermissions "${arch_packages[@]}" - sudo pacman -S --noconfirm --needed "${arch_packages[@]}" + $SUDO pacman -S --noconfirm --needed "${arch_packages[@]}" fi elif [ "$OS" == "ubuntu" ]; then dpkg -s "${ubuntu_packages[@]}" > /dev/null 2>&1 out=$? if [ "$out" == 1 ]; then requestPermissions "${ubuntu_packages[@]}" - sudo apt-get update - sudo apt-get install -y software-properties-common - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install -y "${ubuntu_packages[@]}" + $SUDO bash -c "apt-get update;apt-get install -y software-properties-common;add-apt-repository ppa:ubuntu-toolchain-r/test -y;dpkg --add-architecture i386;apt-get update;apt-get install -y "${ubuntu_packages[@]}"" fi elif [ "$OS" == "fedora" ]; then rpm -q "${fedora_packages[@]}" > /dev/null 2>&1 out=$? if [ "$out" != 0 ]; then requestPermissions "${fedora_packages[@]}" - sudo dnf install -y ${fedora_packages[@]} + $SUDO dnf install -y ${fedora_packages[@]} fi else echo -e "\033[1;33m\nWarning! Automatic package installation is not supported!\n\033[0m" diff --git a/scripts/updater b/scripts/updater index 6bce489c..ab5082ee 100755 --- a/scripts/updater +++ b/scripts/updater @@ -8,6 +8,8 @@ AUTO_UPDATER_ENABLED=${1:-false} DISABLE_TUI=${2:-false} INIT=${3:-false} +SUDO=${CH_SUDO:-sudo} + set -e configfile="./scripts/updater-preferences" @@ -150,7 +152,7 @@ function performupdate() { # Update cathook pushd build && cmake .. && cmake --build . --target cathook -- -j$proccount || { echo -e "\033[1;31m \n \nFailed to compile cathook\n\033[0m"; exit 1; } # Update data - cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory! Trying with root rights!\n\033[0m"; sudo cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory\n\033[0m"; exit 1; } } + cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory! Trying with root rights!\n\033[0m"; $SUDO cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory\n\033[0m"; exit 1; } } popd echo -e "\n\033[1;34mCathook updated successfully\n\033[0m" rm -f ${LOCKFILE} diff --git a/update b/update index 8e33d524..a8f8236d 100755 --- a/update +++ b/update @@ -1,3 +1,2 @@ #!/usr/bin/env bash -RUNUSER="sudo -u $LOGNAME" -$RUNUSER bash ./scripts/updater +./scripts/updater