From 6cc343384e2734b41d93447a67156cfecc61e6da Mon Sep 17 00:00:00 2001 From: Udo Waechter Date: Sat, 10 Oct 2020 19:12:46 +0200 Subject: [PATCH] Piwigo automated sync and its container --- apps/piwigo/.Dockerfile.swp | Bin 0 -> 12288 bytes apps/piwigo/Dockerfile | 9 +++ apps/piwigo/deployment.yaml | 123 ++++++++++++++++++++++++++++++++++++ apps/piwigo/remote_sync.pl | 59 +++++++++++++++++ 4 files changed, 191 insertions(+) create mode 100644 apps/piwigo/.Dockerfile.swp create mode 100644 apps/piwigo/Dockerfile create mode 100644 apps/piwigo/deployment.yaml create mode 100755 apps/piwigo/remote_sync.pl diff --git a/apps/piwigo/.Dockerfile.swp b/apps/piwigo/.Dockerfile.swp new file mode 100644 index 0000000000000000000000000000000000000000..b859556e91cc0063d1385a67a985d5f10ec3c566 GIT binary patch literal 12288 zcmeI&Pixdb7zXgS-uB=h^rE+M3oQuAG+B!!f>0`ghgw-!L0Kr1$?WdX*(p|JD2dx0^&?LtTa{ zLJdP@q3(wIvCMyO*I+;Z0uX=z1Rwwb2tWV=5P$##{+__W(aYD&sd?qqalI&IYz^bo zb8{BC3FBwNaVg|XgV>7zRCy+i5+#ck zU7Jx)HqJ2XDrxIq$>Hb)TZJ222(Q}ys-w%=3uD?1#/etc/apt/apt.conf.d/proxy +RUN apt-get update && apt-get install -y \ + libwww-perl && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /var/cache/apt/* /tmp/* /var/tmp/* +COPY remote_sync.pl / \ No newline at end of file diff --git a/apps/piwigo/deployment.yaml b/apps/piwigo/deployment.yaml new file mode 100644 index 0000000..5453a92 --- /dev/null +++ b/apps/piwigo/deployment.yaml @@ -0,0 +1,123 @@ +--- +apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: piwigo +spec: + selector: + matchLabels: + app: piwigo + strategy: + type: Recreate + template: + metadata: + labels: + app: piwigo + spec: + containers: + - image: linuxserver/piwigo + name: piwigo + imagePullPolicy: IfNotPresent + env: + # Use secret in real usage + - name: TZ + value: Europe/Berlin + livenessProbe: + failureThreshold: 10 + httpGet: + path: /index.php + port: http + scheme: HTTP + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + ports: + - containerPort: 80 + name: http + - containerPort: 443 + name: https + volumeMounts: + - name: piwigo-persistent-storage + mountPath: /config/www/gallery/galleries + - name: piwigo-config + mountPath: /config + volumes: + - name: piwigo-persistent-storage + persistentVolumeClaim: + claimName: piwigo-pv-claim + - name: piwigo-config + persistentVolumeClaim: + claimName: piwigo-config +--- +apiVersion: v1 +kind: Service +metadata: + name: piwigo +spec: + ports: + - name: http + port: 80 + - name: https + port: 443 + selector: + app: piwigo +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: piwigo +spec: + rules: + - host: foto.lan + http: + paths: + - backend: + serviceName: piwigo + servicePort: http +--- +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: piwigo-quicksync +spec: + schedule: "*/10 * * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: piwigo-quicksync + image: docker-registry.lan/piwigo-sync:arm64 + imagePullPolicy: Always + args: + - /remote_sync.pl + - --base_url=http://piwigo.default.svc.cluster.local/ + - --username=api + - --password='{D8G~y:new; +$ua->agent('Mozilla/remote_sync.pl'); +$ua->cookie_jar({}); + +$ua->default_headers->authorization_basic( + $opt{username}, + $opt{password} +); + +my $form = { + method => 'pwg.session.login', + username => $opt{username}, + password => $opt{password}, +}; + +my $result = $ua->post( + $opt{base_url}.'/ws.php?format=json', + $form +); + +# perform the synchronization +$form = { + 'sync' => 'files', + 'display_info' => 1, + 'add_to_caddie' => 1, + 'privacy_level' => 0, + 'sync_meta' => 1, # remove this parameter, turning to 0 is not enough + 'simulate' => 0, + 'subcats-included' => 1, + 'submit' => 1, +}; + +$result = $ua->post( + $opt{base_url}.'/admin.php?page=site_update&site=1', + $form +); + +use Data::Dumper; +print Dumper($result);