From a03d4a9fc5d28f98c7e17e3216be11d293d47b69 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Mon, 11 Dec 2023 16:42:39 +0800 Subject: [PATCH] improve install_app --- scripts/install_app.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/scripts/install_app.sh b/scripts/install_app.sh index da6ef33b..80004a0e 100644 --- a/scripts/install_app.sh +++ b/scripts/install_app.sh @@ -97,6 +97,7 @@ while [[ $# -gt 0 ]]; do done check_appname() { + rm -rf /tmp/library && sudo docker cp websoft9-apphub:/websoft9/library /tmp if [ -z "$appname" ]; then echo "appname cannot be empty" exit 1 @@ -113,18 +114,6 @@ get_public_ip() { echo "$public_ip" } -get_domain_names() { - local domain_names="$1" - local public_ip="$2" - local ip_regex="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" - if [ -z "$domain_names" ]; then - domain_names="$public_ip" - elif [[ $domain_names =~ $ip_regex ]]; then - domain_names="$domain_names" - fi - echo "$domain_names" -} - get_proxy_enabled() { local domain_names="$1" local ip_regex="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" @@ -148,9 +137,13 @@ install_app(){ check_appname public_ip=$(get_public_ip) - domain_names=$(get_domain_names "$domain_names" "$public_ip") + local ip_regex="^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" + if [ -z "$domain_names" ]; then + domain_names="$public_ip" + elif [[ $domain_names =~ $ip_regex ]]; then + domain_names="$domain_names" + fi proxy_enabled=$(get_proxy_enabled "$domain_names") - rm -rf /tmp/library && sudo docker cp websoft9-apphub:/websoft9/library /tmp filename="/tmp/library/apps/${appname}/.env" settings=$(get_settings "${filename}") api_url="localhost/api/apps/install"