xref: /freebsd/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in (revision 7ef62cebc2f965b0f640263e179276928885e33d)
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