diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs old mode 100644 new mode 100755 index 9cd58fa..e39f31c --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -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 diff --git a/config b/config index 2f25d41..3a72afb 100644 --- a/config +++ b/config @@ -1,5 +1,7 @@ #!/usr/bin/env bash +GRUB_BTRFS_VERSION=4.11-20221121 + # Disable grub-btrfs. # Default: "false" #GRUB_BTRFS_DISABLE="true" diff --git a/grub-btrfsd b/grub-btrfsd index f47df03..b72e1d5 100755 --- a/grub-btrfsd +++ b/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