Skip to content
Permalink
Browse files

Allow custom sudo command via env vars

  • Loading branch information
TotallyNotElite committed Feb 12, 2020
1 parent 23c4614 commit d1ad70125a01d4b8717e7a23def67287d83eea60
Showing with 9 additions and 15 deletions.
  1. +1 −4 install-all
  2. +4 −8 scripts/dependencycheck
  3. +3 −1 scripts/updater
  4. +1 −2 update
@@ -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
@@ -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"
@@ -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}
3 update
@@ -1,3 +1,2 @@
#!/usr/bin/env bash
RUNUSER="sudo -u $LOGNAME"
$RUNUSER bash ./scripts/updater
./scripts/updater

0 comments on commit d1ad701

Please sign in to comment.
You can’t perform that action at this time.