Add uberspace crontab handling
This commit is contained in:
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',
|
||||
],
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user