mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-10-20 02:42:03 +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:
Regular → Executable
+21
@@ -51,6 +51,27 @@ print_error()
|
|||||||
exit 0
|
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:
|
## Exit the script, if:
|
||||||
[[ "${GRUB_BTRFS_DISABLE,,}" == "true" ]] && print_error "GRUB_BTRFS_DISABLE is set to true (default=false)"
|
[[ "${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
|
if ! type btrfs >/dev/null 2>&1; then print_error "btrfs-progs isn't installed"; fi
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
GRUB_BTRFS_VERSION=4.11-20221121
|
||||||
|
|
||||||
# Disable grub-btrfs.
|
# Disable grub-btrfs.
|
||||||
# Default: "false"
|
# Default: "false"
|
||||||
#GRUB_BTRFS_DISABLE="true"
|
#GRUB_BTRFS_DISABLE="true"
|
||||||
|
|||||||
+13
-1
@@ -18,6 +18,12 @@ RED=$'\033[0;31m'
|
|||||||
CYAN=$'\033[;36m'
|
CYAN=$'\033[;36m'
|
||||||
RESET=$'\033[0m'
|
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() {
|
print_help() {
|
||||||
echo "${CYAN}[?] Usage:"
|
echo "${CYAN}[?] Usage:"
|
||||||
echo "${0##*/} [-h, --help] [-t, --timeshift-auto] [-l, --log-file LOG_FILE] [-v, --verbose] [-s, --syslog] SNAPSHOTS_DIR"
|
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 "-l, --log-file Specify a logfile to write to"
|
||||||
echo "-v, --verbose Let the log of the daemon be more verbose"
|
echo "-v, --verbose Let the log of the daemon be more verbose"
|
||||||
echo "-s, --syslog Write to syslog"
|
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() {
|
log() {
|
||||||
@@ -81,6 +89,10 @@ while getopts :l:tvsh-: opt; do
|
|||||||
syslog)
|
syslog)
|
||||||
syslog=true
|
syslog=true
|
||||||
;;
|
;;
|
||||||
|
help)
|
||||||
|
print_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
|
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
|
||||||
err "[!] Unknown option --${OPTARG}" "${RED}" >&2
|
err "[!] Unknown option --${OPTARG}" "${RED}" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user