From e2372596a3051322aec59abe38c1b4a73223f700 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Fri, 5 May 2023 10:34:09 +0200 Subject: [PATCH] update sync script --- Makefile | 4 +++- pull-content.sh | 15 --------------- sync-content.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 16 deletions(-) delete mode 100755 pull-content.sh create mode 100755 sync-content.sh diff --git a/Makefile b/Makefile index 96abc59..4a5b908 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,9 @@ help: html: "$(PELICAN)" "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(CONFFILE)" $(PELICANOPTS) pull: - ./pull-content.sh + ./sync-content.sh pull +push: + ./sync-content.sh push clean: [ ! -d "$(OUTPUTDIR)" ] || rm -rf "$(OUTPUTDIR)" diff --git a/pull-content.sh b/pull-content.sh deleted file mode 100755 index 750a17f..0000000 --- a/pull-content.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -server='https://nuage.jean-cloud.net' -user="lexicographe" -ncpath=content/ -password="$CLOUD_PASSWORD" -if [ -z "$password" ] ; then - password="$(cat .password)" -fi -if [ -z "$password" ] ; then - echo "Aucun mot de passe trouvé" - exit 1 -fi - -rclone copy --webdav-url="$server/remote.php/webdav/" --webdav-vendor=nextcloud --webdav-user="$user" --webdav-pass=$(rclone obscure $password) :webdav:"$ncpath" content diff --git a/sync-content.sh b/sync-content.sh new file mode 100755 index 0000000..bb1f19c --- /dev/null +++ b/sync-content.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +server='https://nuage.jean-cloud.net' +user="lexicographe" +ncpath=content/ +password="$CLOUD_PASSWORD" +if [ -z "$password" ] ; then + password="$(cat .password)" +fi +if [ -z "$password" ] ; then + echo "Aucun mot de passe trouvé" + exit 1 +fi + +action="$1" +if [ -z "$action" ] ; then + action=pull +fi + +if [ "$action" = 'pull' ] ; then + rclone copy --webdav-url="$server/remote.php/webdav/" --webdav-vendor=nextcloud --webdav-user="$user" --webdav-pass=$(rclone obscure $password) :webdav:"$ncpath" content +elif [ "$action" = 'push' ] ; then + rclone copy --webdav-url="$server/remote.php/webdav/" --webdav-vendor=nextcloud --webdav-user="$user" --webdav-pass=$(rclone obscure $password) content :webdav:"$ncpath" +else + echo "unknown action: $action" + exit 1 +fi