|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
4 | | -VERSION="0.1.1" |
| 4 | +VERSION="0.1.2" |
5 | 5 |
|
6 | 6 | EXIT_OK=0 |
7 | 7 | EXIT_RUNTIME=1 |
@@ -1004,9 +1004,18 @@ cmd_backup() { |
1004 | 1004 | done |
1005 | 1005 |
|
1006 | 1006 | [ -n "$vm" ] || { err "--vm is required."; usage_backup; return "$EXIT_USAGE"; } |
1007 | | - is_uint "$keep" && [ "$keep" -ge 1 ] || { err "--keep must be >= 1."; return "$EXIT_USAGE"; } |
1008 | | - is_uint "$UTM_STOP_TIMEOUT_SEC" && [ "$UTM_STOP_TIMEOUT_SEC" -ge 1 ] || { err "--timeout must be >= 1."; return "$EXIT_USAGE"; } |
1009 | | - is_uint "$UTM_STOP_POLL_INTERVAL_SEC" && [ "$UTM_STOP_POLL_INTERVAL_SEC" -ge 1 ] || { err "--poll must be >= 1."; return "$EXIT_USAGE"; } |
| 1007 | + if ! is_uint "$keep" || [ "$keep" -lt 1 ]; then |
| 1008 | + err "--keep must be >= 1." |
| 1009 | + return "$EXIT_USAGE" |
| 1010 | + fi |
| 1011 | + if ! is_uint "$UTM_STOP_TIMEOUT_SEC" || [ "$UTM_STOP_TIMEOUT_SEC" -lt 1 ]; then |
| 1012 | + err "--timeout must be >= 1." |
| 1013 | + return "$EXIT_USAGE" |
| 1014 | + fi |
| 1015 | + if ! is_uint "$UTM_STOP_POLL_INTERVAL_SEC" || [ "$UTM_STOP_POLL_INTERVAL_SEC" -lt 1 ]; then |
| 1016 | + err "--poll must be >= 1." |
| 1017 | + return "$EXIT_USAGE" |
| 1018 | + fi |
1010 | 1019 |
|
1011 | 1020 | case "$mode" in |
1012 | 1021 | auto|snapshot|archive) ;; |
@@ -1080,8 +1089,14 @@ cmd_restore() { |
1080 | 1089 |
|
1081 | 1090 | [ -n "$vm" ] || { err "--vm is required."; usage_restore; return "$EXIT_USAGE"; } |
1082 | 1091 | [ -n "$source" ] || { err "--source is required."; usage_restore; return "$EXIT_USAGE"; } |
1083 | | - is_uint "$UTM_STOP_TIMEOUT_SEC" && [ "$UTM_STOP_TIMEOUT_SEC" -ge 1 ] || { err "--timeout must be >= 1."; return "$EXIT_USAGE"; } |
1084 | | - is_uint "$UTM_STOP_POLL_INTERVAL_SEC" && [ "$UTM_STOP_POLL_INTERVAL_SEC" -ge 1 ] || { err "--poll must be >= 1."; return "$EXIT_USAGE"; } |
| 1092 | + if ! is_uint "$UTM_STOP_TIMEOUT_SEC" || [ "$UTM_STOP_TIMEOUT_SEC" -lt 1 ]; then |
| 1093 | + err "--timeout must be >= 1." |
| 1094 | + return "$EXIT_USAGE" |
| 1095 | + fi |
| 1096 | + if ! is_uint "$UTM_STOP_POLL_INTERVAL_SEC" || [ "$UTM_STOP_POLL_INTERVAL_SEC" -lt 1 ]; then |
| 1097 | + err "--poll must be >= 1." |
| 1098 | + return "$EXIT_USAGE" |
| 1099 | + fi |
1085 | 1100 |
|
1086 | 1101 | require_dependencies || return "$?" |
1087 | 1102 | do_restore_for_vm_and_source "$vm" "$source" "$assume_yes" |
|
0 commit comments