mirror of
https://github.com/zoriya/snow.git
synced 2025-12-05 23:06:23 +00:00
Use cronjobs instead of while loops
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gitea-sync
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: sync
|
||||
image: nixery.dev/shell/curl/jq
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- |-
|
||||
while true; do
|
||||
/app/mirror.sh -m user -u zoriya
|
||||
sleep 24h
|
||||
done
|
||||
env:
|
||||
- name: GITEA_URL
|
||||
value: http://gitea-http.gitea.svc:3000
|
||||
- name: ACCESS_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gitea-sync
|
||||
key: gitea-token
|
||||
- name: GITHUB_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gitea-sync
|
||||
key: github-token
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /app
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: scripts
|
||||
defaultMode: 0555
|
||||
|
||||
41
charts/gitea-sync/job.yaml
Normal file
41
charts/gitea-sync/job.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: gitea-sync
|
||||
spec:
|
||||
schedule: "@daily"
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: sync
|
||||
image: nixery.dev/shell/curl/jq
|
||||
command:
|
||||
- /app/mirror.sh
|
||||
- -m
|
||||
- user
|
||||
- -u
|
||||
- zoriya
|
||||
env:
|
||||
- name: GITEA_URL
|
||||
value: http://gitea-http.gitea.svc:3000
|
||||
- name: ACCESS_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gitea-sync
|
||||
key: gitea-token
|
||||
- name: GITHUB_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gitea-sync
|
||||
key: github-token
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /app
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: scripts
|
||||
defaultMode: 0555
|
||||
@@ -12,5 +12,5 @@ configMapGenerator:
|
||||
- ./mirror.sh
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
- job.yaml
|
||||
- secret.yaml
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: yt-dlp
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
securityContext:
|
||||
fsGroup: 1001
|
||||
runAsUser: 1001
|
||||
runAsGroup: 1001
|
||||
runAsNonRoot: true
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
containers:
|
||||
- name: ytdlp
|
||||
image: nixery.dev/shell/yt-dlp
|
||||
workingDir: /work
|
||||
command: [/app/ytdlp-sync.sh]
|
||||
env:
|
||||
- name: OUT
|
||||
value: /musics
|
||||
- name: LIVES_OUT
|
||||
value: /musics/lives
|
||||
- name: URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: ytdlp
|
||||
key: url
|
||||
- name: LIVES_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: ytdlp
|
||||
key: livesUrl
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /app
|
||||
readOnly: true
|
||||
- name: cookies
|
||||
mountPath: /app/secrets
|
||||
- name: work
|
||||
mountPath: /work
|
||||
- name: musics
|
||||
mountPath: /musics
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: sync-scripts
|
||||
defaultMode: 0555
|
||||
- name: musics
|
||||
persistentVolumeClaim:
|
||||
claimName: musics
|
||||
- name: work
|
||||
emptyDir: {}
|
||||
- name: cookies
|
||||
secret:
|
||||
secretName: ytdlp
|
||||
60
charts/meelo/ytdlp/job.yaml
Normal file
60
charts/meelo/ytdlp/job.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: yt-dlp
|
||||
spec:
|
||||
schedule: "@daily"
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
securityContext:
|
||||
fsGroup: 1001
|
||||
runAsUser: 1001
|
||||
runAsGroup: 1001
|
||||
runAsNonRoot: true
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: ytdlp
|
||||
image: nixery.dev/shell/yt-dlp
|
||||
workingDir: /work
|
||||
command: [/app/ytdlp-sync.sh]
|
||||
env:
|
||||
- name: OUT
|
||||
value: /musics
|
||||
- name: LIVES_OUT
|
||||
value: /musics/lives
|
||||
- name: URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: ytdlp
|
||||
key: url
|
||||
- name: LIVES_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: ytdlp
|
||||
key: livesUrl
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /app
|
||||
readOnly: true
|
||||
- name: cookies
|
||||
mountPath: /app/secrets
|
||||
- name: work
|
||||
mountPath: /work
|
||||
- name: musics
|
||||
mountPath: /musics
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: sync-scripts
|
||||
defaultMode: 0555
|
||||
- name: musics
|
||||
persistentVolumeClaim:
|
||||
claimName: musics
|
||||
- name: work
|
||||
emptyDir: {}
|
||||
- name: cookies
|
||||
secret:
|
||||
secretName: ytdlp
|
||||
@@ -12,5 +12,5 @@ configMapGenerator:
|
||||
- ./ytdlp-sync.sh
|
||||
|
||||
resources:
|
||||
- ./deploy.yaml
|
||||
- ./job.yaml
|
||||
- ./secret.yaml
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
while true; do
|
||||
yt-dlp "$LIVES_URL" -o "$LIVES_OUT/%(title)s.%(ext)s" \
|
||||
--embed-thumbnail --embed-metadata --embed-chapters \
|
||||
--download-archive "$LIVES_OUT/ytdlp-archive.txt" \
|
||||
--cookies /app/secrets/cookies.txt \
|
||||
--cache-dir "$(pwd)"
|
||||
yt-dlp "$LIVES_URL" -o "$LIVES_OUT/%(title)s.%(ext)s" \
|
||||
--embed-thumbnail --embed-metadata --embed-chapters \
|
||||
--download-archive "$LIVES_OUT/ytdlp-archive.txt" \
|
||||
--cookies /app/secrets/cookies.txt \
|
||||
--cache-dir "$(pwd)"
|
||||
|
||||
yt-dlp "$URL" -o "$OUT/%(artist)s - %(title)s.%(ext)s" \
|
||||
--extract-audio \
|
||||
--embed-thumbnail --embed-metadata --embed-chapters \
|
||||
--download-archive "$OUT/ytdlp-archive.txt" \
|
||||
--cookies /app/secrets/cookies.txt \
|
||||
--cache-dir "$(pwd)"
|
||||
sleep 6h
|
||||
done
|
||||
yt-dlp "$URL" -o "$OUT/%(artist)s - %(title)s.%(ext)s" \
|
||||
--extract-audio \
|
||||
--embed-thumbnail --embed-metadata --embed-chapters \
|
||||
--download-archive "$OUT/ytdlp-archive.txt" \
|
||||
--cookies /app/secrets/cookies.txt \
|
||||
--cache-dir "$(pwd)"
|
||||
|
||||
Reference in New Issue
Block a user