uscrontab: ajout des options -@, -H, -M
This commit is contained in:
		
							parent
							
								
									52e838e383
								
							
						
					
					
						commit
						a66c0c231f
					
				
							
								
								
									
										35
									
								
								uscrontab
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								uscrontab
									
									
									
									
									
								
							| @ -286,6 +286,14 @@ OPTIONS AVANCEES | |||||||
|         référence. Il faut respecter le format, sinon les résultats ne sont pas |         référence. Il faut respecter le format, sinon les résultats ne sont pas | ||||||
|         garantis. Le mieux est de reprendre le résultat de l'option --show-ctnow |         garantis. Le mieux est de reprendre le résultat de l'option --show-ctnow | ||||||
|         en le modifiant un peu si nécessaire. |         en le modifiant un peu si nécessaire. | ||||||
|  |     -@, --hm H[:M] | ||||||
|  |     -H, --h00 | ||||||
|  |     -M, --h30 | ||||||
|  |         Options pour simplifier l'utilisation de --force-ctnow. Supposons que | ||||||
|  |         --show-ctnow affiche 'Y X day mon dow', alors: | ||||||
|  |             -@ H:M  | est équivalent à  |  --force-ctnow 'M H day mon dow' | ||||||
|  |             -H      |        ''         |  --force-ctnow '0 X day mon dow' | ||||||
|  |             -M      |        ''         |  --force-ctnow '30 X day mon dow' | ||||||
|     -G, --any-ctnow |     -G, --any-ctnow | ||||||
|         Pour le développement ou des tests, lancer toutes les commandes dans |         Pour le développement ou des tests, lancer toutes les commandes dans | ||||||
|         l'ordre sans tenir compte de l'heure de référence. Cette commande ne |         l'ordre sans tenir compte de l'heure de référence. Cette commande ne | ||||||
| @ -345,6 +353,7 @@ lockfile=auto | |||||||
| lockdelay= | lockdelay= | ||||||
| fake= | fake= | ||||||
| continuous= | continuous= | ||||||
|  | force_ctnow= | ||||||
| pause= | pause= | ||||||
| force= | force= | ||||||
| parse_opts "${PRETTYOPTS[@]}" \ | parse_opts "${PRETTYOPTS[@]}" \ | ||||||
| @ -367,6 +376,9 @@ parse_opts "${PRETTYOPTS[@]}" \ | |||||||
|     -k:,--stop: USCRONTAB_STOPEC= \ |     -k:,--stop: USCRONTAB_STOPEC= \ | ||||||
|     --show-ctnow action=show-ctnow \ |     --show-ctnow action=show-ctnow \ | ||||||
|     --force-ctnow: __CTRESOLVE_CTNOW= \ |     --force-ctnow: __CTRESOLVE_CTNOW= \ | ||||||
|  |     -@:,--hm: force_ctnow= \ | ||||||
|  |     -H,--h00 force_ctnow=h00 \ | ||||||
|  |     -M,--h30 force_ctnow=h30 \ | ||||||
|     -G,--any-ctnow __CTRESOLVE_CTNOW="**ANY**" \ |     -G,--any-ctnow __CTRESOLVE_CTNOW="**ANY**" \ | ||||||
|     @ args -- "$@" && set -- "${args[@]}" || die "$args" |     @ args -- "$@" && set -- "${args[@]}" || die "$args" | ||||||
| 
 | 
 | ||||||
| @ -436,10 +448,6 @@ elif [ "$action" == "remove" ]; then | |||||||
|     exit 0 |     exit 0 | ||||||
| 
 | 
 | ||||||
| elif [ "$action" == "list" ]; then | elif [ "$action" == "list" ]; then | ||||||
|     if check_pause "$pausefile" "$now"; then |  | ||||||
|         ewarn "En pause. Réactiver avec $scriptname -Y" |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     if [ -n "$uscrontab" ]; then |     if [ -n "$uscrontab" ]; then | ||||||
|         uscrontab="$(abspath "$uscrontab")" |         uscrontab="$(abspath "$uscrontab")" | ||||||
|         array_from_lines ctfiles "$(crontab -l 2>/dev/null | awkrun script="$script" uscrontab="$uscrontab" '$6 == script && $7 == uscrontab { print $7 }')" |         array_from_lines ctfiles "$(crontab -l 2>/dev/null | awkrun script="$script" uscrontab="$uscrontab" '$6 == script && $7 == uscrontab { print $7 }')" | ||||||
| @ -472,6 +480,10 @@ elif [ "$action" == "list" ]; then | |||||||
|         etitle "$(ppath "$ctfile")" \ |         etitle "$(ppath "$ctfile")" \ | ||||||
|             cat "$ctfile" |             cat "$ctfile" | ||||||
|     done |     done | ||||||
|  | 
 | ||||||
|  |     if check_pause "$pausefile" "$now"; then | ||||||
|  |         ewarn "En pause. Réactiver avec $scriptname -Y" | ||||||
|  |     fi | ||||||
|     exit $r |     exit $r | ||||||
| 
 | 
 | ||||||
| elif [ "$action" == "show-ctnow" ]; then | elif [ "$action" == "show-ctnow" ]; then | ||||||
| @ -604,6 +616,21 @@ elif [ "$action" == "run" ]; then | |||||||
|         die "$*" |         die "$*" | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if [ -n "$force_ctnow" ]; then | ||||||
|  |         ctnow=($(ctnow "$now")) | ||||||
|  |         case "$force_ctnow" in | ||||||
|  |         h00) ctnow[0]=0;; | ||||||
|  |         h30) ctnow[0]=30;; | ||||||
|  |         *) | ||||||
|  |             force_ctnow="${force_ctnow//./:}" # autoriser H.M en plus de H:M | ||||||
|  |             splitpair "$force_ctnow" h m | ||||||
|  |             ctnow[0]="${m:-0}" | ||||||
|  |             ctnow[1]="$h" | ||||||
|  |             ;; | ||||||
|  |         esac | ||||||
|  |         __CTRESOLVE_CTNOW="${ctnow[*]}" | ||||||
|  |     fi | ||||||
|  | 
 | ||||||
|     __ctscript="$(ctresolve <"$uscrontab")" |     __ctscript="$(ctresolve <"$uscrontab")" | ||||||
|     ec=0 |     ec=0 | ||||||
|     edebug "$__ctscript" |     edebug "$__ctscript" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user