In order to start up a service (such as an Unframed Architecture TCP/IP server daemon), the init.d system can be used to make it start up whenever the system starts up.
Copy the service program file to the binary folder (use sudo if not root):
cp progname /usr/sbin/progname
Create a script in the init.d folder (example at the end of this post):
/etc/init.d/progname
Give the script executable permission:
chmod 755 /etc/init.d/progname
Change directory to the init.d folder:
cd /etc/init.d
Add the service to the startup list with low priority:
update-rc.d progname defaults 97 03
Restart the system; check to see if the daemon is running:
ps -A --sort cmd
To manually start the service:
service progname start
In this case, progname is a TCP/IP service daemon (listening on port 6666), so this command will display the status:
sudo netstat -lpn |grep :6666
Returns (where 12818 is the PID):
tcp 0 0 0.0.0.0:6666 0.0.0.0:* LISTEN 12818/progname
Example init.d script:
(Modified from: /etc/init.d/skeleton on local system)
#!/bin/sh # kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script fi ### BEGIN INIT INFO # Provides: skeleton # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Example initscript # Description: This file should be used to construct scripts to be # placed in /etc/init.d. This example start a # single forking daemon capable of writing a pid # file. To get other behavoirs, implemend # do_start(), do_stop() or other functions to # override the defaults in /lib/init/init-d-script. ### END INIT INFO # Author: Someone Somewhere (someone@somewhere.net) # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. DESC="progname" DAEMON=/usr/sbin/progname