This commit is contained in:
Adrian Amaglio 2023-06-29 17:43:19 +02:00
parent 77640cb234
commit d0af10726f
2 changed files with 35 additions and 12 deletions

View File

@ -1,11 +1,15 @@
#!/bin/sh
set -euo pipefail
[ -d .git ] || git clone "$GIT_SOURCE_REPO" .
[ -d .git ] || git clone --single-branch --depth 1 "$GIT_SOURCE_REPO" . || (git checkout -- * && git pull --depth 1)
if [ -f requirements.txt ] ; then
[ -d venv ] || python -m venv venv
. venv/bin/activate
# TODO check if content has changed before installing anything?
pip install --upgrade pip
git pull --rebase
pip install -r requirements.txt
sync-content.sh
make html
else
echo 'No requirements.txt found. No python installed or website built.'
fi

View File

@ -1,17 +1,36 @@
#!/bin/sh
#set -eu
# Sourc some env
[ -f .env ] && . ./.env
[ -z "$CLOUD_SERVER" ] && echo 'Aucun serveur cloud trouvé' && exit 0
[ -z "$CLOUD_PASSWORD" ] && echo "Aucun mot de passe trouvé" && exit 1
# Used env vars
[ -z "$NC_SHARE_LINK" ] && echo 'Aucun partage cloud trouvé' && exit 1
# NC_SHARE_PASSWORD can be empty
# Extract data from share link
tmp="$(mktemp)"
echo "$NC_SHARE_LINK" | sed 's#/s/# #' > "$tmp"
read server token <"$tmp"
rm "$tmp"
[ -z "$server" ] && echo 'Aucun serveur trouvé dans le lien de partage' && exit 1
[ -z "$token" ] && echo 'Aucun token trouvé dans le lien de partage' && exit 1
# User may ask for sync way
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"
path=":webdav: $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"
path="$CLOUD_LOCAL_PATH :webdav:"
else
echo "unknown action: $action"
exit 1
fi
# Actual sync
rclone sync --create-empty-src-dirs "--webdav-url=$server/public.php/webdav/" "--webdav-user=$token" --webdav-pass="$(rclone obscure "$NC_SHARE_PASSWORD")" --webdav-vendor=nextcloud $path
echo "SYNC OK"