Simplyfing variable system - step 2

This commit is contained in:
XargonWan 2022-09-06 15:24:36 +02:00 committed by GitHub
parent 481b2f8c55
commit f2c6dd59bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 53 deletions

View file

@ -2,65 +2,37 @@
# 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
# Static variables
rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path
emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs
lockfile="/var/config/retrodeck/.lock" # where the lockfile is located
sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path
hard_version="$(cat '/app/retrodeck/version')" # hardcoded version (in the readonly filesystem)
# if everything is working put this stuff down there
# If there is no config file I initalize the file with the the default values
if [ ! -f $rd_conf ] if [ ! -f $rd_conf ]
then 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
echo "RetroDECK config file not found in $rd_conf" echo "RetroDECK config file not found in $rd_conf"
echo "Initializing" echo "Initializing"
touch $rd_conf
# Variables to manage: adding a variable here means adding it to conf_write()
echo "#!/bin/bash" >> $rd_conf echo "#!/bin/bash" >> $rd_conf
version="$hard_version" # if we are here means that the we are in a new installation, so the version is valorized with the hardcoded one
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck
roms_folder="$rdhome/roms" # the default roms folder path
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
# version info taken from the version file # writing the needed variables in the config file
# if the version variable is not set means that is a first installation, so we populate with the hardcoded version conf_write
if [ -z $version ]
then
version="$hard_version"
#else
# version="$version"
fi
echo "version=$version" >> $rd_conf
# the retrodeck home, aka ~/retrodeck # If the config file is existing i just read the variables (source it)
rdhome="$HOME/retrodeck" else
echo "rdhome=$rdhome" >> $rd_conf
# default roms folder location (internal)
roms_folder="$roms_folder"
echo "roms_folder=$roms_folder" >> $rd_conf
# default media folder location (internal)
media_folder="$media_folder"
echo "media_folder=$media_folder" >> $rd_conf
# default themes folder location (internal)
themes_folder="$themes_folder"
echo "themes_folder=$themes_folder" >> $rd_conf
else # i just read the variables
echo "Found RetroDECK config file in $rd_conf" echo "Found RetroDECK config file in $rd_conf"
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

View file

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
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" ]