mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-04 13:05:00 +08:00
grub-btrfs: print version of the script with --version
Close #225 Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
This commit is contained in:
21
41_snapshots-btrfs
Normal file → Executable file
21
41_snapshots-btrfs
Normal file → Executable file
@@ -51,6 +51,27 @@ print_error()
|
||||
exit 0
|
||||
}
|
||||
|
||||
# parse arguments
|
||||
while getopts :V-: opt; do
|
||||
case "$opt" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
version)
|
||||
printf "Version %s\n" "${GRUB_BTRFS_VERSION}" >&2 ;
|
||||
exit 0
|
||||
;;
|
||||
esac;;
|
||||
V)
|
||||
printf "Version %s\n" "${GRUB_BTRFS_VERSION}" >&2 ;
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
printf "Unknown flag, exiting...\n"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
## Exit the script, if:
|
||||
[[ "${GRUB_BTRFS_DISABLE,,}" == "true" ]] && print_error "GRUB_BTRFS_DISABLE is set to true (default=false)"
|
||||
if ! type btrfs >/dev/null 2>&1; then print_error "btrfs-progs isn't installed"; fi
|
||||
|
||||
2
config
2
config
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GRUB_BTRFS_VERSION=4.11-20221121
|
||||
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE="true"
|
||||
|
||||
14
grub-btrfsd
14
grub-btrfsd
@@ -18,6 +18,12 @@ RED=$'\033[0;31m'
|
||||
CYAN=$'\033[;36m'
|
||||
RESET=$'\033[0m'
|
||||
|
||||
sysconfdir="/etc"
|
||||
grub_btrfs_config="${sysconfdir}/default/grub-btrfs/config"
|
||||
# source config file
|
||||
[[ -f "$grub_btrfs_config" ]] && . "$grub_btrfs_config"
|
||||
[[ -f "${sysconfdir}/default/grub" ]] && . "${sysconfdir}/default/grub"
|
||||
|
||||
print_help() {
|
||||
echo "${CYAN}[?] Usage:"
|
||||
echo "${0##*/} [-h, --help] [-t, --timeshift-auto] [-l, --log-file LOG_FILE] [-v, --verbose] [-s, --syslog] SNAPSHOTS_DIR"
|
||||
@@ -29,7 +35,9 @@ print_help() {
|
||||
echo "-l, --log-file Specify a logfile to write to"
|
||||
echo "-v, --verbose Let the log of the daemon be more verbose"
|
||||
echo "-s, --syslog Write to syslog"
|
||||
echo "-h, --help Display this message${RESET}"
|
||||
echo "-h, --help Display this message"
|
||||
echo
|
||||
echo "Version ${GRUB_BTRFS_VERSION}${RESET}"
|
||||
}
|
||||
|
||||
log() {
|
||||
@@ -81,6 +89,10 @@ while getopts :l:tvsh-: opt; do
|
||||
syslog)
|
||||
syslog=true
|
||||
;;
|
||||
help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
|
||||
err "[!] Unknown option --${OPTARG}" "${RED}" >&2
|
||||
|
||||
Reference in New Issue
Block a user