mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-27 16:15:42 +00:00
NEW VARIABLES SYSTEM
This commit is contained in:
parent
23e0ebe755
commit
d4a6e1f170
23
global.sh
Executable file
23
global.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is containing some global function needed for the script such as the config file tools
|
||||
|
||||
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
|
||||
touch $rd_conf
|
||||
version="$(cat /app/retrodeck/version)" # version info taken from the version file
|
||||
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck
|
||||
roms_folder="$rdhome/roms" # default roms folder location (intenral)
|
||||
else # i just read the variables
|
||||
source $rd_conf
|
||||
fi
|
||||
}
|
||||
|
||||
conf_write() {
|
||||
# writes the variables in the retrodeck config file
|
||||
sed -i "s%version=.*%version=$version%" $rd_conf
|
||||
sed -i "s%rdhome=.*%rdhome=$rdhome%" $rd_conf
|
||||
sed -i "s%rdhome=.*%rdhome=$roms_folder" $rd_conf
|
||||
}
|
|
@ -1019,6 +1019,9 @@ modules:
|
|||
- cp retrodeck.sh /app/bin/retrodeck.sh
|
||||
- chmod +x /app/bin/retrodeck.sh
|
||||
|
||||
- cp global.sh /app/bin/global.sh
|
||||
- chmod +x /app/bin/global.sh
|
||||
|
||||
# Desktop entry
|
||||
- cp net.retrodeck.retrodeck.desktop /app/share/applications/net.retrodeck.retrodeck.desktop
|
||||
|
||||
|
@ -1074,3 +1077,5 @@ modules:
|
|||
path: net.retrodeck.retrodeck.desktop
|
||||
- type: file
|
||||
path: net.retrodeck.retrodeck.appdata.xml
|
||||
- type: file
|
||||
path: global.sh
|
17
retrodeck.sh
17
retrodeck.sh
|
@ -1,10 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Init default values, this may be overwritten by retrodeck.cfg as it sourced later with global.sh
|
||||
|
||||
lockfile="$HOME/retrodeck/.lock" # where the lockfile is located
|
||||
version="$(cat /app/retrodeck/version)" # version info taken from the version file
|
||||
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodecck
|
||||
emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs
|
||||
sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path
|
||||
rd_conf="/app/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
|
||||
|
||||
source global.sh
|
||||
|
||||
# Functions area
|
||||
|
||||
|
@ -325,7 +330,9 @@ done
|
|||
if [ -f "$lockfile" ] && [ "$(cat "$lockfile")" != "$version" ];
|
||||
then
|
||||
echo "Lockfile version is "$(cat "$lockfile")" but the actual version is $version"
|
||||
post_update
|
||||
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
|
||||
|
@ -335,7 +342,9 @@ fi
|
|||
if [ ! -f "$lockfile" ];
|
||||
then
|
||||
echo "Lockfile not found"
|
||||
finit
|
||||
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
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -d ~/retrodeck/roms ] && [ -d /run/media/mmcblk0p1/retrodeck/roms ]
|
||||
then # found both internal and sd folders
|
||||
zenity --title "RetroDECK" --warning --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="I found a roms folder both in internal and SD Card,\nin order to make this tool useful you should remove one of the two or merge them."
|
||||
source global.sh
|
||||
|
||||
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="Quit" --ok-label "Continue" --text="WARNING: this script is experimental\nplease be sure you back up your data before continuing.\n\nDo you want to continue?"
|
||||
if [ $? == 1 ] #cancel
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -d ~/retrodeck/roms ] && [ ! -d /run/media/mmcblk0p1/retrodeck/roms ]
|
||||
then # found internal folder and not the external
|
||||
roms_path=~/retrodeck
|
||||
new_roms_path=/run/media/mmcblk0p1/retrodeck
|
||||
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="Cancel" --ok-label "Browse" --text="The roms folder is now: $roms_folder\nplease select the new location.\nA retrodeck/roms folder will be created starting from the directory that you selected."
|
||||
if [ $? == 1 ] #cancel
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d ~/retrodeck/roms ] && [ -d /run/media/mmcblk0p1/retrodeck/roms ]
|
||||
then # found external folder and not the internal
|
||||
roms_path=/run/media/mmcblk0p1/retrodeck
|
||||
new_roms_path=~/retrodeck
|
||||
fi
|
||||
new_roms_path="$(zenity --file-selection --title="Choose a new roms folder location" --directory)"/retrodeck/roms
|
||||
|
||||
zenity --title "RetroDECK" --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Should I move the roms from\n\n$roms_path/roms\n\nto\n\n$new_roms_path/roms?"
|
||||
zenity --title "RetroDECK" --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Should I move the roms from\n\n$roms_folder\n\nto\n\n$new_roms_path?"
|
||||
if [ $? == 0 ] #yes
|
||||
then
|
||||
mkdir -p $new_roms_path
|
||||
mv -f $roms_path/roms $new_roms_path/roms
|
||||
mv -f $roms_folder $new_roms_path
|
||||
rm -f /var/config/emulationstation/ROMs
|
||||
ln -s $new_roms_path/roms /var/config/emulationstation/ROMs
|
||||
rm -f $roms_path/roms
|
||||
ln -s $new_roms_path /var/config/emulationstation/ROMs
|
||||
rm -f $roms_folder
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text="Done\nYour roms are now located in:\n\n$roms_folder\n\nPress OK to continue."
|
||||
$roms_folder=$new_roms_path # Updating variable
|
||||
conf_write # Writing variables in the config file (sourced from global.sh)
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue