forked from Antynea/grub-btrfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrub-btrfsd.sysvinit.initd
More file actions
102 lines (90 loc) · 2.63 KB
/
Copy pathgrub-btrfsd.sysvinit.initd
File metadata and controls
102 lines (90 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
### BEGIN INIT INFO
# Provides: grub-btrfsd
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Regenerate grub-btrfs.cfg
# Description: Monitors btrfs snapshots created with snapper
# or Timeshift and automatically regenerates
# grub-btrfs.cfg.
### END INIT INFO
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="grub-btrfs snapshot daemon"
NAME=grub-btrfsd
DAEMON=/usr/bin/$NAME
PIDFILE=/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
SNAPSHOTS="/.snapshots" # Snapper in the root directory
# SNAPSHOTS="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift < v22.06
## Optional arguments to run with the daemon
# Append options to this like this:
# DAEMON_ARGS="--syslog --timeshift-auto --verbose"
# Possible options are:
# -t, --timeshift-auto Automatically detect Timeshifts snapshot directory for timeshift >= 22.06
# -o, --timeshift-old Look for snapshots in directory of Timeshift <v22.06 (requires --timeshift-auto)
# -l, --log-file Specify a logfile to write to
# -v, --verbose Let the log of the daemon be more verbose
# -s, --syslog Write to syslog
DAEMON_ARGS="--syslog" # Snapper
# DAEMON_ARGS="--syslog --timeshift-auto --verbose" # Timeshift >= 22.06
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load LSB init functions.
# This is the path for Debian and Devuan, may vary on other distributions.
. /lib/lsb/init-functions
do_start() {
start-stop-daemon \
--start \
--background \
--make-pidfile \
--pidfile "$PIDFILE" \
--exec "$DAEMON" -- \
$DAEMON_ARGS \
"$SNAPSHOTS"
}
do_stop() {
start-stop-daemon \
--stop \
--quiet \
--retry=TERM/30/KILL/5 \
--pidfile "$PIDFILE"
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if do_start; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if do_stop; then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
sleep 1
if do_start; then
log_end_msg 0
else
log_end_msg 1
fi
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME"
exit $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"
exit 2
;;
esac
exit 0