Skip to main content
Add another mean to check the correctness of the configuration
Source Link
Huygens
  • 9.9k
  • 3
  • 34
  • 36

To add a new init script is quite straight forward on Suse.

The best way would be to create a shell script that will call your PHP script. This shell script should have in its header the following comment:

#!/bin/sh
#chkconfig: 35 99 00
#description: Notify of boot completion

You can find a typical template (with loads of explanatory comments) in /etc/init.d/skeleton.compat (that one supports the chkconfig syntax, you have also 7etc/init.d/skeleton which supports newer LSB standard, but it is a bit more complicate to explain you how to set it up, though it is more powerful). This template includes the necessary code to hook your PHP script. You will see a start case where you would have to call your PHP script.

The important number I gave you are on the chkconfig line.

  • 35: means that this script will be called in either init 3 (console mode, usual for server) or init 5 (graphical mode, more common for desktop)
  • 99: is the priority in either init 3 or 5. It means that it will be called last. Note that some other boot scripts could be called with a priority 99.
  • 00: is the priority for shutdown/reboot. You could also have a notification as soon as the system is going down.

Once you have written your script, copy it to /etc/init.d let's assume that your init script is called boot-notification, then you would do (as root):

# chown root:root boot-notification
# chmod 0750 boot-notification
# mv boot-notification /etc/init.d/

Then you need to "register" the script in the init system. You will use the chkconfig command (again as root):

# chkconfig --add boot-notification

Check that this was taken into account properly:

# chkconfig boot-notification
boot-notification on

If you see on, it is good!
Then you can further check that the script is one of the last to be run by looking into each init level. If you chose only runlevel 3, then you could do this:

$ ls -l /etc/init.d/rc3.d/S*

This will return a list of links to init scripts. The link to your script should be at the end (or near it) of the list.

Note: If you want to play around with the more dynamic way of writing init scripts, I would advise reading these 2 pages:

To add a new init script is quite straight forward on Suse.

The best way would be to create a shell script that will call your PHP script. This shell script should have in its header the following comment:

#!/bin/sh
#chkconfig: 35 99 00
#description: Notify of boot completion

You can find a typical template (with loads of explanatory comments) in /etc/init.d/skeleton.compat (that one supports the chkconfig syntax, you have also 7etc/init.d/skeleton which supports newer LSB standard, but it is a bit more complicate to explain you how to set it up, though it is more powerful). This template includes the necessary code to hook your PHP script. You will see a start case where you would have to call your PHP script.

The important number I gave you are on the chkconfig line.

  • 35: means that this script will be called in either init 3 (console mode, usual for server) or init 5 (graphical mode, more common for desktop)
  • 99: is the priority in either init 3 or 5. It means that it will be called last. Note that some other boot scripts could be called with a priority 99.
  • 00: is the priority for shutdown/reboot. You could also have a notification as soon as the system is going down.

Once you have written your script, copy it to /etc/init.d let's assume that your init script is called boot-notification, then you would do (as root):

# chown root:root boot-notification
# chmod 0750 boot-notification
# mv boot-notification /etc/init.d/

Then you need to "register" the script in the init system. You will use the chkconfig command (again as root):

# chkconfig --add boot-notification

Check that this was taken into account properly:

# chkconfig boot-notification
boot-notification on

If you see on, it is good!

Note: If you want to play around with the more dynamic way of writing init scripts, I would advise reading these 2 pages:

To add a new init script is quite straight forward on Suse.

The best way would be to create a shell script that will call your PHP script. This shell script should have in its header the following comment:

#!/bin/sh
#chkconfig: 35 99 00
#description: Notify of boot completion

You can find a typical template (with loads of explanatory comments) in /etc/init.d/skeleton.compat (that one supports the chkconfig syntax, you have also 7etc/init.d/skeleton which supports newer LSB standard, but it is a bit more complicate to explain you how to set it up, though it is more powerful). This template includes the necessary code to hook your PHP script. You will see a start case where you would have to call your PHP script.

The important number I gave you are on the chkconfig line.

  • 35: means that this script will be called in either init 3 (console mode, usual for server) or init 5 (graphical mode, more common for desktop)
  • 99: is the priority in either init 3 or 5. It means that it will be called last. Note that some other boot scripts could be called with a priority 99.
  • 00: is the priority for shutdown/reboot. You could also have a notification as soon as the system is going down.

Once you have written your script, copy it to /etc/init.d let's assume that your init script is called boot-notification, then you would do (as root):

# chown root:root boot-notification
# chmod 0750 boot-notification
# mv boot-notification /etc/init.d/

Then you need to "register" the script in the init system. You will use the chkconfig command (again as root):

# chkconfig --add boot-notification

Check that this was taken into account properly:

# chkconfig boot-notification
boot-notification on

If you see on, it is good!
Then you can further check that the script is one of the last to be run by looking into each init level. If you chose only runlevel 3, then you could do this:

$ ls -l /etc/init.d/rc3.d/S*

This will return a list of links to init scripts. The link to your script should be at the end (or near it) of the list.

Note: If you want to play around with the more dynamic way of writing init scripts, I would advise reading these 2 pages:

Source Link
Huygens
  • 9.9k
  • 3
  • 34
  • 36

To add a new init script is quite straight forward on Suse.

The best way would be to create a shell script that will call your PHP script. This shell script should have in its header the following comment:

#!/bin/sh
#chkconfig: 35 99 00
#description: Notify of boot completion

You can find a typical template (with loads of explanatory comments) in /etc/init.d/skeleton.compat (that one supports the chkconfig syntax, you have also 7etc/init.d/skeleton which supports newer LSB standard, but it is a bit more complicate to explain you how to set it up, though it is more powerful). This template includes the necessary code to hook your PHP script. You will see a start case where you would have to call your PHP script.

The important number I gave you are on the chkconfig line.

  • 35: means that this script will be called in either init 3 (console mode, usual for server) or init 5 (graphical mode, more common for desktop)
  • 99: is the priority in either init 3 or 5. It means that it will be called last. Note that some other boot scripts could be called with a priority 99.
  • 00: is the priority for shutdown/reboot. You could also have a notification as soon as the system is going down.

Once you have written your script, copy it to /etc/init.d let's assume that your init script is called boot-notification, then you would do (as root):

# chown root:root boot-notification
# chmod 0750 boot-notification
# mv boot-notification /etc/init.d/

Then you need to "register" the script in the init system. You will use the chkconfig command (again as root):

# chkconfig --add boot-notification

Check that this was taken into account properly:

# chkconfig boot-notification
boot-notification on

If you see on, it is good!

Note: If you want to play around with the more dynamic way of writing init scripts, I would advise reading these 2 pages: