Merge pull request #838 from nullworks/totallynotelite

Script updates
This commit is contained in:
TotallyNotElite 2019-10-19 20:27:57 +02:00 committed by GitHub
commit 983dafc6bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 23 deletions

2
config
View File

@ -35,7 +35,7 @@ do
elif [ "$response" == 2 ]; then
cfg_write $configfile update_channel master
elif [ "$response" == 3 ]; then
cfg_write $configfile update_channel developer
./scripts/developer
else
continue
fi

View File

@ -20,7 +20,7 @@ fi
# Set config version for update script
#
$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 1"
$RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferences version 2"
#
# Build cathook

View File

@ -4,17 +4,38 @@ if [ $EUID == 0 ]; then
exit
fi
if [ ! -f ./scripts/updater-preferences ]; then
while true; do
read -p "Do you want to switch your cathook repository into developer mode? y/n " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
while true; do
read -p "Do you want to switch your cathook repository into developer mode? y/n " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# git setup
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --unshallow
git fetch --all
git submodule foreach --recursive 'git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"'
git submodule foreach --recursive 'git fetch --unshallow'
# config setup
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
configfile="$DIR/updater-preferences"
. config.shlib
cfg_write $configfile update_channel developer
while true; do
read -p "Would you like to reset your repository to the origin/master branch? y/n " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# more git setup
git reset --hard origin/master
git submodule foreach --recursive 'git reset --hard'
git submodule sync
git submodule update --init --recursive

View File

@ -47,3 +47,10 @@ cfg_haskey $configfile update_channel || exists=false
if [ "$exists" == false ]; then
cfg_write $configfile update_channel stable
fi
if [ "$version" == 1 ]; then
cfg_write $configfile version 2
if [ -d "./build/CMakeFiles/cathook.dir" ]; then
rm -r ./build/CMakeFiles/cathook.dir
fi
fi

View File

@ -22,14 +22,21 @@ fi
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
# Run migrations
./scripts/migrations "$@" || exit 0
#Check if all required packages are installed
./scripts/dependencycheck
. ./scripts/config.shlib
# Run migrations
exists=true
cfg_haskey $configfile update_channel || exists=false
if [ "$exists" == true ]; then
update_channel="$(cfg_read $configfile update_channel)"
fi
if [ "$update_channel" != "developer" ]; then
./scripts/migrations "$@" || exit 0
fi
# Check if all required packages are installed
./scripts/dependencycheck
tui=true
if [ ! -t 0 ]; then
tui=false
@ -73,11 +80,11 @@ function performupdate() {
update_channel="$(cfg_read $configfile update_channel)"
if [ "$update_channel" == "stable" ]; then
git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && 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; } }
git fetch --force --depth 1 origin refs/tags/latest:refs/tags/latest && git reset --hard latest || { 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://github.com/nullworks/cathook\n\033[0m"; exit 1; } }
elif [ "$update_channel" == "master" ]; then
git fetch --force --depth 1 origin && git reset --hard origin/master && 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://cathook.club\n\033[0m"; exit 1; } }
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 && git submodule update --init --recursive || { 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 || { echo -e "\033[1;31m\n\nFailed to pull from github!\n\033[0m"; exit 1; }
else
if [ "$tui" == true ]; then
value=true
@ -90,8 +97,18 @@ function performupdate() {
fi
# Run migrations
./scripts/migrations "$@" || exit 0
if [ "$update_channel" != "developer" ]; then
./scripts/migrations "$@" || exit 0
fi
#submodules
if [ "$update_channel" == "developer" ]; then
git submodule update --init --recursive
else
git submodule sync
git submodule update --depth 1 --init --recursive
fi
proccount=$(grep -c '^processor' /proc/cpuinfo)
if [ "$AUTOUPDATER" == true ]; then
proccount=1