Changes

From SME Server
Jump to navigationJump to search
4,669 bytes removed ,  22:54, 19 July 2016
no edit summary
Line 1,134: Line 1,134:     
  sv t /service/httpd-e-smith
 
  sv t /service/httpd-e-smith
[[category:developer]]
     −
===chkconfig and runlevel information===
+
===Add a custom service===
[http://linuxcommand.org/man_pages/chkconfig8.html chkconfig] provides a  simple  command-line  tool  for  maintaining  the /etc/rc[0-6].d  directory  hierarchy by relieving system administrators of the task of directly manipulating the  numerous  symbolic  links  in those directories.
  −
 
  −
You need to say to SME Server to add the script to each run level you have specified at the top of your init script( Default-Start: 2 3 4 5 and Default-Stop: 0 1 6 ). For Linux using rpm as centos or redhat, you can use
  −
 
  −
chkconfig YOUR_SERVICE_NAME --add
  −
 
  −
You can set the levels where the initscript has to start
  −
chkconfig YOUR_SERVICE_NAME --level 2345 on
  −
 
  −
If you want to see which runlevel your script will run in
  −
 
  −
chkconfig YOUR_SERVICE_NAME --list
  −
you can pipe the command
  −
chkconfig --list | egrep "nfs|rpc"
  −
 
  −
example :
  −
# chkconfig dhcp-dns --list
  −
dhcp-dns      0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt
  −
 
  −
===allow a service to start for a particular time===
  −
{{Note box| '''If you want to start a service at boot time, a relevant page needs  [[Add_a_custom_service|also your attention ]]'''}}
  −
If your package implements a server or daemon, you will probably want it to be started automatically when the system boots. The SME Server boots in runlevel 7, so you can get an idea of the startup processes by listing the contents of /etc/rc.d/rc7.d.
  −
 
  −
These are similar to the init scripts you may be familiar with from other Linux systems, with one important difference. Instead of pointing to scripts within /etc/rc.d/init.d, all of those init entries are links to /etc/rc.d/init.d/e-smith-service. This is a wrapper which checks the configuration database to see if the service is supposed to be running and if so, starts the service from /etc/rc.d/init.d/whatever.
  −
 
  −
So for example, you might have:
  −
 
  −
S90squid -> /etc/rc.d/init.d/e-smith-service
  −
 
  −
The e-smith-service script looks up the name it was invoked with (S90squid), drops the prefix (leaving squid), checks the configuration database for the "squid" service, then if it's supposed to run, does:
  −
 
  −
/etc/rc.d/init.d/squid start
  −
 
  −
* with this way SME's knows how to/if start the service at startup
  −
 
  −
config set '''myapplicationname''' service status enabled
  −
 
  −
cd /etc/rc.d/init.d
  −
ln -s /path/to/myinitscript '''myapplicationname'''
  −
 
  −
'''We are creating a symlink of the original startup script with a new name (the point is that '''myapplicationname''' must be identical to the service name above)'''
  −
 
  −
cd /etc/rc7.d
  −
ln -s  /etc/rc.d/init.d/e-smith-service '''SXXmyapplicationname'''
  −
 
  −
we create a symlink to e-smith-service startup script with a name where: S tells SME to start XX are numbers
  −
 
  −
You can decide when to start the service '''myapplicationname''', but you should not start something that need the network before the network itself is up and running. Therefore you can see the content of /etc/rc7.d and see which scripts are needed to execute your new startup script
  −
 
  −
signal-event remoteaccess-update
  −
service '''myapplicationname''' start
  −
====Creating or deleting a service====
  −
 
  −
*Creating and starting service
  −
 
  −
ln -f -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S98popfile
  −
/sbin/e-smith/db configuration set popfile service status enabled
  −
/sbin/e-smith/signal-event remoteaccess-update
  −
service popfile start
  −
 
  −
*Deleting and unregistering service
  −
 
  −
service popfile stop
  −
sleep 3
  −
rm -f /etc/rc7.d/S98popfile
  −
rm -f /etc/rc.d/init.d/popfile
  −
/sbin/e-smith/config delete popfile
  −
/sbin/e-smith/signal-event remoteaccess-update
  −
 
  −
====Create a service with db command and set network access====
  −
[[DB_Variables_Configuration#Additional_information_on_customizing_iptables]]
  −
 
  −
Create a custom-named service definition in the configuration database.
  −
 
  −
db configuration set <servicename> service
  −
 
  −
Apply your desired firewall restrictions to any existing SME 'service' or to a custom-named service that you have created. Combine a custom-named service with port-forwarding to create customized firewall rules.
  −
 
  −
db configuration setprop <servicename> TCPPort <portnumber>
  −
db configuration setprop <servicename> TCPPorts <portnumbers> # Ranges of ports are defined with a : not a -
  −
db configuration setprop <servicename> UDPPort <portnumber>
  −
db configuration setprop <servicename> UDPPorts <portnumbers> # Ranges of ports are defined with a : not a -
  −
db configuration setprop <servicename> status enabled|disabled
  −
db configuration setprop <servicename> access public|private
  −
db configuration setprop <servicename> AllowHosts a.b.c.d,x.y.z.0/24
  −
db configuration setprop <servicename> DenyHosts e.f.g.h,l.m.n.0/24
  −
 
  −
 
  −
Effectuate the changes you have made
  −
signal-event remoteaccess-update
      +
see this [Add_a_custom_service page]
 
==SSL==
 
==SSL==
 
===Test SSL certificate===
 
===Test SSL certificate===

Navigation menu