Fix systemd-import services

On debian, systemd complains about missing /bin/awk because it
actually is located at /usr/bin/awk. It is not a good idea to
hardcode binary paths because different linux distros use different
paths. According to systemd's man page it is absolutely safe to
miss paths for binaries located at standard locations (/bin,
/sbin, /usr/bin, ...).

Further, replace this more or less complicated awk command by
grep.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Issue #8510
This commit is contained in:
Michael Niewöhner 2019-03-17 22:47:15 +01:00 committed by Brian Behlendorf
parent 3b2618927c
commit e03b25a564
2 changed files with 2 additions and 2 deletions

View File

@ -13,7 +13,7 @@ ConditionPathExists=@sysconfdir@/zfs/zpool.cache
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | /bin/awk '$1 != \"-\" {print; exit}')" ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')"
[Install] [Install]
WantedBy=zfs-import.target WantedBy=zfs-import.target

View File

@ -12,7 +12,7 @@ ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=@sbindir@/zpool import -aN -o cachefile=none ExecStart=@sbindir@/zpool import -aN -o cachefile=none
ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | /bin/awk '$1 != \"-\" {print; exit}')" ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')"
[Install] [Install]
WantedBy=zfs-import.target WantedBy=zfs-import.target