summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-12-01 16:16:30 -0600
committerJohn Klug <john.klug@multitech.com>2017-12-01 16:16:30 -0600
commitf03eb4f3d8fbbd1be58a2dde6f1747a328a3bf6d (patch)
treed8e30a9b58581e8b7ddda67a53094c1e1aff29a5
parentca7a7f77d3d9ffccf9f02bd0c74d8356f9445865 (diff)
downloadmeta-mlinux-f03eb4f3d8fbbd1be58a2dde6f1747a328a3bf6d.tar.gz
meta-mlinux-f03eb4f3d8fbbd1be58a2dde6f1747a328a3bf6d.tar.bz2
meta-mlinux-f03eb4f3d8fbbd1be58a2dde6f1747a328a3bf6d.zip
Preserve original WiFi BT settings for factory settings reset
-rw-r--r--recipes-core/multitech/config/config.init35
1 files changed, 31 insertions, 4 deletions
diff --git a/recipes-core/multitech/config/config.init b/recipes-core/multitech/config/config.init
index 2a40c16..f1d43b3 100644
--- a/recipes-core/multitech/config/config.init
+++ b/recipes-core/multitech/config/config.init
@@ -17,9 +17,10 @@ ppp/peers \
# Files used by bluetooth or wifi.
BTWIFIFILES="\
-bluetooth
-default/rs9113 \
+bluetooth \
+default/bluetooth \
default/hostapd \
+default/rs9113 \
dnsmasq.d \
hosts \
hostname \
@@ -28,6 +29,9 @@ modprobe.d \
wpa_supplicant.conf \
"
+# File hidden so it is not removed on hardware reset
+WIFITAR=".defaults2.tar.gz"
+
mount_config() {
echo "Mounting ${CONFIG_DIR}"
mkdir -p ${CONFIG_DIR}
@@ -77,7 +81,10 @@ case $1 in
if [ -f force_defaults ]; then
echo "Extracting default config files"
tar -xvf /etc/defaults.tar.gz
-
+ if [[ -f ${WIFITAR} ]] ; then
+ echo "Extract original wifi related files"
+ tar -xvf ${WIFITAR}
+ fi
if [ -f /etc/default_pass ]; then
echo "Defaulting root password"
PASSHASH=`cat /etc/default_pass`
@@ -110,6 +117,17 @@ case $1 in
# Move bluetooth wifi stuff to config directory.
# We don't have factory defaults.
+ ((dobackup=1))
+ for file in ${BTWIFIFILES}; do
+ if [[ -L /etc/$file ]]; then
+ ((dobackup=0))
+ break
+ fi
+ done
+ if ((dobackup==1)) ; then
+ tar -C /etc -czf ${CONFIG_DIR}/${WIFITAR} ${BTWIFIFILES}
+ fi
+
for file in ${BTWIFIFILES}; do
if [[ ! -L /etc/$file ]]; then
echo "Creating link to ${CONFIG_DIR}/$file"
@@ -117,7 +135,16 @@ case $1 in
if [[ $dir != '.' ]] ; then
mkdir -p "$dir"
fi
- mv /etc/$file ${CONFIG_DIR}/$file
+ rm -rf old
+ mkdir old
+ if ! [[ -f $file ]] ; then
+ # Need to preserve old files which is difficult with busybox!
+ mv $file old
+ (cd /etc;cp -a $file ${CONFIG_DIR})
+ cp -a old/$file .
+ rm -rf old
+ fi
+ rm -rf /etc/$file
ln -sf ${CONFIG_DIR}/$file /etc/$file
fi
done