Git tags as update system

tags and stuff
This commit is contained in:
TotallyNotElite 2019-01-17 19:59:33 +01:00
parent 1fbb177548
commit e844401cff
2 changed files with 12 additions and 8 deletions

View File

@ -2,7 +2,7 @@
LOCKFILE=/tmp/chupdater.lock LOCKFILE=/tmp/chupdater.lock
if [ -e ${LOCKFILE} ] && ps -p `cat ${LOCKFILE}` >/dev/null; then 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 exit 1
fi fi
@ -13,9 +13,9 @@ echo $$ > ${LOCKFILE}
echo -e "\033[1;34m \n \nAuto Updater: Updating cathook in the background\n\033[0m" 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 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 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 fi
pushd build >/dev/null || exit 1 pushd build >/dev/null || exit 1

14
update
View File

@ -1,12 +1,16 @@
#!/usr/bin/env bash #!/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 #Get updated source code
if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then 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 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 fi
#Update cathook #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 #Update data
sudo cmake --build . --target data || { echo -e "\033[1;31m \n \nFailed to update /opt/cathook/data directory"; exit 1; } 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\n\033[1;34mCathook updated successfully" echo -e "\n\033[1;34mCathook updated successfully\n\033[0m"