diff --git a/Dockerfile b/Dockerfile index 52431c5..c6b3062 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ARG USER="root" ARG SHELL_OPTS="set -e -o pipefail" ARG SERVICE_PORT="80" -ARG EXPOSE_PORTS="80 9053 9050 9080" +ARG EXPOSE_PORTS="80 8118 9050 9053 9080 9053/udp" ARG PHP_VERSION="84" ARG NODE_VERSION="system" ARG NODE_MANAGER="system" 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 9155eb3..969f3a0 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -275,8 +275,13 @@ __update_conf_files() { # __replace "" "" "$CONF_DIR/nginx.conf" # replace variables recursively # __find_replace "" "" "$CONF_DIR" - if [ -n "$default_host" ] && [ -f "$WWW_ROOT_DIR/index.html" ]; then - sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host'|g' "$WWW_ROOT_DIR/index.html" + if [ -f "$WWW_ROOT_DIR/index.html" ]; then + sed -i 's|REPLACE_ONION_WWW_DIR|'$WWW_ROOT_DIR'|g' "/data/htdocs/www/index.html" + [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "$WWW_ROOT_DIR/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "$WWW_ROOT_DIR/index.html" + fi + if [ -f "/data/htdocs/www/index.html" ]; then + sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/www|g' "/data/htdocs/www/index.html" + [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "/data/htdocs/www/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "/data/htdocs/www/index.html" fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # define actions @@ -294,10 +299,8 @@ __update_conf_files() { onion_site="$(basename -- $site)" __onion_site_dir_is_empty "$onion_site" && NEW_SITE="yes" [ -d "/data/htdocs/onions/$onion_site" ] || mkdir -p "/data/htdocs/onions/$onion_site" - if [ "$default_host" = "$onion_site" ]; then - if __onion_site_dir_is_empty "$onion_site"; then - cp -Rfa "$WWW_ROOT_DIR/." "/data/htdocs/onions/$onion_site/" - fi + if [ "$default_host" = "$onion_site" ] && __onion_site_dir_is_empty "$onion_site"; then + cp -Rfa "$WWW_ROOT_DIR/." "/data/htdocs/onions/$onion_site/" else if [ "$NEW_SITE" = "yes" ]; then if [ -f "/usr/share/httpd/default/hidden_services.html" ]; then @@ -309,11 +312,16 @@ __update_conf_files() { fi if [ ! -f "/config/nginx/vhosts.d/$onion_site.onion.conf" ]; then cp -Rf "/config/nginx/vhosts.d/template" "/config/nginx/vhosts.d/$onion_site.onion.conf" + fi + if [ -f "/config/nginx/vhosts.d/$onion_site.onion.conf" ]; then sed -i 's|REPLACE_ONION_PORT|'$SERVICE_PORT'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" 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" + fi + if [ -f "/data/htdocs/onions/$onion_site/index.html" ]; then + sed -i 's|REPLACE_ONION_ADDRESS|'$onion_site.onion'|g' "/data/htdocs/onions/$onion_site/index.html" sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" + sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" fi unset NEW_SITE echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site"