xref: /freebsd/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in (revision 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)
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    case ",$rootflags," in                                                                     \
16        *,zfsutil,*) ;;                                                                        \
17        ,,) rootflags=zfsutil ;;                                                               \
18        *)  rootflags="zfsutil,$rootflags" ;;                                                  \
19    esac;                                                                                      \
20    exec systemctl set-environment BOOTFS="$root" BOOTFSFLAGS="$rootflags"'
21
22[Install]
23WantedBy=zfs-import.target
24