Fix some migration stuff

This commit is contained in:
TotallyNotElite 2019-10-26 17:36:06 +02:00
parent 37ce0685e2
commit 40c731d2ec
3 changed files with 26 additions and 35 deletions

View File

@ -26,4 +26,4 @@ $RUNCMD bash -c ". ./scripts/config.shlib; cfg_write ./scripts/updater-preferenc
# Build cathook
#
$RUNCMD ./scripts/updater false true
$RUNCMD ./scripts/updater false true true

View File

@ -1,34 +1,12 @@
#!/usr/bin/env bash
# $3 Init
set -e
configfile="./scripts/updater-preferences"
. ./scripts/config.shlib
# Migrate pre config lib configs
exists=true
cfg_haskey $configfile version || exists=false
if [ "$exists" == false ]; then
if [ -f $configfile ]; then
value=$(cat $configfile)
rm $configfile
fi
echo "" > $configfile
cfg_write $configfile version 1
if [ "$(git rev-parse --is-shallow-repository)" == "true" ]; then
cfg_write $configfile update_channel stable
else
cfg_write $configfile update_channel developer
fi
if [ -f $configfile ]; then
if [ "$value" == true ] || [ "$value" == false ]; then
cfg_write $configfile autoupdater $value
fi
fi
fi
version="$(cfg_read $configfile version)"
tui=true
if [ ! -x "$(command -v dialog)" ]; then
tui=false
@ -38,18 +16,26 @@ if [ ! -t 0 ]; then
tui=false
fi
#
# Init goes here
#
if [ "$3" == true ]; then
cfg_write $configfile update_channel stable
cfg_write $configfile version 3
fi
version="$(cfg_read $configfile version)"
#
# Migrations go here
#
exists=true
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 [ "$version" == 1 ] || [ "$version" == 2 ]; then
cfg_write $configfile version 3
if [ -d "./build/CMakeFiles/cathook.dir" ]; then
rm -r ./build/CMakeFiles/cathook.dir
fi

View File

@ -2,6 +2,11 @@
# $1 Auto updater
# $2 Disable TUI
# $3 Init
ARG1=${1:-false}
ARG2=${2:-false}
ARG3=${3:-false}
set -e
@ -31,7 +36,7 @@ if [ "$exists" == true ]; then
update_channel="$(cfg_read $configfile update_channel)"
fi
if [ "$update_channel" != "developer" ]; then
./scripts/migrations "$@" || exit 0
./scripts/migrations $ARG1 $ARG2 false || exit 0
fi
# Check if all required packages are installed
@ -41,7 +46,7 @@ tui=true
if [ ! -t 0 ]; then
tui=false
fi
if [ "$2" == "true" ]; then
if [ "$ARG2" == "true" ]; then
tui=false
fi
if [ ! -x "$(command -v dialog)" ] && [ "$tui" == true ]; then
@ -66,7 +71,7 @@ fi
exists=true
cfg_haskey $configfile autoupdater || exists=false
if [ "$1" == "true" ]; then
if [ "$ARG1" == "true" ]; then
if [ $exists == false ] || [ "$(cfg_read $configfile autoupdater)" == false ]; then
exit 0;
fi
@ -98,7 +103,7 @@ function performupdate() {
# Run migrations
if [ "$update_channel" != "developer" ]; then
./scripts/migrations "$@" || exit 0
./scripts/migrations $ARG1 $ARG2 $ARG3 || exit 0
fi
#submodules