xref: /freebsd/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1[Unit]
2Description=Set BOOTFS and BOOTFSFLAGS environment variables for dracut
3DefaultDependencies=no
4After=zfs-import-cache.service
5After=zfs-import-scan.service
6Before=zfs-import.target
7
8[Service]
9Type=oneshot
10ExecStart=/bin/sh -c '                                                                         \
11    . /lib/dracut-zfs-lib.sh;                                                                  \
12    decode_root_args || exit 0;                                                                \
13    [ "$root" = "zfs:AUTO" ] && root="$(@sbindir@/zpool list -H -o bootfs | grep -m1 -vFx -)"; \
14    rootflags="$(getarg rootflags=)";                                                          \
15    [ "$(@sbindir@/zfs get -H -o value mountpoint "$root")" = legacy ] ||                      \
16        case ",$rootflags," in                                                                 \
17            *,zfsutil,*) ;;                                                                    \
18            ,,) rootflags=zfsutil ;;                                                           \
19            *)  rootflags="zfsutil,$rootflags" ;;                                              \
20        esac;                                                                                  \
21    exec systemctl set-environment BOOTFS="$root" BOOTFSFLAGS="$rootflags"'
22
23[Install]
24WantedBy=zfs-import.target
25