mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-04 13:05:00 +08:00
grub-btrfsd: fix if...else in daemon
add description of feature in manpage fix non sh compatible commands in daemon Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
This commit is contained in:
2
config
2
config
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GRUB_BTRFS_VERSION=4.12-20221123
|
||||
GRUB_BTRFS_VERSION=4.12-20221126-fix-snap-dir
|
||||
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
|
||||
13
grub-btrfsd
13
grub-btrfsd
@@ -32,8 +32,8 @@ setcolors true # normally we want colors
|
||||
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"
|
||||
[ -f "$grub_btrfs_config" ] && . "$grub_btrfs_config"
|
||||
[ -f "${sysconfdir}/default/grub" ] && . "${sysconfdir}/default/grub"
|
||||
|
||||
print_help() {
|
||||
echo "${CYAN}[?] Usage:"
|
||||
@@ -44,8 +44,8 @@ print_help() {
|
||||
echo "Optional arguments:"
|
||||
echo "-c, --no-color Disable colors in output"
|
||||
echo "-l, --log-file Specify a logfile to write to"
|
||||
echo "-o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (still requires --timeshift-auto)"
|
||||
echo "-s, --syslog Write to syslog"
|
||||
echo "-o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (requires --timeshift-auto)"
|
||||
echo "-t, --timeshift-auto Automatically detect Timeshifts snapshot directory"
|
||||
echo "-v, --verbose Let the log of the daemon be more verbose"
|
||||
echo "-h, --help Display this message"
|
||||
@@ -177,13 +177,14 @@ else
|
||||
fi
|
||||
|
||||
if [ ${timeshift_auto} = false ] && [ ${timeshift_old} = false ]; then
|
||||
err "[!] Flag --timeshift-old requires flags --timeshift-auto" "${RED}" >&2
|
||||
err "[!] Flag --timeshift-old requires flag --timeshift-auto" "${RED}" >&2
|
||||
exit 1
|
||||
else
|
||||
fi
|
||||
|
||||
vlog "Arguments:"
|
||||
vlog "Snapshot directory: $snapshots"
|
||||
vlog "Timestift autodetection: $timeshift_auto"
|
||||
vlog "Timeshift old: $timeshift_old"
|
||||
vlog "Logfile: $logfile"
|
||||
|
||||
if ! [ -d "$snapshots" ] && ! [ ${timeshift_auto} = true ]; then
|
||||
@@ -219,7 +220,7 @@ create_grub_menu() {
|
||||
|
||||
set_snapshot_dir() {
|
||||
# old timeshift has it's snapshot dir in a different location
|
||||
if [ ${timeshift_old} = true ]; then
|
||||
if [ "${timeshift_old}" = true ]; then
|
||||
snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots"
|
||||
else
|
||||
snapshots="/run/timeshift/${timeshift_pid}/backup/timeshift-btrfs/snapshots"
|
||||
|
||||
@@ -9,7 +9,7 @@ when a new btrfs snapshot is created.
|
||||
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fCgrub\-btrfsd [\-h, \-\-help] [\-c, \-\-no\-color] [\-l, \-\-log\-file LOG_FILE] [\-s, \-\-syslog] [\-t, \-\-timeshift\-auto] [\-v, \-\-verbose] SNAPSHOTS_DIR\fP
|
||||
\fCgrub\-btrfsd [\-h, \-\-help] [\-c, \-\-no\-color] [\-l, \-\-log\-file LOG_FILE] [\-s, \-\-syslog] [\-t, \-\-timeshift\-auto] [\-o, \-\-timeshift\-old] [\-v, \-\-verbose] SNAPSHOTS_DIR\fP
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
@@ -38,6 +38,10 @@ Write to syslog
|
||||
.PP
|
||||
This is a flag to activate the auto detection of the path where Timeshift stores snapshots. Newer versions (>=22.06) of Timeshift mount their snapshots to \fC/run/timeshift/$PID/backup/timeshift\-btrfs\fP. Where \fC$PID\fP is the process ID of the currently running Timeshift session. The PID is changing every time Timeshift is opened. grub-btrfsd can automatically take care of the detection of the correct PID and directory if this flag is set. In this case the argument \fCSNAPSHOTS_DIR\fP has no effect.
|
||||
|
||||
.SS "\fC\-o / \-\-timeshift\-old\fP"
|
||||
.PP
|
||||
Look for snapshots in \fC/run/timeshift/backup/timeshift\-btrfs\fP instead of \fC/run/timeshift/$PID/backup/timeshift\-btrfs\fP. This is to be used for Timeshift versions <22.06.
|
||||
|
||||
.SS "\fC\-v / \-\-verbose\fP"
|
||||
.PP
|
||||
Let the log of the daemon be more verbose
|
||||
|
||||
@@ -10,7 +10,7 @@ grub-btrfsd - An OpenRC daemon to automatically update the grub menu with
|
||||
when a new btrfs snapshot is created.
|
||||
|
||||
* SYNOPSIS
|
||||
~grub-btrfsd [-h, --help] [-c, --no-color] [-l, --log-file LOG_FILE] [-s, --syslog] [-t, --timeshift-auto] [-v, --verbose] SNAPSHOTS_DIR~
|
||||
~grub-btrfsd [-h, --help] [-c, --no-color] [-l, --log-file LOG_FILE] [-s, --syslog] [-t, --timeshift-auto] [-o, --timeshift-old] [-v, --verbose] SNAPSHOTS_DIR~
|
||||
|
||||
* DESCRIPTION
|
||||
Grub-btrfsd is a shell script which is meant to be run as a daemon.
|
||||
@@ -33,6 +33,9 @@ Write to syslog
|
||||
** ~-t / --timeshift-auto~
|
||||
This is a flag to activate the auto detection of the path where Timeshift stores snapshots. Newer versions (>=22.06) of Timeshift mount their snapshots to ~/run/timeshift/$PID/backup/timeshift-btrfs~. Where ~$PID~ is the process ID of the currently running Timeshift session. The PID is changing every time Timeshift is opened. grub-btrfsd can automatically take care of the detection of the correct PID and directory if this flag is set. In this case the argument ~SNAPSHOTS_DIR~ has no effect.
|
||||
|
||||
** ~-o / --timeshift-old~
|
||||
Look for snapshots in ~/run/timeshift/backup/timeshift-btrfs~ instead of ~/run/timeshift/$PID/backup/timeshift-btrfs~. This is to be used for Timeshift versions <22.06.
|
||||
|
||||
** ~-v / --verbose~
|
||||
Let the log of the daemon be more verbose
|
||||
|
||||
|
||||
Reference in New Issue
Block a user