diff --git a/scripts/run-updater b/scripts/run-updater index a5377d2a..8317b39c 100755 --- a/scripts/run-updater +++ b/scripts/run-updater @@ -2,7 +2,7 @@ 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" + echo -e "\033[1;33m \n \nAuto Updater: Auto Updater already running in the background\n\033[0m" exit 1 fi @@ -13,9 +13,9 @@ echo $$ > ${LOCKFILE} echo -e "\033[1;34m \n \nAuto Updater: Updating cathook in the background\n\033[0m" if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then - sudo -u $LOGNAME bash -c 'git fetch --depth 1 origin >/dev/null && git reset --hard @{upstream} >/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; } + sudo -u $LOGNAME bash -c 'git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest origin && git reset --hard latest && git submodule update --depth 1 --init --recursive || { 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} && git submodule update --depth 1 --init --recursive; }' || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://github.com/nullworks/cathook\n\033[0m"; exit 1; } else - sudo -u $LOGNAME bash -c '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; } + sudo -u $LOGNAME bash -c 'echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && 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; } fi pushd build >/dev/null || exit 1 diff --git a/update b/update index 37c4c414..367822f4 100755 --- a/update +++ b/update @@ -1,12 +1,16 @@ #!/usr/bin/env bash +if [ $EUID == 0 ]; then + echo "\033[1;31m\nThis script must not be run as root\n\033[0m" + exit 1 +fi #Get updated source code if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then - git fetch --depth 1 origin && git reset --hard @{upstream} && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;31m \n \nFailed to pull from github!"; exit 1; } + git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest origin && git reset --hard latest && git submodule update --depth 1 --init --recursive || { 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} && git submodule update --depth 1 --init --recursive || { echo -e "\033[1;31m\nFailed to pull from github! A reinstall is recommended. https://github.com/nullworks/cathook\n\033[0m"; exit 1; } } else - git pull origin && git submodule update --init --recursive || { echo -e "\033[1;31m \n \nFailed to pull from github!"; exit 1; } + echo -e "\033[1;33m\nWarning! Running in developer mode! Expect issues!\n\033[0m" && git pull origin && git submodule update --init --recursive || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; } fi #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; } +cd build && cmake .. && cmake --build . --target cathook -- -j$(grep -c '^processor' /proc/cpuinfo) || { echo -e "\033[1;31m \n \nFailed to compile cathook\n\033[0m"; exit 1; } #Update data -sudo cmake --build . --target data || { echo -e "\033[1;31m \n \nFailed to update /opt/cathook/data directory"; exit 1; } -echo -e "\n\n\033[1;34mCathook updated successfully" +sudo cmake --build . --target data || { echo -e "\033[1;31m\nFailed to update /opt/cathook/data directory\n\033[0m"; exit 1; } +echo -e "\n\033[1;34mCathook updated successfully\n\033[0m"