diff --git a/attach b/attach index f75f3be2..c9d28944 100755 --- a/attach +++ b/attach @@ -58,3 +58,5 @@ rm $FILENAME sudo killall -18 steamwebhelper sudo killall -18 steam + +./scripts/auto-updater & diff --git a/attach-gdb b/attach-gdb index ba742100..dc836cae 100755 --- a/attach-gdb +++ b/attach-gdb @@ -57,6 +57,8 @@ gdb -n -q -batch \ sudo killall -18 steamwebhelper sudo killall -18 steam +./scripts/auto-updater & + gdb -n -q -batch \ -ex "attach $proc" \ -ex "continue" \ diff --git a/attach-libnamed.sh b/attach-libnamed.sh index ed33e5c5..e4487df5 100755 --- a/attach-libnamed.sh +++ b/attach-libnamed.sh @@ -61,3 +61,5 @@ sudo gdb -n -q -batch \ -ex "quit" sudo rm "/lib/i386-linux-gnu/${FILENAME}" + +./scripts/auto-updater & diff --git a/attach-backtrace-scramble.sh b/scripts/attach-backtrace-scramble.sh similarity index 100% rename from attach-backtrace-scramble.sh rename to scripts/attach-backtrace-scramble.sh diff --git a/scripts/auto-updater b/scripts/auto-updater new file mode 100755 index 00000000..61f5fa21 --- /dev/null +++ b/scripts/auto-updater @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +LOCKFILE=/tmp/chupdater.lock +if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}` >/dev/null; then + echo -e "\033[1;31m \n \nAuto Updater: Auto Updater already running in the background\n\033[0m" + exit +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;34 \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' || { echo -e "\033[1;31m \n \nAuto Updater: Failed to pull from github!\n\033[0m"; exit 1; } + +pushd build >/dev/null || exit 1 + +sudo 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; } + +sudo -u $(logname) bash -c 'cmake .. >/dev/null && cmake --build . --target cathook >/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 diff --git a/tools/updater.sh b/tools/updater.sh deleted file mode 100755 index dd7a8abf..00000000 --- a/tools/updater.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -printf "\n\n";printf '\e[1;34m%-6s\e' "Your cathook version is out of date! Please reinstall by using \"wget https://raw.githubusercontent.com/nullworks/One-in-all-cathook-install/master/install-all && bash install-all\"";printf "\n\n" \ No newline at end of file