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