Add uberspace crontab handling
This commit is contained in:
parent
b50f5cc2a4
commit
9d6f2d6db9
11
bundles/uberspace-crontab-dir/files/crontab-dir-generate-crontab.sh
Executable file
11
bundles/uberspace-crontab-dir/files/crontab-dir-generate-crontab.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "# Generated from ~/.config/cron.d"
|
||||||
|
echo "# Use crontab-dir-update to regenerate"
|
||||||
|
echo
|
||||||
|
echo "PATH=$HOME/.local/bin:$HOME/bin:\$PATH"
|
||||||
|
echo
|
||||||
|
|
||||||
|
find $HOME/.config/cron.d -mindepth 1 -maxdepth 1 -type f | sort | xargs cat
|
11
bundles/uberspace-crontab-dir/files/crontab-dir-is-sync.sh
Executable file
11
bundles/uberspace-crontab-dir/files/crontab-dir-is-sync.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ "$(crontab-dir-generate-crontab)" == "$(crontab -l)" ]]; then
|
||||||
|
echo "crontab is up to date"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "crontab needs update"
|
||||||
|
exit 1
|
||||||
|
fi
|
5
bundles/uberspace-crontab-dir/files/crontab-dir-update.sh
Executable file
5
bundles/uberspace-crontab-dir/files/crontab-dir-update.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
crontab-dir-generate-crontab | crontab -
|
46
bundles/uberspace-crontab-dir/items.py
Normal file
46
bundles/uberspace-crontab-dir/items.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
uberspaceify = repo.libs.uberspace.Uberspaceify(node)
|
||||||
|
|
||||||
|
directories = uberspaceify.directories({
|
||||||
|
f'/home/{node.username}/.config/cron.d': {
|
||||||
|
"purge": True,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
crontab_files = {}
|
||||||
|
for crontab_name, crontab_line in node.metadata.get("cron/jobs", {}).items():
|
||||||
|
crontab_files[f'/home/{node.username}/.config/cron.d/{crontab_name}'] = {
|
||||||
|
"content": crontab_line + "\n",
|
||||||
|
}
|
||||||
|
|
||||||
|
files = uberspaceify.files({
|
||||||
|
f'/home/{node.username}/bin/crontab-dir-generate-crontab': {
|
||||||
|
"source": "crontab-dir-generate-crontab.sh",
|
||||||
|
"mode": "0750",
|
||||||
|
},
|
||||||
|
f'/home/{node.username}/bin/crontab-dir-is-sync': {
|
||||||
|
"source": "crontab-dir-is-sync.sh",
|
||||||
|
"mode": "0750",
|
||||||
|
"needs": [
|
||||||
|
f'file:/home/{node.username}/bin/crontab-dir-generate-crontab',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
f'/home/{node.username}/bin/crontab-dir-update': {
|
||||||
|
"source": "crontab-dir-update.sh",
|
||||||
|
"mode": "0750",
|
||||||
|
"needs": [
|
||||||
|
f'file:/home/{node.username}/bin/crontab-dir-generate-crontab',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
**crontab_files,
|
||||||
|
})
|
||||||
|
|
||||||
|
actions = {
|
||||||
|
"update_crontab": {
|
||||||
|
"command": 'crontab-dir-update',
|
||||||
|
"unless": 'crontab-dir-is-sync',
|
||||||
|
"needs": [
|
||||||
|
f'file:/home/{node.username}/bin/crontab-dir-update',
|
||||||
|
f'file:/home/{node.username}/bin/crontab-dir-is-sync',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
7
nodes.py
7
nodes.py
@ -6,6 +6,7 @@ nodes = uberspaceify.nodes({
|
|||||||
"bundles": (
|
"bundles": (
|
||||||
"uberspace-redirect-clerie",
|
"uberspace-redirect-clerie",
|
||||||
"uberspace-clerie-backup",
|
"uberspace-clerie-backup",
|
||||||
|
"uberspace-crontab-dir",
|
||||||
),
|
),
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"clerie-backup": {
|
"clerie-backup": {
|
||||||
@ -32,6 +33,12 @@ nodes = uberspaceify.nodes({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"cron": {
|
||||||
|
"jobs": {
|
||||||
|
"backup_main-cyan": "42 */2 * * * clerie-backup main-cyan backup",
|
||||||
|
"backup_main-magenta": "13 */2 * * * clerie-backup main-magenta backup",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"cleriewi.uber.space": {
|
"cleriewi.uber.space": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user