xref: /openbmc/openbmc/meta-openembedded/meta-networking/recipes-extended/tgt/files/tgtd.service (revision 03907ee1b9e938b9ce87f4d781c905c2a41592c2)
1*03907ee1SPatrick Williams[Unit]
2*03907ee1SPatrick WilliamsDescription=tgtd iSCSI target daemon
3*03907ee1SPatrick WilliamsAfter=network.target
4*03907ee1SPatrick Williams
5*03907ee1SPatrick Williams[Service]
6*03907ee1SPatrick WilliamsEnvironmentFile=@SYSCONFDIR@/sysconfig/tgtd
7*03907ee1SPatrick Williams
8*03907ee1SPatrick WilliamsExecStart=@SBINDIR@/tgtd -f $TGTD_OPTS
9*03907ee1SPatrick Williams# see bz 848942. workaround for a race for now.
10*03907ee1SPatrick WilliamsExecStartPost=@BASE_BINDIR@/sleep 5
11*03907ee1SPatrick Williams# Put tgtd into "offline" state until all the targets are configured.
12*03907ee1SPatrick Williams# We don't want initiators to (re)connect and fail the connection
13*03907ee1SPatrick Williams# if it's not ready.
14*03907ee1SPatrick WilliamsExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline
15*03907ee1SPatrick Williams# Configure the targets.
16*03907ee1SPatrick WilliamsExecStartPost=@SBINDIR@/tgt-admin -e -c $TGTD_CONFIG
17*03907ee1SPatrick Williams# Put tgtd into "ready" state.
18*03907ee1SPatrick WilliamsExecStartPost=@SBINDIR@/tgtadm --op update --mode sys --name State -v ready
19*03907ee1SPatrick Williams
20*03907ee1SPatrick Williams# Update configuration for targets. Only targets which
21*03907ee1SPatrick Williams# are not in use will be updated.
22*03907ee1SPatrick WilliamsExecReload=@SBINDIR@/tgt-admin --update ALL -c $TGTD_CONFIG
23*03907ee1SPatrick Williams
24*03907ee1SPatrick Williams# NOTE: Shutdown of the iscsi target may cause data corruption
25*03907ee1SPatrick Williams# for initiators that are connected.
26*03907ee1SPatrick WilliamsExecStop=@SBINDIR@/tgtadm --op update --mode sys --name State -v offline
27*03907ee1SPatrick Williams# Remove all targets. It only removes targets which are not in use.
28*03907ee1SPatrick WilliamsExecStop=@SBINDIR@/tgt-admin --update ALL -c /dev/null
29*03907ee1SPatrick Williams# tgtd will exit if all targets were removed
30*03907ee1SPatrick WilliamsExecStop=@SBINDIR@/tgtadm --op delete --mode system
31*03907ee1SPatrick Williams
32*03907ee1SPatrick Williams[Install]
33*03907ee1SPatrick WilliamsWantedBy=multi-user.target
34