commit
29e70db8ef
14
install-all
14
install-all
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
RUNUSER="sudo -u $LOGNAME"
|
||||
[[ ! -z "$SUDO_USER" ]] && RUNUSER="$SUDO_USER" || RUNUSER="$LOGNAME"
|
||||
RUNCMD="sudo -u $RUNUSER"
|
||||
|
||||
set -e
|
||||
|
||||
@ -11,21 +12,18 @@ set -e
|
||||
# Update cathook
|
||||
#
|
||||
if [ ! -d "./.git" ]; then
|
||||
$RUNUSER git init
|
||||
$RUNUSER git remote add origin https://github.com/nullworks/cathook
|
||||
$RUNCMD git init
|
||||
$RUNCMD git remote add origin https://github.com/nullworks/cathook
|
||||
fi
|
||||
|
||||
$RUNUSER git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && $RUNUSER git reset --hard latest # pull changes from github
|
||||
$RUNUSER git submodule update --depth 1 --init --recursive # update/init submodules
|
||||
|
||||
#
|
||||
# Set config version for update script
|
||||
#
|
||||
|
||||
$RUNUSER bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 1"
|
||||
$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 1"
|
||||
|
||||
#
|
||||
# Build cathook
|
||||
#
|
||||
|
||||
$RUNUSER ./scripts/updater false true
|
||||
$RUNCMD ./scripts/updater false true
|
||||
|
@ -2,55 +2,58 @@
|
||||
|
||||
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)
|
||||
fedora_packages=(cmake dialog make gcc-c++ glibc-devel.i686 freetype-devel.i686 SDL2-devel.i686 glew-devel.i686 boost-devel.i686 rsync gdb git)
|
||||
|
||||
if [ -x "$(command -v pacman)" ]; then
|
||||
function requestPermissions {
|
||||
string=$@
|
||||
# Prefer GUI question
|
||||
if [ -x "$(command -v zenity)" ] && xset q &>/dev/null; then
|
||||
zenity --no-wrap --question --text="Do you want to install the following packages required for cathook?\n${string}?"
|
||||
out=$?
|
||||
if [ "$out" != 0 ]; then
|
||||
exit
|
||||
fi
|
||||
# Fall back to terminal
|
||||
elif [ -t 0 ]; then
|
||||
read -p "Do you want to install the following packages required for cathook? ${string} y/n " -r
|
||||
if ! [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo -e "\033[1;33m\nWarning! Automatic package installation is not supported! Zenity+XOrg or interactive terminal required!\n\033[0m"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine distro
|
||||
OSR="$(awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)"
|
||||
if [[ ("$OSR" == "manjaro" || "$OSR" == "arch") && -x "$(command -v pacman)" ]]; then
|
||||
OS="arch"
|
||||
elif [ "$OSR" == "ubuntu" ] && [ -x "$(command -v apt-get)" ]; then
|
||||
OS="ubuntu"
|
||||
elif [ "$OSR" == "fedora" ] && [ -x "$(command -v dnf)" ] && [ -x "$(command -v rpm)" ]; then
|
||||
OS="fedora"
|
||||
elif [ -x "$(command -v pacman)" ]; then
|
||||
OS="arch"
|
||||
elif [ -x "$(command -v apt-get)" ]; then
|
||||
OS="ubuntu"
|
||||
elif [ -x "$(command -v dnf)" ] && [ -x "$(command -v rpm)" ]; then
|
||||
OS="fedora"
|
||||
fi
|
||||
|
||||
if [ "$OS" == "arch" ]; then
|
||||
pacman -Qi "${arch_packages[@]}" > /dev/null 2>&1
|
||||
out=$?
|
||||
if [ "$out" == 1 ]; then
|
||||
string=${arch_packages[@]}
|
||||
# Prefer GUI question
|
||||
if [ -x "$(command -v zenity)" ] && xset q &>/dev/null; then
|
||||
zenity --no-wrap --question --text="Do you want to install the following packages required for cathook?\n${string}?"
|
||||
out=$?
|
||||
if [ "$out" != 0 ]; then
|
||||
exit
|
||||
fi
|
||||
# Fall back to terminal
|
||||
elif [ -t 0 ]; then
|
||||
read -p "Do you want to install the following packages required for cathook? ${string} y/n " -r
|
||||
if ! [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo -e "\033[1;33m\nWarning! Automatic package installation is not supported! Zenity+XOrg or interactive terminal required!\n\033[0m"
|
||||
exit
|
||||
fi
|
||||
requestPermissions "${arch_packages[@]}"
|
||||
sudo pacman -S --noconfirm --needed "${arch_packages[@]}"
|
||||
fi
|
||||
elif [ -x "$(command -v apt-get)" ]; then
|
||||
elif [ "$OS" == "ubuntu" ]; then
|
||||
dpkg -s "${ubuntu_packages[@]}" > /dev/null 2>&1
|
||||
out=$?
|
||||
if [ "$out" == 1 ]; then
|
||||
string=${ubuntu_packages[@]}
|
||||
# Prefer GUI question
|
||||
if [ -x "$(command -v zenity)" ] && xset q &>/dev/null; then
|
||||
zenity --no-wrap --question --text="Do you want to install the following packages required for cathook?\n${string}?"
|
||||
out=$?
|
||||
if [ "$out" != 0 ]; then
|
||||
exit
|
||||
fi
|
||||
# Fall back to terminal
|
||||
elif [ -t 0 ]; then
|
||||
read -p "Do you want to install the following packages required for cathook? ${string} y/n " -r
|
||||
if ! [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo -e "\033[1;33m\nWarning! Automatic package installation is not supported! Zenity+XOrg or interactive terminal required!\n\033[0m"
|
||||
exit
|
||||
fi
|
||||
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
|
||||
@ -58,6 +61,13 @@ elif [ -x "$(command -v apt-get)" ]; then
|
||||
sudo apt-get update
|
||||
sudo 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[@]}
|
||||
fi
|
||||
else
|
||||
echo -e "\033[1;33m\nWarning! Automatic package installation is not supported!\n\033[0m"
|
||||
fi
|
||||
|
@ -22,12 +22,12 @@ fi
|
||||
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
|
||||
echo $$ > ${LOCKFILE}
|
||||
|
||||
#Check if all required packages are installed
|
||||
./scripts/dependencycheck
|
||||
|
||||
# Run migrations
|
||||
./scripts/migrations "$@" || exit 0
|
||||
|
||||
#Check if all required packages are installed
|
||||
./scripts/dependencycheck
|
||||
|
||||
. ./scripts/config.shlib
|
||||
|
||||
tui=true
|
||||
|
Reference in New Issue
Block a user