Skip to content

Commit c72ac68

Browse files
Add -v option for version information
Closes #7.
1 parent 3fa7dbb commit c72ac68

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

DEVELOPMENT.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ Nothing special or automated yet. Therefore just some hints for manual testing:
1818

1919
1. Do proper [Testing](#testing). Continue only if everything is fine.
2020
2. Determine the next version number. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
21-
3. Update the [`CHANGELOG.md`](./CHANGELOG.md). Insert a section for the new release. Do not forget the comparison link at the end of the file.
22-
4. If everything is fine: commit the changes, tag the release and push:
21+
3. Update the internal version variable `readonly version=` to match the new release version.
22+
4. Update the [`CHANGELOG.md`](./CHANGELOG.md). Insert a section for the new release. Do not forget the comparison link at the end of the file.
23+
5. If everything is fine: commit the changes, tag the release and push:
2324
```console
2425
git tag v<version> <commit> -m "version <version>"
2526
git show v<version>
@@ -31,10 +32,10 @@ Nothing special or automated yet. Therefore just some hints for manual testing:
3132
git push origin :refs/tags/v<version> # delete the old tag remotely
3233
```
3334
This is *only* possible if there was no [GitHub release](https://github.com/foundata/proxmox-pve-backup-usb/releases/). Use a new patch version number otherwise.
34-
5. Use [GitHub's release feature](https://github.com/foundata/proxmox-pve-backup-usb/releases/new), select the tag you pushed and create a new release:
35+
6. Use [GitHub's release feature](https://github.com/foundata/proxmox-pve-backup-usb/releases/new), select the tag you pushed and create a new release:
3536
* Use `v<version>` as title
3637
* A description is optional. In doubt, use `See CHANGELOG.md for more information about this release.`
37-
6. Check if the GitHub API delivers the correct version as `latest`:
38+
7. Check if the GitHub API delivers the correct version as `latest`:
3839
```console
3940
curl -s -L https://api.github.com/repos/foundata/proxmox-pve-backup-usb/releases/latest | jq -r '.tag_name' | sed -e 's/^v//g'
4041
```

pve_backup_usb.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616

1717

1818

19+
################################################################################
20+
# Miscellaneous constants and global values
21+
################################################################################
22+
23+
# version of the script
24+
readonly version='1.3.0-devel'
25+
26+
27+
1928
################################################################################
2029
# Environment
2130
################################################################################
@@ -43,11 +52,12 @@ opt_target_mappername='' # -l
4352
opt_quiet='0' # -q
4453
opt_source_paths_pvedumps_list='' # -s
4554
opt_backup_user='' # -u
55+
opt_show_version='0' # -v
4656

4757
# parse options
4858
opt=''
4959
OPTIND='1'
50-
while getopts ':b:cd:e:f:g:hjk:l:qs:u:' opt
60+
while getopts ':b:cd:e:f:g:hjk:l:qs:u:v' opt
5161
do
5262
case "${opt}" in
5363
# backup config
@@ -165,6 +175,13 @@ do
165175
fi
166176
;;
167177

178+
# show version flag
179+
'v')
180+
opt_show_version='1' # flag currently not being used, but still setting the value for code consistency
181+
printf '%s\n' "${version}"
182+
exit 0
183+
;;
184+
168185
# show help
169186
'h')
170187
filename="$(basename "${0}")"
@@ -186,9 +203,10 @@ USB drives, including proper logging and optional email notifications.
186203
.B [-j]
187204
.BI "[-k " "/path/to/keyfile" "]"
188205
.BI "[-l " "mapper and mount point name" "]"
206+
.B [-q]
189207
.BI "[-s " "/pve1/dumps[:/pve2/dumps:...]" "]"
190208
.BI "[-u " "username" "]"
191-
.B [-q]
209+
.B [-v]
192210
193211
.SH DESCRIPTION
194212
See https://github.com/foundata/proxmox-pve-backup-usb/ for a detailed
@@ -263,6 +281,10 @@ Name used for handling LUKS via /dev/mapper/ and creating a mountpoint
263281
subdirectory at /media/. Defaults to "pve_backup_usb".
264282
16 alphanumeric chars at max.
265283
.TP
284+
.B -q
285+
Flag to enable quiet mode. Emails will be sent only on "error" or "warning"
286+
then (but not on "info" or "success").
287+
.TP
266288
.B -s
267289
List of one or more directories to search for PVE dumps, without trailing
268290
slash, separated by ":"; Example: "/pve1/dumps:/pve2/dumps".
@@ -277,9 +299,8 @@ for most environments.
277299
.B -h
278300
Print this help.
279301
.TP
280-
.B -q
281-
Flag to enable quiet mode. Emails will be sent only on "error" or "warning"
282-
then (but not on "info" or "success").
302+
.B -v
303+
Print the script's version.
283304
284305
285306
.SH EXIT STATUS

0 commit comments

Comments
 (0)