Space saving and auto updater enable prompt

This commit is contained in:
TotallyNotElite 2018-12-01 16:04:15 +01:00
parent 2bf8be8ab9
commit bc074ab3b8
9 changed files with 49 additions and 39 deletions

2
.gitignore vendored
View File

@ -282,3 +282,5 @@ cathook.cbp
\.kdev4/cathook\.kdev4
cathook\.kdev4
scripts/updater-preferences

View File

@ -41,7 +41,7 @@ and a lot of useful features, including
## Automatic: (Ubuntu 17.10+/Arch based only)
Run in terminal:
* `wget https://raw.githubusercontent.com/nullworks/One-in-all-cathook-install/master/install-all && bash install-all`
* `wget -O - https://raw.githubusercontent.com/nullworks/One-in-all-cathook-install/master/install-all | bash`
## Manual:
You need CMake to build cathook, CMake should take care of dependencies

3
attach
View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
sudo ./scripts/auto-updater
line=$(pidof hl2_linux)
arr=($line)
inst=$1
@ -58,5 +59,3 @@ rm $FILENAME
sudo killall -18 steamwebhelper
sudo killall -18 steam
sudo ./scripts/auto-updater &

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
sudo ./scripts/auto-updater
line=$(pidof hl2_linux)
arr=($line)
inst=$1
@ -57,8 +58,6 @@ gdb -n -q -batch \
sudo killall -18 steamwebhelper
sudo killall -18 steam
sudo ./scripts/auto-updater &
gdb -n -q -batch \
-ex "attach $proc" \
-ex "continue" \

View File

@ -3,6 +3,7 @@
# Thank you LWSS
# https://github.com/LWSS/Fuzion/commit/a53b6c634cde0ed47b08dd587ba40a3806adf3fe
sudo ./scripts/auto-updater
line=$(pidof hl2_linux)
arr=($line)
inst=$1
@ -61,5 +62,3 @@ sudo gdb -n -q -batch \
-ex "quit"
sudo rm "/lib/i386-linux-gnu/${FILENAME}"
sudo ./scripts/auto-updater &

View File

@ -5,8 +5,6 @@ if [ $EUID == 0 ]; then
exit
fi
rm ../install-all # remove install file
#
# Install base Dependencies
#
@ -21,9 +19,8 @@ fi
# Update cathook
#
git fetch # fetch github repo for udpates
git pull origin # pull changes from github
git submodule update --init --recursive # update/init submodules
git pull --depth 1 origin # pull changes from github
git submodule update --depth 1 --init --recursive # update/init submodules
#
# Build cathook

View File

@ -1,29 +1,14 @@
#!/usr/bin/env bash
LOCKFILE=/tmp/chupdater.lock
if [ -e ${LOCKFILE} ] && ps -p `cat ${LOCKFILE}` >/dev/null; then
echo -e "\033[1;31m \n \nAuto Updater: Auto Updater already running in the background\n\033[0m"
exit 1
if [ ! -f ./scripts/updater-preferences ]; then
while true; do
read -p "Do you wan't to enable the cathook auto updater? y/n " yn
case $yn in
[Yy]* ) echo true > ./scripts/updater-preferences; break;;
[Nn]* ) echo false > ./scripts/updater-preferences; exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
echo -e "\033[1;34m \n \nAuto Updater: Updating cathook in the background\n\033[0m"
sudo -u $LOGNAME bash -c 'git fetch && git pull origin >/dev/null && git submodule update --init --recursive >/dev/null' || { echo -e "\033[1;31m \n \nAuto Updater: Failed to pull from github!\n\033[0m"; exit 1; }
pushd build >/dev/null || exit 1
if [ $(id -u) -eq 0 ]; then
cmake --build . --target data >/dev/null || { echo -e "\033[1;31m \n \nAuto Updater:Failed to update /opt/cathook/data directory\n\033[0m"; exit 1; }
if [ `cat ./scripts/updater-preferences` == "true" ]; then
./scripts/run-update &
fi
sudo -u $LOGNAME bash -c 'cmake .. >/dev/null && nice -n 10 cmake --build . --target cathook -- -j 1 >/dev/null' || { echo -e "\033[1;31m \n \nAuto Updater: Failed to compile cathook\n\033[0m"; exit 1; }
rm -f ${LOCKFILE}
popd >/dev/null
echo -e "\n\n\033[1;34mAuto Updater: Cathook updated successfully\033[0m" && exit 0

29
scripts/run-updater Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
LOCKFILE=/tmp/chupdater.lock
if [ -e ${LOCKFILE} ] && ps -p `cat ${LOCKFILE}` >/dev/null; then
echo -e "\033[1;31m \n \nAuto Updater: Auto Updater already running in the background\n\033[0m"
exit 1
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
echo -e "\033[1;34m \n \nAuto Updater: Updating cathook in the background\n\033[0m"
sudo -u $LOGNAME bash -c 'git pull --depth 1 origin >/dev/null && git submodule update --depth 1 --init --recursive >/dev/null' || { echo -e "\033[1;31m \n \nAuto Updater: Failed to pull from github!\n\033[0m"; exit 1; }
pushd build >/dev/null || exit 1
if [ $(id -u) -eq 0 ]; then
cmake --build . --target data >/dev/null || { echo -e "\033[1;31m \n \nAuto Updater:Failed to update /opt/cathook/data directory\n\033[0m"; exit 1; }
fi
sudo -u $LOGNAME bash -c 'cmake .. >/dev/null && nice -n 10 cmake --build . --target cathook -- -j 1 >/dev/null' || { echo -e "\033[1;31m \n \nAuto Updater: Failed to compile cathook\n\033[0m"; exit 1; }
rm -f ${LOCKFILE}
popd >/dev/null
echo -e "\n\n\033[1;34mAuto Updater: Cathook updated successfully\033[0m" && exit 0

2
update
View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
#Get updated source code
git fetch && git pull origin && git submodule update --init --recursive || { echo -e "\033[1;31m \n \nFailed to pull from github!"; exit 1; }
git pull --depth 1 origin && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;31m \n \nFailed to pull from github!"; exit 1; }
#Update cathook
cd build && cmake .. && cmake --build . --target cathook -- -j$(grep -c '^processor' /proc/cpuinfo) || { echo -e "\033[1;31m \n \nFailed to compile cathook"; exit 1; }
#Update data