46 lines
2.2 KiB
YAML
46 lines
2.2 KiB
YAML
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: purge-oc-authtoken
|
|
namespace: nextcloud
|
|
spec:
|
|
schedule: 0 0 */15 * *
|
|
jobTemplate:
|
|
spec:
|
|
ttlSecondsAfterFinished: 100
|
|
template:
|
|
spec:
|
|
containers:
|
|
- image: alpine
|
|
imagePullPolicy: Always
|
|
name: purge-oc-authtoken
|
|
volumeMounts:
|
|
- name: nextcloud-purge-oc-authtoken-log
|
|
mountPath: /var/log/nextcloud-nextcloud-purge-oc-authtoken.log
|
|
command: [ "/bin/sh", "-c", "--" ]
|
|
args:
|
|
- apk -q update; apk -q add postgresql;clear;echo $(date) >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log 2>&1;echo "Number of row before the query" >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log;PGPASSWORD=$POSTGRES_PASSWORD psql -h db.nextcloud.svc -d $POSTGRES_DB -U $POSTGRES_USER -c "select * from oc_authtoken where uid='pi';" |tail -n 2 >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log; PGPASSWORD=$POSTGRES_PASSWORD psql -h db.nextcloud.svc -d $POSTGRES_DB -U $POSTGRES_USER -c "delete from oc_authtoken where uid='pi' >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log;";echo "Number of row after the query" >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log; PGPASSWORD=$POSTGRES_PASSWORD psql -h db.nextcloud.svc -d $POSTGRES_DB -U $POSTGRES_USER -c "select * from oc_authtoken where uid='pi';"|tail -n 2 >> /var/log/nextcloud-nextcloud-purge-oc-authtoken.log;sleep 3600
|
|
env:
|
|
- name: POSTGRES_DB
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: nextcloud-credentials
|
|
key: POSTGRES_DB
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: nextcloud-credentials
|
|
key: POSTGRES_USER
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: nextcloud-credentials
|
|
key: POSTGRES_PASSWORD
|
|
restartPolicy: OnFailure
|
|
volumes:
|
|
- name: nextcloud-purge-oc-authtoken-log
|
|
hostPath:
|
|
path: /var/log/nextcloud-nextcloud-purge-oc-authtoken.log
|
|
type: File
|
|
|