Add proper support for updater self update

Also remove old scripts
This commit is contained in:
TotallyNotElite 2021-02-11 21:08:43 +01:00 committed by TotallyNotElite
parent 4804f30ff9
commit 8f33d775c6
20 changed files with 19 additions and 706 deletions

View File

@ -1,41 +0,0 @@
#!/usr/bin/env bash
line=$(pidof hl2_linux)
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi
if [ ${#arr[@]} == 0 ]; then
echo tf2 isn\'t running!
exit
fi
if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi
proc=${arr[$inst]}
echo Running instances: "${arr[@]}"
echo Attaching to "$proc"
sudo ./detach $inst bin/libcathook.so
if grep -q "$(realpath bin/libcathook.so)" /proc/"$proc"/maps; then
echo already loaded
exit
fi
echo loading "$(realpath bin/libcathook.so)" to "$proc"
gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath bin/libcathook.so)\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "catch syscall exit exit_group" \
-ex "continue" \
-ex "backtrace"

View File

@ -1,51 +0,0 @@
#!/usr/bin/env bash
line=$(pidof hl2_linux)
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi
if [ ${#arr[@]} == 0 ]; then
echo tf2 isn\'t running!
exit
fi
if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi
proc=${arr[$inst]}
echo Running instances: "${arr[@]}"
FILENAME="/tmp/.gl$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"
cp "bin/libcathook.so" "$FILENAME"
echo Attaching to "$proc"
sudo ./detach $inst bin/libcathook.so
if grep -q "$FILENAME" /proc/"$proc"/maps; then
echo already loaded
exit
fi
sudo killall -19 steam
sudo killall -19 steamwebhelper
echo loading "$FILENAME" to "$proc"
gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$FILENAME\", 1)" \
-ex "call dlerror()" \
-ex "print (char *) $2" \
-ex "catch syscall exit exit_group" \
-ex "continue" \
-ex "backtrace"
sudo killall -18 steamwebhelper
sudo killall -18 steam

View File

@ -1,53 +0,0 @@
#!/usr/bin/env bash
if [ $UID == "0" ]; then
echo "Don't run as root!"
exit
fi
user=$USER
if [ "$#" == 1 ]; then
user=$1
fi
proc="0"
for pid in $(pidof hl2_linux)
do
if sudo -H -u $user kill -0 $pid
then
proc=$pid
break
fi
done
echo Attaching to "$proc"
if sudo grep -q "libcathook.so" /proc/"$proc"/maps; then
echo already loaded
exit
fi
# pBypass for crash dumps being sent
# You may also want to consider using -nobreakpad in your launch options.
sudo rm -rf /tmp/dumps # Remove if it exists
sudo mkdir /tmp/dumps # Make it as root
sudo chmod 000 /tmp/dumps # No permissions
cp "bin/libcathook.so" /tmp
FILENAME=/tmp/libcathook.so
echo loading "$FILENAME" to "$proc"
sudo gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$FILENAME\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"
rm /tmp/libcathook.so

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
proc=${1:-$(ps $(pidof gameoverlayui) | tail -n1 | cut -d\- -f2 | cut -d\ -f2)}
if ! [[ $proc =~ ^[0-9]+$ ]]; then
echo "Couldn't find process! Are you sure a game is running?" >&2; exit 1
fi
if grep -q "$(realpath bin/libcathook.so)" /proc/"$proc"/maps; then
echo already loaded
exit
fi
echo loading "$(realpath bin/libcathook.so)" to "$proc"
gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath bin/libcathook.so)\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"

View File

@ -1,46 +0,0 @@
#!/usr/bin/env bash
user=$USER
if [ "$#" == 1 ]; then
user=$1
fi
proc="0"
for pid in $(pidof hl2_linux)
do
if sudo -H -u $user kill -0 $pid
then
proc=$pid
break
fi
done
if [ "$proc" == "0" ]
then
echo "TF2 for $user is not running"
continue
fi
echo Attaching to "$proc"
FILENAME=$(realpath "bin/libcathook.so")
echo loading "$FILENAME" to "$proc"
sudo killall -19 steam
sudo killall -19 steamwebhelper
sudo gdb -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$FILENAME\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"
sudo killall -18 steamwebhelper
sudo killall -18 steam

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
. common
$DIALOG --title "Install?" --backtitle "Installing catlibs" --yesno "This script will ask you for superuser password to install xoverlay and glez." 9 78
if [ $? == 1 ]; then exit; fi
SU=gksu
if ! command -v gksu; then
SU=sudo
exit
fi
pushd ../libxoverlay
if ! make -e ARCH=32 >/tmp/buildxoverlay.log 2>&1; then
$DIALOG --title "Build failed" --msgbox "Failed to build libxoverlay. See /tmp/buildxoverlay.log for more info." 9 78
exit
fi
$SU make install
popd
pushd ../libglez
if ! make -e ARCH=32 >/tmp/buildglez.log 2>&1; then
$DIALOG --title "Build failed" --msgbox "Failed to build libglez. See /tmp/buildglez.log for more info." 9 78
exit
fi
$SU make install
popd

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
DIALOG="whiptail --clear"
echo_ok ()
{
echo -e "\033[32m\e[1mOK\e[0m"
}
echo_error ()
{
echo -e "\033[31m\e[1mERROR\e[0m"
}

33
scripts/old/configure vendored
View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
. common
CONFIG=autoconf.h
echo "/* This config is generated by scripts/configure */" >$CONFIG
FEATURES=(aimbot esp test);
declare -A features
for feature in "${FEATURES[@]}"
do
features[\"$feature\"]=0
done
enabled=$($DIALOG --backtitle "Configure cathook" --checklist "Select features you want to enable" 20 78 4 \
aimbot "Enable Aimbot" ON \
esp "Enable ESP" ON \
test "Test" OFF \
3>&2 2>&1 1>&3)
for feature in $enabled
do
features[$feature]="1"
done
for feature in ${FEATURES[@]}
do
echo "#define CONFIG_FEATURE_$feature ${features[\"$feature\"]}">>$CONFIG
done
! $DIALOG --backtitle "Configure cathook" --yesno "Use Xoverlay to draw visuals outside TF2's window (can be buggy and is NOT compatible with Steam overlay!)" 10 40 3>&2 2>&1 1>&3
echo "#define CONFIG_ENABLE_XOVERLAY $?" >>$CONFIG

View File

@ -1,76 +0,0 @@
#!/usr/bin/env bash
. depends
. common
library_exists ()
{
ld -melf_i386 -l$1 -o /dev/null >/dev/null 2>&1
return $?
}
header_exists ()
{
echo "#include <$1>" | g++ -x c++ - -fsyntax-only -o /dev/null >/dev/null 2>&1
return $?
}
STATUS_MISSING=$(mktemp)
gauge_deps_libraries ()
{
local I=0
for lib in "${DEPENDS_LIBRARIES[@]}"
do
# unholy
local percent=$(echo "scale=2; $I / ${#DEPENDS_LIBRARIES[*]} * 100" | bc | sed s/\\.[0-9]\\+//)
printf 'XXX\n%d\nChecking for library "%s"...\nXXX\n' $percent "$lib"
if ! library_exists $lib; then
echo $lib >$STATUS_MISSING
return 1
fi
I=$(($I + 1))
done
return 0
}
gauge_deps_headers ()
{
local I=0
for header in "${DEPENDS_HEADERS[@]}"
do
# unholy
local percent=$(echo "scale=2; $I / ${#DEPENDS_HEADERS[*]} * 100" | bc | sed s/\\.[0-9]\\+//)
printf 'XXX\n%d\nChecking for header <%s>...\nXXX\n' $percent "$header"
if ! header_exists $header; then
echo $header >$STATUS_MISSING
return 1
fi
I=$(($I + 1))
done
return 0
}
BAD=0
check_all_deps ()
{
gauge_deps_libraries | whiptail --title "Checking libraries" --gauge "Please wait" 6 78 0
if ! [ ${PIPESTATUS[0]} == 0 ]; then
$DIALOG --title "Error: missing library" --msgbox "It appears that you don't have library '$(cat $STATUS_MISSING)' installed. Please install it and try again." 8 78
BAD=1
fi
gauge_deps_headers | whiptail --title "Checking headers" --gauge "Please wait" 6 78 0
if ! [ ${PIPESTATUS[0]} == 0 ]; then
$DIALOG --title "Error: missing header" --msgbox "It appears that you don't have header '$(cat $STATUS_MISSING)' installed. Please install it and try again." 8 78
BAD=1
fi
if [ $BAD == 1 ]; then
$DIALOG --title "Failure" --msgbox "It looks like you need to install some additional libraries, you can do that from main menu." 8 78
else
$DIALOG --title "Success" --msgbox "You have all the libraries you need to build and use cathook!" 7 68
fi
}
check_all_deps
rm $STATUS_MISSING

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# TODO
# do not depend on graphical libraries if compiling for textmode
# do not depend on X libraries if Xoverlay is disabled
DEPENDS_LIBRARIES=(ssl m rt GL freetype GLEW png X11 Xext pthread Xfixes xoverlay glez);
DEPENDS_HEADERS=("SDL2/SDL.h" "freetype2/freetype/config/ftheader.h" "openssl/err.h" "GL/gl.h" "GL/glew.h");
DEPENDS_PACKAGES=("gcc-6" "g++-6" "gcc-6-multilib" "g++-6-multilib" "libssl-dev:i386" "libsdl2-dev" "libfreetype6-dev" "libfreetype6-dev:i386" "libglew-dev" "libglew-dev:i386" "libpng-dev" "libpng-dev:i386" "libboost-all-dev");

View File

@ -1,45 +0,0 @@
#!/usr/bin/env bash
. common
. depends
$DIALOG --title "Install?" --backtitle "Installing" --yesno "The script will probably need to install some additional packages using apt, and this probably can break something, so you should use it at your own risk." 9 78
if [ $? == 1 ]; then exit; fi
package_exists ()
{
dpkg -s $1 2>&1 | grep Status >/dev/null 2>&1
return $?
}
gauge_deps_packages ()
{
local I=0
for package in "${DEPENDS_PACKAGES[@]}"
do
# unholy
local percent=$(echo "scale=2; $I / ${#DEPENDS_PACKAGES[*]} * 100" | bc | sed s/\\.[0-9]\\+//)
printf 'XXX\n%d\nChecking for package "%s"...\nXXX\n' $percent "$package"
if ! package_exists $package; then
printf 'XXX\n%d\nInstalling "%s"...\nXXX\n' $percent "$package"
gksu -- apt install -y $package >/dev/null 2>&1
fi
I=$(($I + 1))
# Sleep so the user sees the package name
sleep 0.3
done
return 0
}
if ! package_exists "gksu"; then
$DIALOG --title "gksu not installed" --msgbox "You should install gksu first. Do that with\nsudo apt install gksu" 9 78
exit
fi
gauge_deps_packages | whiptail --title "Installing packages" --gauge "Please wait" 6 78 0
$DIALOG --title "Success" --msgbox "Installed successfully." 8 78
if ! [ ${PIPESTATUS[0]} == 0 ]; then
$DIALOG --title "Error: error" --msgbox "It appears that you have error. Please fix it." 8 78
fi

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
line=$(pidof hl2_linux)
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi
if [ ${#arr[@]} == 0 ]; then
echo TF2 isn\'t running!
exit
fi
if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi
echo Running instances: "${arr[@]}"
echo Detaching from "${arr[$1]}"
if grep -q "$(realpath bin/libcathook.so)" /proc/"${arr[$1]}"/maps; then
gdb -n -q -batch \
-ex "attach ${arr[$1]}" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "set \$dlclose = (int(*)(void*)) dlclose" \
-ex "set \$library = \$dlopen(\"$(realpath bin/libcathook.so)\", 6)" \
-ex "print \$library" \
-ex "sharedlibrary ." \
-ex "call \$dlclose(\$library)" \
-ex "call \$dlclose(\$library)" \
-ex "detach"
echo "Detached"
else
echo "not found!"
fi

View File

@ -1,38 +0,0 @@
#!/usr/bin/env bash
line=$(pidof hl2_linux)
arr=($line)
inst=$1
if [ $# == 0 ]; then
inst=0
fi
if [ ${#arr[@]} == 0 ]; then
echo TF2 isn\'t running!
exit
fi
if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
echo wrong index!
exit
fi
echo Running instances: "${arr[@]}"
echo Detaching from "${arr[$1]}"
if grep -q "$(realpath bin/libcathook.so)" /proc/"${arr[$1]}"/maps; then
gdb -n -q -batch \
-ex "attach ${arr[$1]}" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "set \$dlclose = (int(*)(void*)) dlclose" \
-ex "set \$library = \$dlopen(\"$(realpath bin/libcathook.so)\", 6)" \
-ex "print \$library" \
-ex "sharedlibrary ." \
-ex "call \$dlclose(\$library)" \
-ex "call \$dlclose(\$library)" \
-ex "continue" \
-ex "backtrace"
echo "Detached"
else
echo "not found!"
fi

View File

View File

@ -1,2 +0,0 @@
#!/bin/bash
make -j4 -e NOGUI=1

View File

@ -1,76 +0,0 @@
#!/usr/bin/env bash
# TODO extremely unfinished
. common
if ! grep -qi "Ubuntu" /proc/version ; then
$DIALOG --title "WARNING" --msgbox "The script has detected that you are not using Ubuntu.\n\
While cathook can work on most distros, most helper scripts can work incorrectly or not work at all and you may also have trouble with compiling cathook here.\n\n\
If you have trouble, you can visit cathook's official telegram channel and ask for help from other users of your distro there." 15 50
fi
USER=$($DIALOG --title "Main Menu (WIP)" --menu "What do you want to do?" 20 60 12 \
"DEP" "| Check requirements (Ubuntu)" \
"CAT" "| Install libglez and libxoverlay" \
"INS" "| Install libraries (Ubuntu)" \
"BLD" "| Build" \
"INJ" "| Inject" \
"FIX" "| Troubleshoot (WIP)" \
"BUG" "| Suggestion or bug report" \
"TGA" "| Join announcements channel in Telegram" \
"TGB" "| Join community channel in Telegram" \
"PAT" "| Support the creator" \
"FMT" "| Format sources" \
"UPD" "| Update" 3>&1 1>&2 2>&3)
case "$USER" in
"DEP")
. depcheck
exit
;;
"CAT")
. catlibs
exit
;;
"INS")
. depinstall
exit
;;
"BLD")
. build
exit
;;
"INJ")
. inject
exit
;;
"FIX")
. troubleshoot
exit
;;
"BUG")
xdg-open https://github.com/nullifiedcat/cathook/issues >/dev/null 2>&1 &
exit
;;
"TGA")
xdg-open tg://resolve?domain=cathook_cheat >/dev/null 2>&1 &
exit
;;
"TGB")
xdg-open tg://resolve?domain=nullifiedcat >/dev/null 2>&1 &
exit
;;
"PAT")
xdg-open https://patreon.com/nullifiedcat >/dev/null 2>&1 &
exit
;;
"FMT")
. format
exit
;;
"UPD")
. update
exit
;;
esac

View File

@ -1,111 +0,0 @@
#!/usr/bin/env bash
# Credit to LWSS for doing this shit in Fuzion, looked and pasted a stuff from his preload meme
# This assumes the presence of the ~/.steam symlink
GAMEROOT=$(realpath $HOME/.steam/steam/steamapps/common/Team\ Fortress\ 2)
GAMEEXE="hl2_linux"
if [ ! -d "$GAMEROOT" ]; then
echo -e "\e[91mCould not find Team Fortress 2 directory. Check if Steam symlink at $HOME/.steam exists.\e[39m"
exit -1
fi
export LD_LIBRARY_PATH="$GAMEROOT"\
":$GAMEROOT/bin"\
":$GAMEROOT/bin/linux32"\
":$GAMEROOT/tf/bin"\
":$HOME/.steam/ubuntu12_32"\
":$HOME/.steam/ubuntu12_32/linux32"\
":$HOME/.steam/ubuntu12_32/panorama"\
":$HOME/.steam/bin32"\
":$HOME/.steam/bin32/linux32"\
":$HOME/.steam/bin32/panorama"\
":/lib/i386-linux-gnu"\
":/usr/lib/i386-linux-gnu/"\
":/usr/lib64/atlas"\
":/usr/lib64/bind99"\
":/usr/lib64/iscsi"\
":/usr/lib64/nx"\
":/usr/lib64/qt-3.3/lib"\
":/usr/lib"\
":/usr/lib32"\
":/lib64"\
":/lib32"\
":/usr/lib/i686"\
":/usr/lib/sse2"\
":/lib64/tls"\
":/lib64/sse2"\
":/usr/lib/steam"\
":/usr/lib32/steam"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/lib"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/lib"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/i386/usr/lib"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/lib"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu"\
":$HOME/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib"\
":$HOME/.steam/ubuntu12_64"\
":$HOME/.steam/bin32/steam-runtime/i386/usr/lib/i386-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/i386/lib/i386-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/amd64/lib/x86_64-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/amd64/lib"\
":$HOME/.steam/bin32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/amd64/usr/lib"\
":$HOME/.steam/bin32/steam-runtime/i386/lib/i386-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/i386/lib"\
":$HOME/.steam/bin32/steam-runtime/i386/usr/lib/i386-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/i386/usr/lib"\
":$HOME/.steam/bin32/steam-runtime/amd64/lib/x86_64-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/amd64/lib"\
":$HOME/.steam/bin32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu"\
":$HOME/.steam/bin32/steam-runtime/amd64/usr/lib"\
":$HOME/.steam/bin64"\
":$HOME/.steam/bin"
# Set file descriptor limit
ulimit -n 2048
export LD_PRELOAD
LD_PRELOAD="$(realpath .)/bin/libcathook.so:/usr/lib/i386-linux-gnu/libstdc++.so.6:/usr/lib32/libstdc++.so.6:launcher.so"
# Enable nVidia threaded optimizations
export __GL_THREADED_OPTIMIZATIONS=1
# Enable Mesa threaded shader compiles
export multithread_glsl_compiler=1
cd "$GAMEROOT"
STATUS=42
while [ $STATUS -eq 42 ]; do
if [ "${DEBUGGER}" == "gdb" ] || [ "${DEBUGGER}" == "cgdb" ]; then
echo -e "\e[92mSuccess! Launching TF2 using ${DEBUGGER} as debugger.\e[39m"
ARGSFILE=$(mktemp "$(whoami)".hl2.gdb.XXXX)
echo b main > "$ARGSFILE"
# Set the LD_PRELOAD varname in the debugger, and unset the global version. This makes it so that
# gameoverlayrenderer.so and the other preload objects aren't loaded in our debugger's process.
echo set env LD_PRELOAD=$LD_PRELOAD >> "$ARGSFILE"
echo show env LD_PRELOAD >> "$ARGSFILE"
unset LD_PRELOAD
echo run $@ >> "$ARGSFILE"
echo show args >> "$ARGSFILE"
${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} -x -steam -game "tf" "$ARGSFILE"
rm "$ARGSFILE"
else
echo -e "\e[92mSuccess! Launching TF2.\e[39m"
${DEBUGGER} "${GAMEROOT}"/${GAMEEXE} -steam -game "tf" "$@"
fi
STATUS=$?
done
exit ${STATUS}

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
sudo ./detach "$1" && sudo ./attach "$1"

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
. common
$DIALOG --backtitle "Troubleshooting" --title "Troubleshooting" --menu "What is your problem?" 12 40 3 \
"C" "Compiling problems" \
"R" "Runtime problems" \
"O" "Other problems"
$DIALOG --backtitle "Troubleshooting" --title "Compile problems" --menu "What is your problem?" 20 40 3 \
"TODO" "TODO"

View File

@ -21,7 +21,7 @@ if [ $(id -u) -eq 0 ]; then
fi
LOCKFILE=/tmp/chupdater.lock
if [ -e ${LOCKFILE} ] && ps -p `cat ${LOCKFILE}` >/dev/null; then
if [ -e ${LOCKFILE} ] && ps -p `cat ${LOCKFILE}` >/dev/null && [ -z "$CH_UPDATER_SELFUPDATE" ]; then
echo -e "\033[1;33m \n \nUpdater: Updater already running!\n\033[0m"
exit 1
fi
@ -48,9 +48,6 @@ if [ "$DISABLE_TUI" == "true" ]; then
fi
if [ ! -x "$(command -v dialog)" ] || [ "$tui" == false ]; then
dialog=false
if [ "$tui" == true ]; then
echo -e "\033[1;31mTerminal UI NOT supported! Install \"dialog\"! \033[0m"
fi
fi
# Run migrations if not a developer
@ -67,14 +64,14 @@ fi
exists=true
cfg_haskey $configfile autoupdater || exists=false
if [ "$dialog" == true ] && [ "$exists" == false ]; then
value=true
value=false
response=255
while [ "$response" != 0 ] && [ "$response" != 1 ]; do
dialog --keep-tite --title "Updater" --yesno "Do you want to enable the cathook auto updater?" 10 25 || { response=$?; continue; }
response=$?
done
if [ "$response" == 1 ]; then
value=false
if [ "$response" == 0 ]; then
value=true
fi
cfg_write $configfile autoupdater $value
fi
@ -106,12 +103,15 @@ function performupdate() {
fi
fi
# Store info about the currently checked out updater script hash
OLD_UPDATE=$(git rev-parse HEAD:scripts/updater)
if [ "$update_channel" == "stable" ]; then
git fetch --force --depth 1 origin refs/tags/stable:refs/tags/stable && git reset --hard stable || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://cathook.club\n\033[0m"; exit 1; } }
elif [ "$update_channel" == "master" ]; then
git fetch --force --depth 1 origin && git reset --hard origin/master || { echo -e "\033[1;33m\nFailed to pull from github! Trying alternative pull (legacy)\n\033[0m"; git fetch --depth 1 && git reset --hard @{upstream} || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://cathook.club\n\033[0m"; exit 1; } }
elif [ "$update_channel" == "developer" ]; then
echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; }
echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin --rebase=false || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; }
else
if [ "$dialog" == true ]; then
value=true
@ -124,11 +124,19 @@ function performupdate() {
exit 1
fi
# Run migrations
if [ "$update_channel" != "developer" ]; then
# Run migrations, idk if it's a good idea to let this execute outside of the reach of the updater script self updater
if [ "$update_channel" != "developer" ] && [ -e ./scripts/migrations ]; then
./scripts/migrations $tui $INIT false || exit 1
fi
NEW_UPDATE=$(git rev-parse HEAD:scripts/updater)
# Check if the updater script hash has changed. If yes, re-execute yourself (this automates the "double updates" that are sometimes required
if [ "$OLD_UPDATE" != "$NEW_UPDATE" ]; then
echo -e "\033[1;33m\nWarning: Update script self update!\n\033[0m"
CH_UPDATER_SELFUPDATE=1 exec $0 $@
fi
# Check if all required packages are installed
./scripts/dependencycheck
@ -145,7 +153,7 @@ function performupdate() {
if [ "$AUTOUPDATER" == true ]; then
proccount=1
fi
#Create build folder in case it doesn't exist
mkdir -p ./build
# Update cathook