diff --git a/rootfs/usr/local/etc/docker/init.d/00-aria2c.sh b/rootfs/usr/local/etc/docker/init.d/00-aria2c.sh index d691a94..ed76229 100755 --- a/rootfs/usr/local/etc/docker/init.d/00-aria2c.sh +++ b/rootfs/usr/local/etc/docker/init.d/00-aria2c.sh @@ -40,7 +40,7 @@ get_config="$(find "$www_dir/js" -name 'aria-ng-*.min.js' | grep -v 'f1dd57abb9. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # use this function to update config files - IE: change port __update_conf_files() { - local port="${SERVICE_PORT:-${ARIA2RPCPORT:-8000}}" + local port="${SERVICE_PORT:-8000}" [ -d "$etc_dir" ] || mkdir -p "$etc_dir" [ -d "$data_dir" ] || mkdir -p "$data_dir" [ -d "/data/logs/aria2" ] || mkdir -p "/data/logs/aria2" @@ -50,16 +50,17 @@ __update_conf_files() { rm -Rf "$get_config" ln -sf "$etc_dir/aria-ng.config.js" "$get_config" ln -sf "$etc_dir/aria-ng.config.js" "$www_dir/js/aria-ng-f1dd57abb9.min.js" - __replace "127.0.0.1" "0.0.0.0" "$etc_dir/aria-ng.config.js" fi if [ -n "$RPC_SECRET" ]; then echo "Changing rpc secret to $RPC_SECRET" - if grep -sq "rpc-secret=*" "$etc_dir/aria2.conf"; then - sed -i "s|secret: '',|secret: ''$RPC_SECRET'',|g" "$www_dir/js/aria-ng.config.js" - sed -i "s|rpc-secret=.*|rpc-secret=$RPC_SECRET|g" "$etc_dir/aria2.conf" + if grep -sq "rpc-secret=" "$etc_dir/aria2.conf"; then + __replace "REPLACE_RPC_SECRET" "$RPC_SECRET" "$www_dir/js/aria-ng.config.js" + __replace "REPLACE_RPC_SECRET" "$RPC_SECRET" "$etc_dir/aria2.conf" else echo "rpc-secret=$RPC_SECRET" >>"$etc_dir/aria2.conf" fi + else + __replace "rpc-secret=" "#rpc-secret=" "$etc_dir/aria2.conf" fi return 0 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 6deae33..f127894 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -25,7 +25,7 @@ done WORKDIR="" # set working directory SERVICE_UID="0" # set the user id SERVICE_USER="root" # execute command as another user -SERVICE_PORT="${PORT:-80}" # port which service is listening on +SERVICE_PORT="80" # port which service is listening on EXEC_CMD_BIN="nginx" # command to execute EXEC_CMD_ARGS="-c /etc/nginx/nginx.conf" # command arguments PRE_EXEC_MESSAGE="" # Show message before execute @@ -34,8 +34,9 @@ PRE_EXEC_MESSAGE="" # Show message before execute data_dir="/data" etc_dir="/etc/nginx" conf_dir="/config/nginx" -www_dir="${WWW_ROOT_DIR:-/data/htdocs}" +www_dir="${WWW_ROOT_DIR:-/usr/local/share/ariang}" nginx_bin="$(type -P 'nginx')" +SERVICE_PORT="${ARIA2RPCPORT:-${PORT:-$SERVICE_PORT}}" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # use this function to update config files - IE: change port __update_conf_files() { @@ -44,12 +45,6 @@ __update_conf_files() { chmod -Rf 777 "$data_dir/logs/nginx" [ -d "$etc_dir" ] || mkdir -p "$etc_dir" [ -d "$conf_dir" ] && cp -Rf "$conf_dir/." "$etc_dir/" - if [ "$SSL_ENABLED" = "true" ]; then - __file_copy "$conf_dir/nginx.ssl.conf" "$etc_dir/nginx.conf" - __file_copy "$conf_dir/vhosts.d/default.ssl.conf" "$etc_dir/vhosts.d/default.conf" - fi - [ -f "$etc_dir/nginx.ssl.conf" ] && rm -Rf "$etc_dir/nginx.ssl.conf" - [ -f "$etc_dir/vhosts.d/default.ssl.conf" ] && rm -Rf "$etc_dir/vhosts.d/default.ssl.conf" # [ -d "$www_dir" ] || mkdir -p "$www_dir" [ -d "$www_dir/www/health" ] || mkdir -p "$www_dir/www/health" @@ -58,12 +53,8 @@ __update_conf_files() { # __replace "REPLACE_SERVER_PORT" "${SERVICE_PORT:-80}" "$etc_dir/nginx.conf" __replace "REPLACE_SERVER_PORT" "${SERVICE_PORT:-80}" "$etc_dir/vhosts.d/default.conf" - [ -f "$www_dir/www/index.php" ] && __replace "SERVER_SOFTWARE" "dns" "$www_dir/www/index.php" - [ -f "$www_dir/www/index.html" ] && __replace "SERVER_SOFTWARE" "dns" "$www_dir/www/index.html" - if [ -z "$PHP_BIN_DIR" ]; then - [ -f "$www_dir/www/info.php" ] && echo "PHP support is not enabled" >"$www_dir/www/info.php" - [ -f "$etc_dir/conf.d/php-fpm.conf" ] && echo "# PHP support is not enabled" >"$etc_dir/conf.d/php-fpm.conf" - fi + # + __replace "REPLACE_SERVER_PORT" "${SERVICE_PORT:-80}" "/etc/aria2/aria-ng.config.js" return 0 } diff --git a/rootfs/usr/local/share/template-files/config/aria2/aria-ng.config.js b/rootfs/usr/local/share/template-files/config/aria2/aria-ng.config.js index b078b6c..9d05e30 100755 --- a/rootfs/usr/local/share/template-files/config/aria2/aria-ng.config.js +++ b/rootfs/usr/local/share/template-files/config/aria2/aria-ng.config.js @@ -525,11 +525,11 @@ browserNotification: !1, rpcAlias: 'aria2', rpcHost: '127.0.0.1', - rpcPort: '8000', + rpcPort: 'REPLACE_SERVER_PORT', rpcInterface: 'jsonrpc', protocol: 'http', httpMethod: 'POST', - secret: '', + secret: 'REPLACE_RPC_SECRET', extendRpcServers: [], globalStatRefreshInterval: 1e3, downloadTaskRefreshInterval: 1e3, diff --git a/rootfs/usr/local/share/template-files/config/aria2/aria2.conf b/rootfs/usr/local/share/template-files/config/aria2/aria2.conf index 6afcdd7..5c1b5a7 100644 --- a/rootfs/usr/local/share/template-files/config/aria2/aria2.conf +++ b/rootfs/usr/local/share/template-files/config/aria2/aria2.conf @@ -4,9 +4,10 @@ log=/data/logs/aria2/aria2.log input-file=/config/aria2/aria2.session save-session=/config/aria2/aria2.session enable-rpc=true -rpc-listen-port=8000 +rpc-listen-port=6800 rpc-allow-origin-all=true rpc-listen-all=true +rpc-secret=REPLACE_RPC_SECRET disable-ipv6=true max-concurrent-downloads=5 continue=true diff --git a/rootfs/usr/local/share/template-files/config/nginx/nginx.conf b/rootfs/usr/local/share/template-files/config/nginx/nginx.conf index f9ae15f..6e8bb3b 100644 --- a/rootfs/usr/local/share/template-files/config/nginx/nginx.conf +++ b/rootfs/usr/local/share/template-files/config/nginx/nginx.conf @@ -35,7 +35,7 @@ http { add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval' *; frame-src 'self' *; object-src 'self'" always; location /jsonrpc { - proxy_pass http://127.0.0.1:8000/jsonrpc; + proxy_pass http://127.0.0.1:6800/jsonrpc; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; @@ -43,7 +43,7 @@ http { } location /rpc { - proxy_pass http://127.0.0.1:8000/jsonrpc; + proxy_pass http://127.0.0.1:6800/jsonrpc; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";