diff --git a/conf/shellinabox.service b/conf/shellinabox.service new file mode 100644 index 0000000..1d84cc0 --- /dev/null +++ b/conf/shellinabox.service @@ -0,0 +1,38 @@ +# Make it bootable at startup +[Install] +WantedBy=multi-user.target + +[Unit] +Documentation=man:shellinaboxd(1) + +# Sourcing LSB Path +SourcePath=/etc/init.d/shellinabox +Description=LSB: Shell In A Box Daemon +Before=multi-user.target +Before=graphical.target +After=network-online.target + +# Awaits LDAP is specific user binding at startup +After=slapd.service +After=remote-fs.target +Wants=network-online.target +Requires=slapd.service + +[Service] +Type=forking + +# Calls for restart when there is a fail +Restart=on-failure +RestartSec=5min +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=no +SuccessExitStatus=5 6 + +# Gracefully wait for every service to come up +ExecStartPre=/bin/sleep 3 +ExecStart=/etc/init.d/shellinabox start +ExecStop=/etc/init.d/shellinabox stop +ExecReload=/etc/init.d/shellinabox reload diff --git a/scripts/backup b/scripts/backup index 91e67ed..bb288e0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -27,6 +27,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/shellinabox" ynh_backup --src_path="/etc/default/shellinabox" +ynh_backup --src_path="/etc/systemd/system/shellinabox.service" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 6342e63..4ab3824 100644 --- a/scripts/install +++ b/scripts/install @@ -33,6 +33,10 @@ ynh_script_progression --message="Configuring a systemd service..." # Allow the service to log in syslog ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox" + +# Enable SystemD respawn feature and boot order to avoid premature crashs +cp ../conf/shellinabox.service /etc/systemd/system/shellinabox.service + systemctl daemon-reload #================================================= diff --git a/scripts/remove b/scripts/remove index fead557..8bd4725 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,6 +28,9 @@ ynh_remove_nginx_config # Remove metapackage and its dependencies ynh_package_autopurge shellinabox +# Remove Systemd auto-created daemon +rm -f /etc/systemd/system/shellinabox.service + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 81b5b2e..f0f71a5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -24,6 +24,7 @@ ynh_script_progression --message="Restoring various files..." --weight=3 ynh_restore_file --origin_path="/etc/shellinabox" ynh_restore_file --origin_path="/etc/default/shellinabox" +ynh_restore_file --origin_path="/etc/systemd/system/shellinabox.service" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index b008c8a..d60073c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,6 +46,8 @@ ynh_add_config --template="../conf/shellinabox" --destination="/etc/default/shel #================================================= ynh_script_progression --message="Upgrading systemd configuration..." +cp ../conf/shellinabox.service /etc/systemd/system/shellinabox.service + ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox" systemctl daemon-reload