1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-20 14:03:36 +03:00
one/share/pkgs/services/systemd/opennebula-ssh-agent.service
Petr Ospalý 59426dd8fd
F #2152: Improve SSH agent service unit (#4627)
- change /run/one to /var/run/one - /run/one is either bind-mount or
  symlink and can be changed while /var/run/one is configured via
  tmpfiles.d/opennebula*.conf - it is more consistent now
- add a dependency to SSH agent unit for remote-fs in the cases when
  /var/lib/one (oneadmin's home) is on a network filesystem
- add SSH agent support to opennebula-hem service

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
2020-04-29 14:59:46 +02:00

25 lines
872 B
Desktop File

[Unit]
Description=OpenNebula SSH agent
After=remote-fs.target
[Service]
Type=forking
Group=oneadmin
User=oneadmin
Environment=SSH_AUTH_SOCK=/var/run/one/ssh-agent.sock
# ssh-agent is executed via shell wrapper to workaround a SELinux issue
ExecStartPre=/bin/sh -c "echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK > /var/run/one/ssh-agent.env"
ExecStart=/bin/sh -c "exec /usr/bin/ssh-agent -a $SSH_AUTH_SOCK"
ExecStartPost=-/bin/sh -c "/usr/bin/ssh-add"
ExecStopPost=/usr/bin/rm -f /var/run/one/ssh-agent.env
ExecReload=/bin/sh -c "/usr/bin/ssh-add -D && /usr/bin/ssh-add"
Restart=on-failure
# NOTE: ssh-agent returns "2" as the exit code on SIGTERM or on termination via:
# SSH_AGENT_PID=??? ssh-agent -k
# without this following directive the "systemctl stop" would fail and cleanup
# (ExecStopPost) would not be triggered...
SuccessExitStatus=2
[Install]
WantedBy=default.target