From 77640cb23479ae74421db327a73598eb3baed53f Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Wed, 10 May 2023 12:38:53 +0200 Subject: [PATCH] init --- Dockerfile | 11 +++++++++++ build.sh | 3 +++ entrypoint.sh | 11 +++++++++++ sync-content.sh | 17 +++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 Dockerfile create mode 100755 build.sh create mode 100755 entrypoint.sh create mode 100755 sync-content.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..68498a9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +from docker.io/library/python:3.11-alpine + +RUN mkdir /usr/local/app +WORKDIR /usr/local/app + +COPY entrypoint.sh / +ENTRYPOINT /entrypoint.sh + +COPY sync-content.sh /usr/local/bin/ + +RUN apk add --no-cache git make rclone diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..15fc62e --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker build --network host . -t docker.io/jeancloud/pelican-rclone-builder +docker push jeancloud/pelican-rclone-builder:latest diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..565f545 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -euo pipefail + +[ -d .git ] || git clone "$GIT_SOURCE_REPO" . +[ -d venv ] || python -m venv venv +. venv/bin/activate +pip install --upgrade pip +git pull --rebase +pip install -r requirements.txt +sync-content.sh +make html diff --git a/sync-content.sh b/sync-content.sh new file mode 100755 index 0000000..3096f64 --- /dev/null +++ b/sync-content.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +[ -f .env ] && . ./.env + +[ -z "$CLOUD_SERVER" ] && echo 'Aucun serveur cloud trouvé' && exit 0 +[ -z "$CLOUD_PASSWORD" ] && echo "Aucun mot de passe trouvé" && exit 1 + +action="$1" + +if [ "$action" = 'pull' ] || [ -z "$action" ] ; then + rclone sync --webdav-url="$CLOUD_SERVER/remote.php/webdav/" --webdav-vendor=nextcloud --webdav-user="$CLOUD_USER" --webdav-pass=$(rclone obscure $CLOUD_PASSWORD) :webdav:"$CLOUD_REMOTE_PATH" "$CLOUD_LOCAL_PATH" +elif [ "$action" = 'push' ] ; then + rclone sync --webdav-url="$CLOUD_SERVER/remote.php/webdav/" --webdav-vendor=nextcloud --webdav-user="$CLOUD_USER" --webdav-pass=$(rclone obscure $CLOUD_PASSWORD) "$CLOUD_LOCAL_PATH" :webdav:"$CLOUD_REMOTE_PATH" +else + echo "unknown action: $action" + exit 1 +fi