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