reset and revert settings

pull/29/head
Botspot 5 years ago
parent c273d24f70
commit 3c475a358c

@ -16,13 +16,29 @@ while [ -z $exitloop ];do
echo '' > "${DIRECTORY}/data/settings/reinstall-after-update" echo '' > "${DIRECTORY}/data/settings/reinstall-after-update"
fi fi
#$1 is usually left blank. If it equals 'reset', then the settings will be reset and then the script will exit. #$1 is usually left blank. If it equals 'reset', then empty settings will be created and then the script will exit.
if [ "$1" == 'reset' ];then if [ "$1" == 'reset' ];then
#set default settings, if they don't exist #set default settings, if they don't exist
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')" settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS" PREIFS="$IFS"
IFS='|' IFS='|'
for name in $settings for name in $settings
do
if [ ! -f "${DIRECTORY}/data/settings/${name}" ];then
cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}"
fi
done
IFS="$PREIFS"
exit 0
fi
#$1 is usually left blank. If it equals 'revert', then overwrite all settings with the defaults and then the script will exit.
if [ "$1" == 'revert' ];then
#overwrite all settings with the defaults
settings="$(ls "${DIRECTORY}/etc/setting-params" | tr '\n' '|')"
PREIFS="$IFS"
IFS='|'
for name in $settings
do do
cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}" cat "${DIRECTORY}/etc/setting-params/${name}" | grep -v '#' | head -n1 > "${DIRECTORY}/data/settings/${name}"
done done
@ -30,6 +46,7 @@ while [ -z $exitloop ];do
exit 0 exit 0
fi fi
if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then
echo "Creating Settings menu button" echo "Creating Settings menu button"
echo "[Desktop Entry] echo "[Desktop Entry]
@ -94,7 +111,7 @@ ${params}"
if [ $button -eq 2 ];then if [ $button -eq 2 ];then
output='' output=''
"${0}" reset "${0}" revert
else else
exitloop=yes exitloop=yes
fi fi

Loading…
Cancel
Save