Refactor entrypoint script for improved readability and add upgrade functionality

This commit is contained in:
gyurix
2025-03-14 08:41:59 +01:00
parent 580866a0e6
commit 7cd01799e2
2 changed files with 30 additions and 16 deletions

View File

@@ -163,7 +163,6 @@ get_repositories() {
local TREES=""
local REPO
REPOS=$(jq -r .repositories[] /etc/user/config/repositories.json) # list of repos, delimiter by space
for REPO in $REPOS; do
@@ -434,12 +433,13 @@ check_update() {
CURL_CHECK="curl -m 5 -s -o /dev/null -w "%{http_code}" https://$REPOSITORY_URL/v2/"
CURL_CHECK_CODE=$(eval $CURL_CHECK)
if [[ "$CURL_CHECK_CODE" == "200" ]]; then
if [[ "$CURL_CHECK_CODE" == "200" ]] || [[ "$(echo "$REPOSITORY_URL" | grep '\.')" == "" ]]; then
debug "$REPOSITORY_URL accessed successful"
# if repository url is not set
if [[ "$(echo "$REPOSITORY_URL" | grep '\.')" == "" ]]; then
REPOSITORY_URL="docker.io"
REPOSITORY_URL="hub.docker.com"
TEMP_PATH=$IMAGE
else
# -f2- IMAGE can contain subdirectories
@@ -784,7 +784,7 @@ execute_task() {
elif [ "$TASK_NAME" == "save_vpn" ]; then
VPN_PROXY_REPO="wireguard-proxy-client";
VPN_PROXY_REPO="wireguard-proxy-client"
if [ ! -d "/tmp/$VPN_PROXY_REPO" ]; then
git clone https://git.format.hu/safebox/$VPN_PROXY_REPO.git /tmp/$VPN_PROXY_REPO >/dev/null
else
@@ -795,8 +795,8 @@ execute_task() {
cp -av /tmp/$VPN_PROXY_REPO/*.json $SERVICE_DIR/
VPN_VOLUMES=$(jq -r .containers[0].VOLUMES[0].SOURCE $SERVICE_DIR/vpn-proxy.json)
VOLUME=$(dirname $VPN_VOLUMES);
mkdir -p $VOLUME;
VOLUME=$(dirname $VPN_VOLUMES)
mkdir -p $VOLUME
# install vpn only
sh /scripts/install.sh "$B64_JSON" "$service_exec" "vpn" "$GLOBAL_VERSION"
@@ -807,7 +807,12 @@ execute_task() {
CONTAINERS=$(docker ps -a --format '{{.Names}} {{.Status}}' | grep -v framework-scheduler)
RESULT=$(echo "$CONTAINERS" | base64 -w0)
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "RESULT": "'$RESULT'" }' | jq -r . | base64 -w0)
elif [ "$TASK_NAME" == "upgrade" ]; then
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "UPGRADE_STATUS": "0" }' | jq -r . | base64 -w0) # install has started
install -m 664 -g 65534 /dev/null $SHARED/output/$TASK.json
echo $JSON_TARGET | base64 -d >$SHARED/output/$TASK.json
sh /scripts/upgrade.sh "$B64_JSON" "$service_exec" "true" "$GLOBAL_VERSION"
JSON_TARGET=$(echo '{ "DATE": "'$DATE'", "UPGRADE_STATUS": "'$UPGRADE_STATUS'" }' | jq -r . | base64 -w0)
fi
debug "JSON_TARGET: $JSON_TARGET"

9
scripts/scheduler/upgrade.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
B64_JSON=$1
SERVICE_EXEC=$2
GLOBAL_VERSION=$4
for SERVICE in $(echo $B64_JSON | base64 -d | jq -r 'keys[]'); do
done