improve install_app

This commit is contained in:
qiaofeng1227 2023-12-11 16:42:39 +08:00
parent 9f882735ed
commit a03d4a9fc5

View file

@ -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"