40 Commits

Author SHA1 Message Date
gyurix
933d182244 Reorder upgrade calls in entrypoint script for framework and web-installer
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-05-21 11:07:50 +02:00
153249211a Update Dockerfile
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-21 09:07:24 +00:00
c5765ca952 Merge branch 'main' of https://git.format.hu/safebox/framework-scheduler
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:25:48 +00:00
2bcf430dfd upgrade debug 2025-05-15 13:25:02 +00:00
gyurix
bc7d30ea59 Reorder service stop command in entrypoint script for clarity during removal process
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-05-15 14:43:02 +02:00
gyurix
e23001223c Refactor service removal process in entrypoint script to streamline deletion of directories, files, and Docker volumes
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 14:06:09 +02:00
gyurix
4a7a854f6f Comment out service file removal in entrypoint script
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:54:12 +02:00
gyurix
5804346e42 Fix volume destination filtering in removal process
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:51:31 +02:00
gyurix
43fcc62014 Filter destinations by service name in removal process
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:28:27 +02:00
gyurix
a9ba3698bd Enhance entrypoint script to delete both volume destinations and Docker volumes during service removal
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:20:31 +02:00
gyurix
8e3a28334e Remove temporary firewall and domain files during service removal
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 13:01:30 +02:00
f808a394aa uninsall fix
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 11:00:15 +00:00
gyurix
97398388d6 Merge branch 'main' of https://git.format.hu/safebox/framework-scheduler
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 11:24:08 +02:00
gyurix
0839a78d41 Enhance entrypoint script to clean up environment files, volume destinations, firewall rules, and domains during service removal 2025-05-15 11:24:06 +02:00
43b529d2d0 PID
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 08:46:33 +00:00
81cc2b14ab upgrade check_pid
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-15 08:25:44 +00:00
gyurix
42c3275e19 Improve git clone and pull commands with timeout settings; update JSON_TARGET handling in task execution
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-05-13 13:12:16 +02:00
283b42bce1 rename letsencrypt task
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-07 16:16:40 +00:00
gyurix
fe5ffd3add Fix service execution commands in entrypoint script for web-installer
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-05-07 09:55:07 +02:00
gyurix
bc87393fba Add logic to handle new certificate requests in letsencrypt task
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is passing
2025-05-06 16:09:34 +02:00
gyurix
f9d43d43f9 Enhance task execution logic to handle new certificate requests and improve debug output formatting
Some checks failed
continuous-integration/drone/push Build is failing
2025-05-06 15:55:08 +02:00
ee0b103593 commented environment variables from drone
Some checks failed
continuous-integration/drone/push Build is failing
2025-05-06 12:14:20 +00:00
6cd309eb9a do not log check_vpn.json file created
Some checks failed
continuous-integration/drone/push Build is failing
2025-05-06 08:21:12 +00:00
93aebc5251 do not log check_vpn
Some checks reported errors
continuous-integration/drone/push Build was killed
2025-05-06 08:17:04 +00:00
gyurix
513b3f9f6a Remove unnecessary blank line in Drone CI configuration
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-28 08:13:25 +02:00
gyurix
dd9f1a1c2f Add Docker plugin mirror configuration to Drone CI pipeline
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-28 08:03:58 +02:00
gyurix
de3896d5ca Fix Drone CI configuration by correcting indentation and updating mirror key
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-28 07:55:57 +02:00
gyurix
6bc1120a64 Refactor Drone CI configuration for Docker image handling and secret management
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-28 07:54:11 +02:00
gyurix
f7c6ce03ea Merge branch 'main' of https://git.format.hu/safebox/framework-scheduler
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-28 07:48:39 +02:00
gyurix
e1e69d5212 Update node selector in Drone CI configuration to use dev1 2025-04-28 07:48:25 +02:00
gyurix
ca0fbeea73 Add Docker mirror configuration to Drone CI pipeline 2025-04-28 07:47:51 +02:00
f2c82d24e2 Update .drone.yml
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-23 22:33:13 +00:00
0fdbac0ea8 Update .drone.yml
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2025-04-23 22:10:45 +00:00
638f51eaa6 Update .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
2025-04-23 21:49:19 +00:00
0f9850d6f8 Update .drone.yml
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-23 20:02:02 +00:00
c26a2f6efb Update .drone.yml
Some checks failed
continuous-integration/drone/push Build is failing
2025-04-23 19:53:37 +00:00
5af97a3714 Update .drone.yml
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2025-04-23 19:42:02 +00:00
6d73464c70 Update .drone.yml
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2025-04-23 16:23:32 +00:00
gyurix
ea9c55b6bf Add apache2-utils to Dockerfile and implement htpasswd file creation in entrypoint script
All checks were successful
continuous-integration/drone/push Build is passing
2025-04-22 11:56:42 +02:00
3088f3904f service- prefix removed from upgrade
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-28 20:52:58 +01:00
3 changed files with 172 additions and 73 deletions

View File

@@ -3,7 +3,7 @@ type: kubernetes
name: default name: default
node_selector: node_selector:
physical-node: dev2 physical-node: dev1
trigger: trigger:
event: event:
@@ -14,26 +14,6 @@ workspace:
path: /drone/src path: /drone/src
steps: steps:
- name: build multiarch from dev
image: docker.io/owncloudci/drone-docker-buildx:4
privileged: true
settings:
cache-from: [ "registry.dev.format.hu/framework-scheduler" ]
registry: registry.dev.format.hu
repo: registry.dev.format.hu/framework-scheduler
tags: latest
dockerfile: Dockerfile
username:
from_secret: dev-hu-registry-username
password:
from_secret: dev-hu-registry-password
platforms:
- linux/amd64
- linux/arm64
when:
event:
- push
- name: pull image to dockerhub - name: pull image to dockerhub
image: docker.io/owncloudci/drone-docker-buildx:4 image: docker.io/owncloudci/drone-docker-buildx:4
privileged: true privileged: true
@@ -51,3 +31,25 @@ steps:
when: when:
event: event:
- tag - tag
- name: build multiarch from dev
image: docker.io/owncloudci/drone-docker-buildx:4
privileged: true
#environment:
# DOCKER_PLUGIN_MIRROR: "https://mirror.dev.format.hu"
settings:
cache-from: [ "registry.dev.format.hu/framework-scheduler" ]
registry: registry.dev.format.hu
repo: registry.dev.format.hu/framework-scheduler
tags: latest
dockerfile: Dockerfile
username:
from_secret: dev-hu-registry-username
password:
from_secret: dev-hu-registry-password
platforms:
- linux/amd64
- linux/arm64
when:
event:
- push

View File

@@ -14,10 +14,10 @@ FROM alpine:latest
# COPY --from=redis-source /usr/src/redis/src/redis-cli /usr/bin/redis-cli # COPY --from=redis-source /usr/src/redis/src/redis-cli /usr/bin/redis-cli
# RUN chmod +x /usr/bin/redis-cli # RUN chmod +x /usr/bin/redis-cli
RUN apk add --update --no-cache docker-cli wget curl dos2unix jq openssl git coreutils inotify-tools acl RUN apk add --update --no-cache docker-cli wget curl dos2unix jq openssl git coreutils inotify-tools acl apache2-utils
COPY scripts/scheduler/*.sh /scripts/ 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

View File

@@ -30,6 +30,7 @@ REDIS_VERSION=${REDIS_VERSION:-latest}
SOURCE=${SOURCE:-user-config} SOURCE=${SOURCE:-user-config}
SMARTHOST_PROXY_PATH=$SMARTHOST_PROXY_PATH SMARTHOST_PROXY_PATH=$SMARTHOST_PROXY_PATH
HTPASSWD_FILE=${HTPASSWD_FILE:-/etc/system/config/smarthost-proxy/nginx/htpasswd}
GIT_URL=${GIT_URL:-git.format.hu} GIT_URL=${GIT_URL:-git.format.hu}
REPO=$REPO REPO=$REPO
@@ -99,6 +100,19 @@ if [ -d /etc/user/config/services ]; then
done done
fi fi
create_htpasswd_file() {
local USER="$1"
local PASSWD="$2"
if [ ! -f "$HTPASSWD_FILE" ]; then
install -m 664 -g 65534 /dev/null $HTPASSWD_FILE
htpasswd -cb $HTPASSWD_FILE $USER $PASSWD
fi
}
install -m 664 -g 65534 /dev/null
deploy_additionals() { deploy_additionals() {
local DIR="$1" local DIR="$1"
@@ -146,6 +160,63 @@ 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
VOLUMES=$(cat $SERVICE_DIR/service-$NAME.json | jq -r '[.containers[] | select(has("VOLUMES")) | .VOLUMES[] | select(.SHARED != "true") | .SOURCE] | unique[]' | grep -vE 'USER|SYSTEM')
for VOLUME in $(echo $VOLUMES); do
if [ "$(echo $VOLUME | cut -d '/' -f1)" ]; then
docker volume rm $VOLUME
debug "deleted volume: $VOLUME"
fi
done
# 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"
@@ -153,7 +224,7 @@ remove_additionals() {
# 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() {
@@ -168,10 +239,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"
@@ -536,27 +607,31 @@ upgrade() {
if [ "$NAME" == "web-installer" ]; then if [ "$NAME" == "web-installer" ]; then
debug "$service_exec service-framework-scheduler.containers.webserver start info" debug "$service_exec service-framework.containers.webserver stop force"
$service_exec service-framework-scheduler.containers.webserver stop force $service_exec service-framework.containers.webserver stop force
$service_exec service-framework-scheduler.containers.webserver start info & debug "$service_exec service-framework.containers.webserver start info"
$service_exec service-framework.containers.webserver start info &
else else
debug "$service_exec service-$NAME.json start info" debug "$service_exec $NAME.json stop force"
$service_exec service-$NAME.json stop force $service_exec $NAME.json stop force
$service_exec service-$NAME.json start info & debug "$service_exec $NAME.json start info"
$service_exec $NAME.json start info &
fi fi
PID=$!
} }
execute_task() { execute_task() {
TASK="$1" TASK="$1"
B64_JSON="$2" B64_JSON="$2"
DATE=$(date +"%Y%m%d%H%M") DATE=$(date +"%Y%m%d%H%M")
# Executing task # Executing task
debug "TASK: $(echo $TASK | cut -d ':' -f1)"
TASK_NAME=$(echo $TASK | cut -d ':' -f1) TASK_NAME=$(echo $TASK | cut -d ':' -f1)
if [ "$TASK_NAME" != "check_vpn" ]; then
debug "TASK: $(echo $TASK_NAME | cut -d ':' -f1)"
fi
# checking sytem status # checking sytem status
SYSTEM_STATUS=$(ls /etc/user/config/services/*.json | grep -v service-framework.json) SYSTEM_STATUS=$(ls /etc/user/config/services/*.json | grep -v service-framework.json)
@@ -579,6 +654,18 @@ 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" == "request_letsencrypt" ]; then
DOMAINS=$(echo $B64_JSON | base64 -d | jq -r 'keys[]')
for DOMAIN in $(echo $DOMAINS); do
REQUEST=$(echo $B64_JSON | base64 -d | jq -r ".[\"$DOMAIN\"].status")
if [ "$REQUEST" == "requested" ]; then
echo "New certificate for $DOMAIN is requested."
touch /etc/system/data/ssl/keys/$DOMAIN/new_certificate
fi
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"
SYSTEM_LIST="core-dns.json cron.json letsencrypt.json local-proxy.json service-framework.json smarthost-proxy-scheduler.json smarthost-proxy.json" SYSTEM_LIST="core-dns.json cron.json letsencrypt.json local-proxy.json service-framework.json smarthost-proxy-scheduler.json smarthost-proxy.json"
@@ -788,6 +875,7 @@ execute_task() {
TEMPLATE=$(echo "$TEMPLATE" | base64 -w0) TEMPLATE=$(echo "$TEMPLATE" | base64 -w0)
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "STATUS": "0", "TEMPLATE": "'$TEMPLATE'" }' | jq -r . | base64 -w0) JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "STATUS": "0", "TEMPLATE": "'$TEMPLATE'" }' | jq -r . | base64 -w0)
elif [ "$DEPLOY_ACTION" == "deploy" ]; then elif [ "$DEPLOY_ACTION" == "deploy" ]; then
JSON_TARGET="" JSON_TARGET=""
#JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "STATUS": "1" }' | jq -r . | base64 -w0) # deployment has started #JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "STATUS": "1" }' | jq -r . | base64 -w0) # deployment has started
@@ -876,18 +964,25 @@ 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
debug "JSON_TARGET: $JSON_TARGET" debug "JSON_TARGET: $JSON_TARGET"
fi
if [ "$JSON_TARGET" != "" ]; then if [ "$JSON_TARGET" != "" ]; then
#redis-cli -h $REDIS_SERVER -p $REDIS_PORT SET $TASK "$JSON_TARGET" #redis-cli -h $REDIS_SERVER -p $REDIS_PORT SET $TASK "$JSON_TARGET"
@@ -1049,7 +1144,9 @@ unset IFS
inotifywait --exclude "\.(swp|tmp)" -m -e CREATE,CLOSE_WRITE,DELETE,MOVED_TO -r $DIR | inotifywait --exclude "\.(swp|tmp)" -m -e CREATE,CLOSE_WRITE,DELETE,MOVED_TO -r $DIR |
while read dir op file; do while read dir op file; do
if [ "${op}" == "CLOSE_WRITE,CLOSE" ]; then if [ "${op}" == "CLOSE_WRITE,CLOSE" ]; then
if [ "$file" != "check_vpn.json" ]; then
echo "new file created: $file" echo "new file created: $file"
fi
B64_JSON=$(cat $DIR/$file | base64 -w0) B64_JSON=$(cat $DIR/$file | base64 -w0)
TASK=$(echo $file | cut -d '.' -f1) TASK=$(echo $file | cut -d '.' -f1)
execute_task "$TASK" "$B64_JSON" execute_task "$TASK" "$B64_JSON"