Compare commits
30 Commits
1.0.2
...
279c886c07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
279c886c07 | ||
|
|
415d65ac1c | ||
|
|
6d00aefb21 | ||
|
|
2c782808ed | ||
|
|
ba8af23f42 | ||
|
|
c5da839c5b | ||
| a575bcbf46 | |||
|
|
06658b59d3 | ||
| 2f914cf8d9 | |||
|
|
b362f2e37f | ||
|
|
8eb3d1eef1 | ||
|
|
2b91706d86 | ||
|
|
933d182244 | ||
| 153249211a | |||
| c5765ca952 | |||
| 2bcf430dfd | |||
|
|
bc7d30ea59 | ||
|
|
e23001223c | ||
|
|
4a7a854f6f | ||
|
|
5804346e42 | ||
|
|
43fcc62014 | ||
|
|
a9ba3698bd | ||
|
|
8e3a28334e | ||
| f808a394aa | |||
|
|
97398388d6 | ||
|
|
0839a78d41 | ||
| 43b529d2d0 | |||
| 81cc2b14ab | |||
|
|
42c3275e19 | ||
| 283b42bce1 |
+1
-1
@@ -20,4 +20,4 @@ COPY scripts/scheduler/*.sh /scripts/
|
|||||||
RUN find ./scripts -name "*.sh" | xargs dos2unix
|
RUN find ./scripts -name "*.sh" | xargs dos2unix
|
||||||
RUN ["chmod", "+x", "-R", "/scripts/"]
|
RUN ["chmod", "+x", "-R", "/scripts/"]
|
||||||
|
|
||||||
ENTRYPOINT ["/scripts/entrypoint.sh"]
|
CMD /scripts/entrypoint.sh
|
||||||
+103
-13
@@ -111,8 +111,6 @@ create_htpasswd_file() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install -m 664 -g 65534 /dev/null
|
|
||||||
|
|
||||||
deploy_additionals() {
|
deploy_additionals() {
|
||||||
|
|
||||||
local DIR="$1"
|
local DIR="$1"
|
||||||
@@ -160,14 +158,80 @@ remove_additionals() {
|
|||||||
|
|
||||||
debug "UNINSTALL: $NAME"
|
debug "UNINSTALL: $NAME"
|
||||||
|
|
||||||
|
# delete firewall rules
|
||||||
|
FIREWALLS=""
|
||||||
|
FIREWALLS="$(ls $SERVICE_DIR/firewall-*.json | grep $NAME)"
|
||||||
|
for FIREWALL in $(echo $FIREWALLS); do
|
||||||
|
cat $FIREWALL | jq '.containers[] |= (
|
||||||
|
if (.ENVS | map(has("OPERATION")) | any) then
|
||||||
|
# If any entry has OPERATION key, update it
|
||||||
|
.ENVS = [.ENVS[] | if has("OPERATION") then {"OPERATION": "DELETE"} else . end]
|
||||||
|
else
|
||||||
|
# If no entry has OPERATION key, add new entry
|
||||||
|
.ENVS += [{"OPERATION": "DELETE"}]
|
||||||
|
end
|
||||||
|
)' >$FIREWALL.tmp
|
||||||
|
debug "$service_exec $FIREWALL.tmp start info"
|
||||||
|
$service_exec $FIREWALL.tmp start info
|
||||||
|
rm $FIREWALL.tmp
|
||||||
|
done
|
||||||
|
|
||||||
|
# delete domains
|
||||||
|
DOMMAINS=""
|
||||||
|
DOMAINS="$(ls $SERVICE_DIR/domain-*.json | grep $NAME)"
|
||||||
|
for DOMAIN in $(echo $DOMAINS); do
|
||||||
|
cat $DOMAIN | jq '.containers[] |= (
|
||||||
|
if (.ENVS | map(has("OPERATION")) | any) then
|
||||||
|
# If any entry has OPERATION key, update it
|
||||||
|
.ENVS = [.ENVS[] | if has("OPERATION") then {"OPERATION": "DELETE"} else . end]
|
||||||
|
else
|
||||||
|
# If no entry has OPERATION key, add new entry
|
||||||
|
.ENVS += [{"OPERATION": "DELETE"}]
|
||||||
|
end
|
||||||
|
)' >$DOMAIN.tmp
|
||||||
|
debug "$service_exec $DOMAIN.tmp start info"
|
||||||
|
$service_exec $DOMAIN.tmp start info
|
||||||
|
rm $DOMAIN.tmp
|
||||||
|
done
|
||||||
|
|
||||||
|
# remove related directories and files
|
||||||
|
# get volume destinations
|
||||||
|
DESTINATIONS=""
|
||||||
|
VOLUMES=""
|
||||||
|
DESTINATIONS=$(cat $SERVICE_DIR/service-$NAME.json | jq -r '[.containers[] | select(has("VOLUMES")) | .VOLUMES[] | select(.SHARED != "true") | .SOURCE] | unique[]' | grep $NAME)
|
||||||
|
for DESTINATION in $(echo $DESTINATIONS); do
|
||||||
|
if [ -d "$DESTINATION" ] || [ -f "$DESTINATION" ]; then
|
||||||
|
rm -rf $DESTINATION
|
||||||
|
debug "deleted directory or file: $DESTINATION"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ENV_FILES=$(cat $SERVICE_DIR/service-$NAME.json | jq -r '[.containers[] | select(has("ENV_FILES")) | .ENV_FILES[]] | unique[]')
|
||||||
|
for ENV_FILE in $(echo $ENV_FILES); do
|
||||||
|
if [ -f "$ENV_FILE" ]; then
|
||||||
|
rm -rf $ENV_FILE
|
||||||
|
debug "deleted enviroment file: $ENV_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
VOLUMES=$(cat $SERVICE_DIR/service-$NAME.json | jq -r '[.containers[] | select(has("VOLUMES")) | .VOLUMES[] | select(.SHARED != "true") | .SOURCE] | unique[]' | grep -vE 'USER|SYSTEM')
|
||||||
|
|
||||||
# stop service
|
# stop service
|
||||||
# force - remove stopped container, docker rm
|
# force - remove stopped container, docker rm
|
||||||
debug "$service_exec service-$NAME.json stop force dns-remove"
|
debug "$service_exec service-$NAME.json stop force dns-remove"
|
||||||
$service_exec service-$NAME.json stop force dns-remove
|
$service_exec service-$NAME.json stop force dns-remove
|
||||||
|
|
||||||
|
for VOLUME in $(echo $VOLUMES | grep -vE 'USER|SYSTEM|SHARED'); do
|
||||||
|
if [ "$(echo $VOLUME | cut -d '/' -f1)" ]; then
|
||||||
|
docker volume rm $VOLUME
|
||||||
|
debug "deleted volume: $VOLUME"
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# remove service files
|
# remove service files
|
||||||
rm $SERVICE_DIR/*"-"$NAME.json # service, domain, etc.
|
rm $SERVICE_DIR/*"-"$NAME.json # service, domain, etc.
|
||||||
rm $SECRET_DIR/$NAME/$NAME.json
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_repositories() {
|
get_repositories() {
|
||||||
@@ -182,10 +246,10 @@ get_repositories() {
|
|||||||
|
|
||||||
BASE=$(basename $REPO | cut -d '.' -f1)
|
BASE=$(basename $REPO | cut -d '.' -f1)
|
||||||
if [ ! -d "/tmp/$BASE" ]; then
|
if [ ! -d "/tmp/$BASE" ]; then
|
||||||
git clone $REPO /tmp/$BASE >/dev/null
|
GIT_HTTP_CONNECT_TIMEOUT=10 GIT_HTTP_TIMEOUT=30 git clone $REPO /tmp/$BASE >/dev/null
|
||||||
else
|
else
|
||||||
cd /tmp/$BASE
|
cd /tmp/$BASE
|
||||||
git pull >/dev/null
|
GIT_HTTP_CONNECT_TIMEOUT=10 GIT_HTTP_TIMEOUT=30 git pull >/dev/null
|
||||||
fi
|
fi
|
||||||
if [ -f "/tmp/$BASE/applications-tree.json" ]; then
|
if [ -f "/tmp/$BASE/applications-tree.json" ]; then
|
||||||
TREES=$TREES" /tmp/$BASE/applications-tree.json"
|
TREES=$TREES" /tmp/$BASE/applications-tree.json"
|
||||||
@@ -550,16 +614,19 @@ upgrade() {
|
|||||||
|
|
||||||
if [ "$NAME" == "web-installer" ]; then
|
if [ "$NAME" == "web-installer" ]; then
|
||||||
|
|
||||||
debug "$service_exec service-framework.containers.webserver start info"
|
debug "$service_exec service-framework.containers.webserver stop force"
|
||||||
$service_exec service-framework.containers.webserver stop force
|
$service_exec service-framework.containers.webserver stop force
|
||||||
|
debug "$service_exec service-framework.containers.webserver start info"
|
||||||
$service_exec service-framework.containers.webserver start info &
|
$service_exec service-framework.containers.webserver start info &
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
debug "$service_exec $NAME.json start info"
|
debug "$service_exec $NAME.json stop force"
|
||||||
$service_exec $NAME.json stop force
|
$service_exec $NAME.json stop force
|
||||||
|
debug "$service_exec $NAME.json start info"
|
||||||
$service_exec $NAME.json start info &
|
$service_exec $NAME.json start info &
|
||||||
fi
|
fi
|
||||||
|
PID=$!
|
||||||
}
|
}
|
||||||
|
|
||||||
execute_task() {
|
execute_task() {
|
||||||
@@ -594,7 +661,7 @@ execute_task() {
|
|||||||
#fi;
|
#fi;
|
||||||
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "INSTALL_STATUS": "'$INSTALL_STATUS'" }' | jq -r . | base64 -w0)
|
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "INSTALL_STATUS": "'$INSTALL_STATUS'" }' | jq -r . | base64 -w0)
|
||||||
|
|
||||||
elif [ "$TASK_NAME" == "letsencrypt" ]; then
|
elif [ "$TASK_NAME" == "request_letsencrypt" ]; then
|
||||||
DOMAINS=$(echo $B64_JSON | base64 -d | jq -r 'keys[]')
|
DOMAINS=$(echo $B64_JSON | base64 -d | jq -r 'keys[]')
|
||||||
for DOMAIN in $(echo $DOMAINS); do
|
for DOMAIN in $(echo $DOMAINS); do
|
||||||
REQUEST=$(echo $B64_JSON | base64 -d | jq -r ".[\"$DOMAIN\"].status")
|
REQUEST=$(echo $B64_JSON | base64 -d | jq -r ".[\"$DOMAIN\"].status")
|
||||||
@@ -604,6 +671,7 @@ execute_task() {
|
|||||||
touch /etc/system/data/ssl/keys/$DOMAIN/new_certificate
|
touch /etc/system/data/ssl/keys/$DOMAIN/new_certificate
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
JSON_TARGET=$B64_JSON
|
||||||
|
|
||||||
elif [ "$TASK_NAME" == "system" ]; then
|
elif [ "$TASK_NAME" == "system" ]; then
|
||||||
#SYSTEM_LIST="core-dns.json cron.json domain-local-backend.json firewall-letsencrypt.json firewall-local-backend.json firewall-localloadbalancer-dns.json firewall-localloadbalancer-to-smarthostbackend.json firewall-smarthost-backend-dns.json firewall-smarthost-loadbalancer-dns.json firewall-smarthost-to-backend.json firewall-smarthostloadbalancer-from-publicbackend.json letsencrypt.json local-backend.json local-proxy.json service-framework.json smarthost-proxy-scheduler.json smarthost-proxy.json"
|
#SYSTEM_LIST="core-dns.json cron.json domain-local-backend.json firewall-letsencrypt.json firewall-local-backend.json firewall-localloadbalancer-dns.json firewall-localloadbalancer-to-smarthostbackend.json firewall-smarthost-backend-dns.json firewall-smarthost-loadbalancer-dns.json firewall-smarthost-to-backend.json firewall-smarthostloadbalancer-from-publicbackend.json letsencrypt.json local-backend.json local-proxy.json service-framework.json smarthost-proxy-scheduler.json smarthost-proxy.json"
|
||||||
@@ -730,18 +798,22 @@ execute_task() {
|
|||||||
elif [ "$TASK_NAME" == "deployments" ]; then
|
elif [ "$TASK_NAME" == "deployments" ]; then
|
||||||
DEPLOYMENTS=""
|
DEPLOYMENTS=""
|
||||||
TREES=$(get_repositories)
|
TREES=$(get_repositories)
|
||||||
for TREE in $TREES; do
|
for TREE in "$TREES"; do
|
||||||
APPS=$(jq -rc '.apps[]' $TREE)
|
APPS=$(jq -rc '.apps[]' $TREE)
|
||||||
for APP in $APPS; do
|
#for APP in "$APPS"; do #space problem
|
||||||
|
while IFS= read -r APP; do
|
||||||
APP_NAME=$(echo "$APP" | jq -r '.name')
|
APP_NAME=$(echo "$APP" | jq -r '.name')
|
||||||
|
APP_SUBTITLE="$(echo "$APP" | jq -r '.subtitle')"
|
||||||
APP_VERSION=$(echo "$APP" | jq -r '.version')
|
APP_VERSION=$(echo "$APP" | jq -r '.version')
|
||||||
|
APP_ICON=$(echo "$APP" | jq -r '.icon')
|
||||||
if [ "$DEPLOYMENTS" != "" ]; then
|
if [ "$DEPLOYMENTS" != "" ]; then
|
||||||
SEP=","
|
SEP=","
|
||||||
else
|
else
|
||||||
SEP=""
|
SEP=""
|
||||||
fi
|
fi
|
||||||
DEPLOYMENTS=$DEPLOYMENTS$SEP'"'$APP_NAME'": "'$APP_VERSION'"'
|
DEPLOYMENTS="$DEPLOYMENTS"$SEP'"'$APP_NAME'": {"subtitle": "'"$APP_SUBTITLE"'", "version": "'"$APP_VERSION"'", "icon":
|
||||||
done
|
"'"$APP_ICON"'"}'
|
||||||
|
done < <(echo "$APPS") # preserve DEPLOYMENTS variable
|
||||||
done
|
done
|
||||||
if [ "$DEPLOYMENTS" == "" ]; then
|
if [ "$DEPLOYMENTS" == "" ]; then
|
||||||
DEPLOYMENTS='"deployments": "NONE"'
|
DEPLOYMENTS='"deployments": "NONE"'
|
||||||
@@ -777,6 +849,7 @@ execute_task() {
|
|||||||
APPS=$(jq -rc '.apps[]' $TREE)
|
APPS=$(jq -rc '.apps[]' $TREE)
|
||||||
for APP in $APPS; do
|
for APP in $APPS; do
|
||||||
APP_NAME=$(echo "$APP" | jq -r '.name' | awk '{print tolower($0)}')
|
APP_NAME=$(echo "$APP" | jq -r '.name' | awk '{print tolower($0)}')
|
||||||
|
APP_SUBTITLE=$(echo "$APP" | jq -r '.subtitle')
|
||||||
APP_VERSION=$(echo "$APP" | jq -r '.version')
|
APP_VERSION=$(echo "$APP" | jq -r '.version')
|
||||||
APP_DIR=$(dirname $TREE)"/"$APP_NAME
|
APP_DIR=$(dirname $TREE)"/"$APP_NAME
|
||||||
debug "$APP_TEMPLATE"
|
debug "$APP_TEMPLATE"
|
||||||
@@ -830,6 +903,18 @@ execute_task() {
|
|||||||
DEPLOY_PAYLOAD=$(echo "$JSON" | jq -r .PAYLOAD) # base64 list of key-value pairs in JSON
|
DEPLOY_PAYLOAD=$(echo "$JSON" | jq -r .PAYLOAD) # base64 list of key-value pairs in JSON
|
||||||
deploy_additionals "$APP_DIR" "$DEPLOY_NAME" "$DEPLOY_PAYLOAD"
|
deploy_additionals "$APP_DIR" "$DEPLOY_NAME" "$DEPLOY_PAYLOAD"
|
||||||
sh /scripts/check_pid.sh "$PID" "$SHARED" "deploy-$DEPLOY_NAME" "$DATE" "$DEBUG" &
|
sh /scripts/check_pid.sh "$PID" "$SHARED" "deploy-$DEPLOY_NAME" "$DATE" "$DEBUG" &
|
||||||
|
|
||||||
|
elif [ "$DEPLOY_ACTION" == "edit" ]; then
|
||||||
|
JSON_TARGET=""
|
||||||
|
DEPLOY_PAYLOAD=$(echo "$JSON" | jq -r .PAYLOAD) # base64 list of key-value pairs in JSON
|
||||||
|
|
||||||
|
# stop service before edit
|
||||||
|
debug "$service_exec service-$DEPLOY_NAME.json stop force"
|
||||||
|
$service_exec service-$DEPLOY_NAME.json stop force
|
||||||
|
|
||||||
|
deploy_additionals "$APP_DIR" "$DEPLOY_NAME" "$DEPLOY_PAYLOAD"
|
||||||
|
sh /scripts/check_pid.sh "$PID" "$SHARED" "deploy-$DEPLOY_NAME" "$DATE" "$DEBUG" &
|
||||||
|
|
||||||
elif [ "$DEPLOY_ACTION" == "uninstall" ]; then
|
elif [ "$DEPLOY_ACTION" == "uninstall" ]; then
|
||||||
remove_additionals "$APP_DIR" "$DEPLOY_NAME"
|
remove_additionals "$APP_DIR" "$DEPLOY_NAME"
|
||||||
# uninstall has finished
|
# uninstall has finished
|
||||||
@@ -903,15 +988,20 @@ execute_task() {
|
|||||||
CONTAINERS=$(docker ps -a --format '{{.Names}} {{.Status}}' | grep -v framework-scheduler)
|
CONTAINERS=$(docker ps -a --format '{{.Names}} {{.Status}}' | grep -v framework-scheduler)
|
||||||
RESULT=$(echo "$CONTAINERS" | base64 -w0)
|
RESULT=$(echo "$CONTAINERS" | base64 -w0)
|
||||||
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "RESULT": "'$RESULT'" }' | jq -r . | base64 -w0)
|
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "RESULT": "'$RESULT'" }' | jq -r . | base64 -w0)
|
||||||
|
|
||||||
elif [ "$TASK_NAME" == "upgrade" ]; then
|
elif [ "$TASK_NAME" == "upgrade" ]; then
|
||||||
JSON="$(echo $B64_JSON | base64 -d)"
|
JSON="$(echo $B64_JSON | base64 -d)"
|
||||||
NAME=$(echo "$JSON" | jq -r .NAME | awk '{print tolower($0)}')
|
NAME=$(echo "$JSON" | jq -r .NAME | awk '{print tolower($0)}')
|
||||||
if [ "$NAME" == "framework" ]; then
|
if [ "$NAME" == "framework" ]; then
|
||||||
upgrade_scheduler
|
|
||||||
upgrade "web-installer"
|
upgrade "web-installer"
|
||||||
|
upgrade_scheduler
|
||||||
|
#CONTAINERS=$(docker ps -a --format '{{.Names}} {{.Status}}' | grep -E 'framework-scheduler|webserver')
|
||||||
else
|
else
|
||||||
upgrade "$NAME"
|
upgrade "$NAME"
|
||||||
|
#CONTAINERS=$(docker ps -a --format '{{.Names}} {{.Status}}' | grep -w "$NAME")
|
||||||
fi
|
fi
|
||||||
|
#RESULT=$(echo "$CONTAINERS" | base64 -w0)
|
||||||
|
sh /scripts/check_pid.sh "$PID" "$SHARED" "$TASK_NAME-$NAME" "$DATE" "$DEBUG" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$TASK_NAME" != "check_vpn" ]; then
|
if [ "$TASK_NAME" != "check_vpn" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user