Merge pull request #350 from fewtarius/dev

Dev
This commit is contained in:
fewtarius 2022-08-14 19:01:26 -04:00 committed by GitHub
commit 9065a5017a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 8 deletions

View file

@ -19,24 +19,25 @@ get_setting() {
then
### Test to see if we have a game setting.
VAR="$2\[\"$(echo ${3} | sed 's/[\(\)]/\\&/g')\"\]\.$1"
OUTPUT=$(awk 'BEGIN {FS="="} /'"^${VAR}"'/ {print $NF}' ${J_CONF})
OUTPUT=$(awk 'BEGIN {FS="="} /^'"${VAR}"'/ {print $NF}' ${J_CONF})
if [ ! -z "${OUTPUT}" ]
then
echo ${OUTPUT}
return
else
### If not, check to see if we have a system setting.
awk -F: '/'^${2}.${1}'/ { st = index($0,"=");print substr($0,st+1)}' ${J_CONF}
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
fi
elif [ -z "${3}" ] && [ ! -z "${2}" ]
then
### Check to see if we have a system setting.
awk -F: '/'^${2}.${1}'/ { st = index($0,"=");print substr($0,st+1)}' ${J_CONF}
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
else
### Check to see if we have a global setting
awk -F: '/'^${1}'/ { st = index($0,"=");print substr($0,st+1)}' ${J_CONF}
awk -F: '/^'"${1}"='/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
fi
}

View file

@ -32,7 +32,6 @@ then
set_setting system.cpugovernor interactive
fi
### Make sure there are no invalid characters in system.cfg
### or ES will not start.
cp /storage/.config/system/configs/system.cfg /storage/.config/system/configs/last_system.cfg
grep -ai "^[A-Z|a-z]" /storage/.config/system/configs/last_system.cfg >/storage/.config/system/configs/system.cfg
### Test for binary data in system.cfg and clean it
### if it exists.
/usr/bin/clean_sysconfig

View file

@ -0,0 +1,56 @@
#!/bin/bash
###
### Attempt to safely clean any binary data out of the system config.
###
. /etc/profile
J_DIR="/storage/.config/system"
L_CONF="${J_DIR}/configs/last_system.cfg"
get_setting() {
if [ ! -z "${3}" ]
then
### Test to see if we have a game setting.
VAR="$2\[\"$(echo ${3} | sed 's/[\(\)]/\\&/g')\"\]\.$1"
OUTPUT=$(awk 'BEGIN {FS="="} /^'"${VAR}"'/ {print $NF}' ${L_CONF})
if [ ! -z "${OUTPUT}" ]
then
echo ${OUTPUT}
return
else
### If not, check to see if we have a system setting.
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${L_CONF}
return
fi
elif [ -z "${3}" ] && [ ! -z "${2}" ]
then
### Check to see if we have a system setting.
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${L_CONF}
return
else
### Check to see if we have a global setting
awk -F: '/^'"${1}"='/ { st = index($0,"=");print substr($0,st+1);exit}' ${L_CONF}
return
fi
}
cd /storage/.config/system/configs
cp system.cfg last_system.cfg
TYPE=$(grep a system.cfg 2>&1)
if [[ "${TYPE}" =~ binary ]]
then
cp /usr/config/system/configs/system.cfg .
awk 'BEGIN {FS="="} /^[A-z]/ {print $1}' last_system.cfg >/tmp/keys
while read line;
do
if [[ "${line}" =~ \[ ]]
then
continue
fi
if [ -n "${line}" ]
then
set_setting ${line} "$(get_setting ${line})"
fi
done < /tmp/keys
fi