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 0202264..87e1a39 100644 --- a/scripts/backup +++ b/scripts/backup @@ -35,6 +35,7 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="/etc/shellinabox" ynh_backup --src_path="/etc/default/shellinabox" +ynh_backup --src_path="/etc/systemd/system/shellinabox.service" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 205ed3f..050d054 100644 --- a/scripts/install +++ b/scripts/install @@ -78,10 +78,14 @@ ynh_script_progression --message="Configuring shellinabox..." --weight=2 cp ../conf/shellinabox /etc/default/shellinabox ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox" + # Allow the service to log in syslog ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox" -systemctl daemon-reload +# Enable SystemD respawn feature and boot order to avoid premature crashs +cp ../conf/shellinabox.service /etc/systemd/system/shellinabox.service + +systemctl daemon-reload ynh_systemd_action --service_name=shellinabox --action=restart #================================================= @@ -90,6 +94,7 @@ ynh_systemd_action --service_name=shellinabox --action=restart # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="/etc/default/shellinabox" +ynh_store_file_checksum --file="/etc/systemd/system/shellinabox.service" #================================================= # GENERIC FINALIZATION diff --git a/scripts/remove b/scripts/remove index 93df963..fce51e0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,6 +39,9 @@ ynh_script_progression --message="Removing shellinabox..." --weight=20 ynh_package_autopurge shellinabox +# Remove Systemd auto-created daemon +rm -f /etc/systemd/system/shellinabox.service + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 1d248bd..a124250 100644 --- a/scripts/restore +++ b/scripts/restore @@ -59,6 +59,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= 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" # Allow the service to log in syslog ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox" diff --git a/scripts/upgrade b/scripts/upgrade index c3b5993..2565a8b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,10 +69,13 @@ ynh_script_progression --message="Upgrading shellinabox configuration..." --weig # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different --file="/etc/default/shellinabox" +ynh_backup_if_checksum_is_different --file="/etc/systemd/system/shellinabox.service" cp ../conf/shellinabox /etc/default/shellinabox ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox" +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