diff options
-rwxr-xr-x | systemd-zfs-partition-backup.sh | 32 | ||||
-rw-r--r-- | systemd-zfs-partition-backup/AUR/PKGBUILD | 13 |
2 files changed, 30 insertions, 15 deletions
diff --git a/systemd-zfs-partition-backup.sh b/systemd-zfs-partition-backup.sh index e40c241..aa3951f 100755 --- a/systemd-zfs-partition-backup.sh +++ b/systemd-zfs-partition-backup.sh | |||
@@ -1,16 +1,6 @@ | |||
1 | #!/usr/bin/bash | 1 | #!/usr/bin/bash |
2 | # Written in 2020 by Max Christian Pohle <webmaster@coderonline.de> | 2 | # Written in 2020 by Max Christian Pohle <webmaster@coderonline.de> |
3 | 3 | ||
4 | # check for a configuration file and source it in if its there | ||
5 | test -f /etc/default/systemd-zfs-partition-backup &&\ | ||
6 | source /etc/default/systemd-zfs-partition-backup | ||
7 | |||
8 | DISK_NAME=$1 | ||
9 | DISK_NAME_ESCAPED=$(systemd-escape "$DISK_NAME") | ||
10 | |||
11 | logger "Disk: $DISK_NAME" | ||
12 | logger " : $DISK_NAME_ESCAPED (escaped)" | ||
13 | |||
14 | function beep() { | 4 | function beep() { |
15 | test -f /usr/bin/beep &&\ | 5 | test -f /usr/bin/beep &&\ |
16 | env -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER -u SUDO_UID /usr/bin/beep $@ | 6 | env -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER -u SUDO_UID /usr/bin/beep $@ |
@@ -34,9 +24,29 @@ function stop() { | |||
34 | } | 24 | } |
35 | 25 | ||
36 | 26 | ||
27 | |||
28 | # check for a configuration file and source it in if its there | ||
29 | test -f /etc/default/systemd-zfs-partition-backup &&\ | ||
30 | source /etc/default/systemd-zfs-partition-backup | ||
31 | |||
32 | DISK_NAME=$1 | ||
33 | DISK_NAME_ESCAPED=$(systemd-escape "$DISK_NAME") | ||
34 | |||
35 | logger "Disk: $DISK_NAME" | ||
36 | logger " : $DISK_NAME_ESCAPED (escaped)" | ||
37 | |||
38 | DATASETS_WITH_DISKNAME=$(zfs list -H -o name | grep $DISK_NAME) | ||
39 | |||
40 | |||
41 | [ -z "$DATASETS_WITH_DISKNAME" ] &&\ | ||
42 | (fail "no datasets found with name $DISK_NAME. Please create some." ; exit 1) | ||
43 | |||
44 | logger "Datasets: $DATASETS_WITH_DISKNAME" | ||
45 | |||
37 | # iterate over all datasets | 46 | # iterate over all datasets |
38 | for i in $(zfs list -H -o name); | 47 | for i in ${DATASETS_WITH_DISKNAME[@]}; |
39 | do | 48 | do |
49 | logger "assertion: $(basename $i) == $DISK_NAME" | ||
40 | # compare the 'tail' of the PATH against the disk name... | 50 | # compare the 'tail' of the PATH against the disk name... |
41 | if [ "$(basename $i)" == "$DISK_NAME" ]; then | 51 | if [ "$(basename $i)" == "$DISK_NAME" ]; then |
42 | start $DISK_NAME | 52 | start $DISK_NAME |
diff --git a/systemd-zfs-partition-backup/AUR/PKGBUILD b/systemd-zfs-partition-backup/AUR/PKGBUILD index 3d76738..8150e9b 100644 --- a/systemd-zfs-partition-backup/AUR/PKGBUILD +++ b/systemd-zfs-partition-backup/AUR/PKGBUILD | |||
@@ -13,12 +13,17 @@ depends=( | |||
13 | 'mkinitcpio' | 13 | 'mkinitcpio' |
14 | ) | 14 | ) |
15 | source=("http://git.entwicklerseite.de/zfs-bash-tools/snapshot/zfs-bash-tools-master.tar.gz") | 15 | source=("http://git.entwicklerseite.de/zfs-bash-tools/snapshot/zfs-bash-tools-master.tar.gz") |
16 | sha256sums=('a8636f9fba3129feb07075daa802b47d6c338d35823a9bb8e3685efa799d1c3a') | 16 | sha256sums=('a6089d8abb9c5a433f0f1513194b726f7c6072849891e1922cd664be79cc4df0') |
17 | 17 | ||
18 | package() { | 18 | package() { |
19 | install -D zfs-bash-tools-master/${pkgname}.sh ../pkg/${pkgname}/usr/bin/${pkgname}.sh | 19 | install -D zfs-bash-tools-master/${pkgname}.sh \ |
20 | install -D zfs-bash-tools-master/${pkgname}/systemd/${pkgname}\@.service ../pkg/${pkgname}/usr/lib/systemd/system/${pkgname}.service | 20 | ../pkg/${pkgname}/usr/bin/${pkgname}.sh |
21 | install -D zfs-bash-tools-master/${pkgname}/udev/rules.d/90-${pkgname}.rules ../pkg/${pkgname}/etc/udev/rules.d/99-${pkgname}.rules | 21 | |
22 | install -D -m 644 zfs-bash-tools-master/${pkgname}/systemd/${pkgname}\@.service \ | ||
23 | ../pkg/${pkgname}/usr/lib/systemd/system/${pkgname}\@.service | ||
24 | |||
25 | install -D -m 644 zfs-bash-tools-master/${pkgname}/udev/rules.d/90-${pkgname}.rules \ | ||
26 | ../pkg/${pkgname}/etc/udev/rules.d/90-${pkgname}.rules | ||
22 | } | 27 | } |
23 | 28 | ||
24 | # vim: ft=bash | 29 | # vim: ft=bash |