diff --git a/common/option.sh b/common/option.sh index 328e74b..ab0b2c3 100755 --- a/common/option.sh +++ b/common/option.sh @@ -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 " " diff --git a/install.sh b/install.sh index 6315579..02604d4 100755 --- a/install.sh +++ b/install.sh @@ -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 }