[Main]
Type = oneshot
Version = %%version%%
Description = "Check filesystem partition"
User = ( root )
Depends = ( system-fontnkey devices-branch )
StdOut = s6log:%%livedir%%/log/system-fsck

[Start]
Execute =
(
    if { 66-yeller -cdp system-fsck -1 /dev/console check filesystem }

    execl-envfile ${ConfFile}
    ifelse -X { test ${FORCECHCK} = yes }
    {
        if { 66-yeller -cdp system-fsck -1 /dev/console FORCECHCK was asked... }
        execl-cmdline -s {
            pipeline { fsck -f ${Args} } 66-yeller -Scdp system-fsck -1 /dev/console
        }
    }
    foreground {
        pipeline { execl-cmdline -s { fsck ${Args} } } 66-yeller -Scdp system-fsck -1 /dev/console
    }
    importas ? ?
    ifelse { test $? -gt 1 }
    {
        66-yeller -Wcdp system-fsck -1 /dev/console fsck reports errors -- at least system should be rebooted
    }
    true
)

[Environment]
Args=!-A -T -a noopts=_netdev
ConfFile=!%%bootconf%%
