Initial commit
This commit is contained in:
5
Dockerfile
Normal file
5
Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM scheduler:latest
|
||||||
|
|
||||||
|
COPY scripts /scripts
|
||||||
|
|
||||||
|
ENTRYPOINT ["/scripts/scheduler.sh"]
|
32
scripts/scheduler.sh
Executable file
32
scripts/scheduler.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
service_exec=echo
|
||||||
|
|
||||||
|
|
||||||
|
CERT_DIR=/keys
|
||||||
|
|
||||||
|
inotifywait --exclude .swp -m -e modify,create -r $CERT_DIR | \
|
||||||
|
|
||||||
|
while read dir op file
|
||||||
|
do
|
||||||
|
if [[ "${op}" == "CLOSE_WRITE,CLOSE" || "${op}" == "CREATE" ]] ; then
|
||||||
|
DOMAIN=$(echo $dir|cut -d / -f3)
|
||||||
|
|
||||||
|
FILE=$(find /etc/user/config/services/ -name *.json | xargs -I {} jq '{"file": input_filename, "MAIN": ..|.main?'} {} | jq -c 'select(.MAIN | length > 0)' | grep $DOMAIN | jq -r .file)
|
||||||
|
|
||||||
|
ROLE=$ROLES
|
||||||
|
|
||||||
|
CONTAINER=$(jq -r --arg ROLE $ROLE '.containers[] | select(.ROLES==$ROLE)' $FILE | jq -r .NAME)
|
||||||
|
|
||||||
|
SERVICE_NAME=$(basename $FILE|cut -d . -f1)
|
||||||
|
|
||||||
|
$service_exec $SERVICE_NAME.containers.$CONTAINER stop
|
||||||
|
|
||||||
|
$service_exec $SERVICE_NAME.containers.$CONTAINER start
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
Reference in New Issue
Block a user