open-iscsi / targetcli-fb

Command shell for managing Linux LIO kernel target
Apache License 2.0
101 stars 69 forks source link

targetcli could use a systemd service file #152

Open gonzoleeman opened 4 years ago

gonzoleeman commented 4 years ago

Targetcli can use the "service" concept of systemd to ensure it's configuration is restored at startup tie and cleared at shutdown time. It can also be handy for other services to be able to sequence themselves before or after targetcli is usable.

For example, openSUSE is using:

[Unit]
Description="Generic Target-Mode Service (fb)"
DefaultDependencies=No
After=network.target target.service
Before=remote-fs-pre.target

[Service]
Type=oneshot
Environment=CONFIG_FILE=/etc/target/saveconfig.json
EnvironmentFile=-/etc/sysconfig/targetcli
ExecStart=-/usr/bin/targetcli restoreconfig $CONFIG_FILE
RemainAfterExit=true
ExecStop=/usr/bin/targetcli clearconfig confirm=True
ExecReload=/usr/bin/targetcli restoreconfig $CONFIG_FILE clearexisting

[Install]
WantedBy=remote-fs.target

This not only manages targetcli configuration, but it also allows overriding the configuration file

pkalever commented 4 years ago

@gonzoleeman have you came across https://github.com/open-iscsi/rtslib-fb/blob/master/systemd/target.service ?

This is what we use at gluster, https://github.com/gluster/gluster-block/blob/master/systemd/gluster-block-target.service.in

gonzoleeman commented 4 years ago

@gonzoleeman have you came across https://github.com/open-iscsi/rtslib-fb/blob/master/systemd/target.service ?

This is what we use at gluster, https://github.com/gluster/gluster-block/blob/master/systemd/gluster-block-target.service.in

No, I was not familiar with that. Interesting.