diff --git a/global.sh b/global.sh index 6f69a74e..0c69693d 100755 --- a/global.sh +++ b/global.sh @@ -2,9 +2,22 @@ # This file is containing some global function needed for the script such as the config file tools -rd_conf="/var/config/retrodeck/retrodeck.cfg" +rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path -conf_init() { +# if everything is working put this stuff down there +if [ ! -f $rd_conf ] +then + # Init default values, this may be overwritten by retrodeck.cfg as it sourced later with global.sh + lockfile="/var/config/retrodeck/.lock" # where the lockfile is located + emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs + sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path + rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck + media_folder="$HOME/retrodeck/downloaded_media" # the media folder, where all the scraped data is downloaded into + themes_folder="$HOME/retrodeck/themes" # the themes folder + hard_version="$(cat '/app/retrodeck/version')" # hardcoded version (in the readonly filesystem) +fi + +#conf_init() { # initializing and reading the retrodeck config file if [ ! -f $rd_conf ] then # I have to initialize the variables as they cannot be red from an empty config file @@ -16,7 +29,13 @@ conf_init() { echo "#!/bin/bash" >> $rd_conf # version info taken from the version file - version="$(cat /app/retrodeck/version)" + # if the version variable is not set means that is a first installation, so we populate with the hardcoded version + if [ -z $version ] + then + version="$hard_version" + #else + # version="$version" + fi echo "version=$version" >> $rd_conf # the retrodeck home, aka ~/retrodeck @@ -41,7 +60,7 @@ conf_init() { echo "Loading it" source $rd_conf fi -} +#} conf_write() { # writes the variables in the retrodeck config file diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index 246c908b..77bd3695 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -61,7 +61,7 @@ modules: # This module is used to define the RetroDECK version # If the version is set as cooker it will automatically generate the version tag based on the date # else it will just put what is written, "v" is not needed - # The version number is stored in /var/conf/retrodeck/version + # The version number is hardcoded in /app/retrodeck/version # # UPDATE STEPS FOR MAIN: # [ ] Update the VERSION variable diff --git a/retrodeck.sh b/retrodeck.sh index 34e2829e..963a5158 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -1,17 +1,7 @@ #!/bin/bash -# Init default values, this may be overwritten by retrodeck.cfg as it sourced later with global.sh - -lockfile="/var/config/retrodeck/.lock" # where the lockfile is located -emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs -sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path -rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path -version="$(cat /app/retrodeck/version)" # version info taken from the version file -rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck -media_folder="$HOME/retrodeck/downloaded_media" # the media folder, where all the scraped data is downloaded into -themes_folder="$HOME/retrodeck/themes" # the themes folder - source /app/bin/global.sh +#conf_init # We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions if [ -f "$HOME/retrodeck/.lock" ] @@ -228,8 +218,8 @@ ra_init() { } create_lock() { - # creating RetroDECK's lock file and writing the version number in it - echo "$version" > "$lockfile" + # creating RetroDECK's lock file and writing the version in the config file + touch "$lockfile" conf_write } @@ -438,7 +428,7 @@ finit() { for i in "$@"; do case $i in -h*|--help*) - echo "RetroDECK v""$(cat /var/config/retrodeck/version)" + echo "RetroDECK v""$version" echo " Usage: flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS] @@ -459,12 +449,12 @@ https://retrodeck.net exit ;; --version*|-v*) - conf_init + #conf_init echo "RetroDECK v$version" exit ;; --info-msg*) - conf_init + #conf_init echo "RetroDECK v$version" echo "RetroDECK config file is in: $rd_conf" echo "Contents:" @@ -497,23 +487,27 @@ https://retrodeck.net done # UPDATE TRIGGERED -# if lockfile exists but the version doesn't match -if [ -f "$lockfile" ] && [ "$(cat "$lockfile")" != "$version" ]; +# if lockfile exists +if [ -f "$lockfile" ] then - echo "Lockfile version is "$(cat "$lockfile")" but the actual version is $version" - conf_init # Initializing/reading the config file (sourced from global.sh) - post_update # Executing post update script - conf_write # Writing variables in the config file (sourced from global.sh) - start_retrodeck - exit 0 -fi -# LOCKFILE REMOVED + #conf_init # Initializing/reading the config file (sourced from global.sh) + + # ...but the version doesn't match with the config file + if [ "$hard_version" != "$version" ]; + then + echo "Config file's version is "$(cat "$version")" but the actual version is $hard_version" + post_update # Executing post update script + conf_write # Writing variables in the config file (sourced from global.sh) + start_retrodeck + exit 0 + fi + +# Else, LOCKFILE IS NOT EXISTING (WAS REMOVED) # if the lock file doesn't exist at all means that it's a fresh install or a triggered reset -if [ ! -f "$lockfile" ]; -then +else echo "Lockfile not found" - conf_init # Initializing/reading the config file (sourced from global.sh) + #conf_init # Initializing/reading the config file (sourced from global.sh) finit # Executing First/Force init conf_write # Writing variables in the config file (sourced from global.sh) exit 0