diff --git a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh index 8cfa5af..ae1e64a 100755 --- a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh +++ b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh @@ -20,8 +20,11 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Exit if service is disabled +[ -z "$TOR_BRIDGE_ENABLED" ] || [ "$TOR_BRIDGE_ENABLED" = "no" ] || [ "$TOR_BRIDGE_ENABLED" != "false" ] || exit 0 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" @@ -237,9 +240,8 @@ __update_conf_files() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # define actions - if [ "$TOR_BRIDGE_ENABLED" = "yes" ]; then - mkdir -p "$CONF_DIR/conf.d" - cat <>"$CONF_DIR/bridge.conf" + mkdir -p "$CONF_DIR/conf.d" + cat <>"$CONF_DIR/bridge.conf" ##### Bridge RunAsDaemon 0 HardwareAccel 1 @@ -281,10 +283,7 @@ AccountingStart month 1 00:00 %include $CONF_DIR/conf.d/*.conf EOF - [ -f "$CONF_DIR/conf.d/default.conf" ] || touch "$CONF_DIR/conf.d/default.conf" - else - unset EXEC_CMD_BIN EXEC_CMD_ARGS - fi + [ -f "$CONF_DIR/conf.d/default.conf" ] || touch "$CONF_DIR/conf.d/default.conf" if [ "$TOR_DEBUG" = "yes" ]; then sed -i 's|#Log debug|Log debug|g' "$CONF_DIR/bridge.conf" fi diff --git a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh index c8901e2..c7c07a8 100755 --- a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh +++ b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh @@ -20,8 +20,11 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Exit if service is disabled +[ -z "$TOR_RELAY_ENABLED" ] || [ "$TOR_RELAY_ENABLED" = "no" ] || [ "$TOR_RELAY_ENABLED" != "false" ] || exit 0 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" @@ -237,9 +240,8 @@ __update_conf_files() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # define actions - if [ "$TOR_RELAY_ENABLED" = "yes" ]; then - mkdir -p "$CONF_DIR/conf.d" - cat <"$CONF_DIR/relay.conf" + mkdir -p "$CONF_DIR/conf.d" + cat <"$CONF_DIR/relay.conf" ##### Relay RunAsDaemon 0 HardwareAccel 1 @@ -282,10 +284,7 @@ DirPortFrontPage /usr/share/tor/html/exit.html %include $CONF_DIR/conf.d/*.conf EOF - [ -f "$CONF_DIR/conf.d/default.conf" ] || touch "$CONF_DIR/conf.d/default.conf" - else - unset EXEC_CMD_BIN EXEC_CMD_ARGS - fi + [ -f "$CONF_DIR/conf.d/default.conf" ] || touch "$CONF_DIR/conf.d/default.conf" if [ "$TOR_DEBUG" = "yes" ]; then sed -i 's|#Log debug|Log debug|g' "$CONF_DIR/relay.conf" fi diff --git a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh index f6283b0..9a8449c 100755 --- a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh +++ b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh @@ -21,7 +21,7 @@ # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" @@ -379,9 +379,10 @@ __post_execute() { d="$(dirname -- $host)" name="$(basename "$d")" url="$(<"$host")" + site="$(echo "$url" | sed 's|\.onion$||g')" echo "$name: $url" + touch "/run/tor/sites/$site" echo ''$name'
' >>"$WWW_ROOT_DIR/hostnames.html" - touch "/run/tor/sites/${url//.onion/}" done echo "End current hidden services" fi diff --git a/rootfs/usr/local/etc/docker/init.d/09-unbound.sh b/rootfs/usr/local/etc/docker/init.d/09-unbound.sh index 484ca6d..e985025 100755 --- a/rootfs/usr/local/etc/docker/init.d/09-unbound.sh +++ b/rootfs/usr/local/etc/docker/init.d/09-unbound.sh @@ -21,7 +21,7 @@ # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" diff --git a/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh b/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh index c4f88d5..8ffd724 100755 --- a/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh +++ b/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh @@ -21,7 +21,7 @@ # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" diff --git a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh index a4d24f1..01542ca 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -21,7 +21,7 @@ # shellcheck disable=SC1003,SC2016,SC2031,SC2120,SC2155,SC2199,SC2317 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # run trap command on exit -trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM EXIT +trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGINT SIGTERM ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}" @@ -271,6 +271,7 @@ __update_conf_files() { sed -i 's|REPLACE_ONION_SITE|'$onion_site.onion'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" + sed -i 's|imtulbcjer7mohs62lpycyod2c3pnil2x6xjirrojedbluh4d7z2g6ad|'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" fi echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site" done