add option to replace or backup-restore

This commit is contained in:
bluemeda 2019-04-30 13:33:52 +07:00
parent 6b815b9e85
commit cf7f31ab1f
2 changed files with 25 additions and 16 deletions

View File

@ -56,6 +56,31 @@ else
$FUNCTION "DOWN"
fi
ui_print " "
ui_print " Vol+ = Replace previous config (mandatory for first install)"
ui_print " "
ui_print " Vol- = Use previous config"
ui_print " "
CONFIG_FILE=$MODPATH/system/etc/dnscrypt-proxy/dnscrypt-proxy.toml
if $FUNCTION; then
ui_print "Replace old config"
ui_print " "
cp -af $MODPATH/system/etc/example-dnscrypt-proxy.toml $CONFIG_FILE
sed -i -e 's/127.0.0.1:53/127.0.0.1:5354/g' $CONFIG_FILE
sed -i -e 's/\[::1\]:53/\[::1\]:5354/g' $CONFIG_FILE
else
if [ -f "$CONFIG_FILE" ]; then
ui_print "* Backing up config file"
cp $CONFIG_FILE $TMPDIR
ui_print "* Restoring config files"
cp -af $TMPDIR/dnscrypt-proxy.toml $CONFIG_FILE
else
abort "First install have to choose replace mode"
fi
fi
ui_print " "
ui_print " Vol+ = Auto redirect DNS request with iptables"
ui_print " "

View File

@ -149,14 +149,8 @@ on_install() {
BINARY_PATH=$TMPDIR/binary/dnscrypt-proxy-x86_64
fi
CONFIG_FILE=$MODPATH/system/etc/dnscrypt-proxy/dnscrypt-proxy.toml
CONFIG_PATH=$TMPDIR/config
if [ -f "$CONFIG_FILE" ]; then
ui_print "* Backing up config file"
cp $CONFIG_FILE $TMPDIR
fi
unzip -o "$ZIPFILE" 'config/*' 'binary/*' -d $TMPDIR 2>/dev/null
ui_print "* Creating binary path"
@ -179,16 +173,6 @@ on_install() {
abort "Config file is missing!"
fi
if [ ! -f "$CONFIG_FILE" ]; then
ui_print "* Copying config files"
cp -af $CONFIG_PATH/example-dnscrypt-proxy.toml $CONFIG_FILE
sed -i -e 's/127.0.0.1:53/127.0.0.1:5354/g' $CONFIG_FILE
sed -i -e 's/\[::1\]:53/\[::1\]:5354/g' $CONFIG_FILE
else
ui_print "* Restoring config files"
cp -af $TMPDIR/dnscrypt-proxy.toml $CONFIG_FILE
fi
. $TMPDIR/option.sh
}