mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-23 14:35:39 +00:00
Simplyfing variable system
This commit is contained in:
parent
22e1e2b00f
commit
481b2f8c55
27
global.sh
27
global.sh
|
@ -2,9 +2,22 @@
|
||||||
|
|
||||||
# This file is containing some global function needed for the script such as the config file tools
|
# 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
|
# initializing and reading the retrodeck config file
|
||||||
if [ ! -f $rd_conf ]
|
if [ ! -f $rd_conf ]
|
||||||
then # I have to initialize the variables as they cannot be red from an empty config file
|
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
|
echo "#!/bin/bash" >> $rd_conf
|
||||||
|
|
||||||
# version info taken from the version file
|
# 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
|
echo "version=$version" >> $rd_conf
|
||||||
|
|
||||||
# the retrodeck home, aka ~/retrodeck
|
# the retrodeck home, aka ~/retrodeck
|
||||||
|
@ -41,7 +60,7 @@ conf_init() {
|
||||||
echo "Loading it"
|
echo "Loading it"
|
||||||
source $rd_conf
|
source $rd_conf
|
||||||
fi
|
fi
|
||||||
}
|
#}
|
||||||
|
|
||||||
conf_write() {
|
conf_write() {
|
||||||
# writes the variables in the retrodeck config file
|
# writes the variables in the retrodeck config file
|
||||||
|
|
|
@ -61,7 +61,7 @@ modules:
|
||||||
# This module is used to define the RetroDECK version
|
# 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
|
# 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
|
# 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 STEPS FOR MAIN:
|
||||||
# [ ] Update the VERSION variable
|
# [ ] Update the VERSION variable
|
||||||
|
|
42
retrodeck.sh
42
retrodeck.sh
|
@ -1,17 +1,7 @@
|
||||||
#!/bin/bash
|
#!/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
|
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
|
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
|
||||||
if [ -f "$HOME/retrodeck/.lock" ]
|
if [ -f "$HOME/retrodeck/.lock" ]
|
||||||
|
@ -228,8 +218,8 @@ ra_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
create_lock() {
|
create_lock() {
|
||||||
# creating RetroDECK's lock file and writing the version number in it
|
# creating RetroDECK's lock file and writing the version in the config file
|
||||||
echo "$version" > "$lockfile"
|
touch "$lockfile"
|
||||||
conf_write
|
conf_write
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +428,7 @@ finit() {
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
-h*|--help*)
|
-h*|--help*)
|
||||||
echo "RetroDECK v""$(cat /var/config/retrodeck/version)"
|
echo "RetroDECK v""$version"
|
||||||
echo "
|
echo "
|
||||||
Usage:
|
Usage:
|
||||||
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
|
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
|
||||||
|
@ -459,12 +449,12 @@ https://retrodeck.net
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--version*|-v*)
|
--version*|-v*)
|
||||||
conf_init
|
#conf_init
|
||||||
echo "RetroDECK v$version"
|
echo "RetroDECK v$version"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--info-msg*)
|
--info-msg*)
|
||||||
conf_init
|
#conf_init
|
||||||
echo "RetroDECK v$version"
|
echo "RetroDECK v$version"
|
||||||
echo "RetroDECK config file is in: $rd_conf"
|
echo "RetroDECK config file is in: $rd_conf"
|
||||||
echo "Contents:"
|
echo "Contents:"
|
||||||
|
@ -497,23 +487,27 @@ https://retrodeck.net
|
||||||
done
|
done
|
||||||
|
|
||||||
# UPDATE TRIGGERED
|
# UPDATE TRIGGERED
|
||||||
# if lockfile exists but the version doesn't match
|
# if lockfile exists
|
||||||
if [ -f "$lockfile" ] && [ "$(cat "$lockfile")" != "$version" ];
|
if [ -f "$lockfile" ]
|
||||||
then
|
then
|
||||||
echo "Lockfile version is "$(cat "$lockfile")" but the actual version is $version"
|
|
||||||
conf_init # Initializing/reading the config file (sourced from global.sh)
|
#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
|
post_update # Executing post update script
|
||||||
conf_write # Writing variables in the config file (sourced from global.sh)
|
conf_write # Writing variables in the config file (sourced from global.sh)
|
||||||
start_retrodeck
|
start_retrodeck
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# LOCKFILE REMOVED
|
# 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 the lock file doesn't exist at all means that it's a fresh install or a triggered reset
|
||||||
if [ ! -f "$lockfile" ];
|
else
|
||||||
then
|
|
||||||
echo "Lockfile not found"
|
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
|
finit # Executing First/Force init
|
||||||
conf_write # Writing variables in the config file (sourced from global.sh)
|
conf_write # Writing variables in the config file (sourced from global.sh)
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue