#!/bin/sh
# The daemons description
#
# GNU-GPL (c) Eko M. Budi, 2004
#         (c) Vector Linux, 2004

# return default run_level (2 - 5) and order for known daemons.
# The recomendation :
#   00-09 = reserved
#   10-19 = hardware (pcmcia,hotplug,...)
#   20-29 = networking (network,firewall,portmap,...)
#   30-39 = network client (netfs, cups, ...)
#   40-49 = local services (log, cron, ...)
#   50-69 = intranet servers (nfs, smb, ...)
#   70-89 = internet servers (inet, http, ...)
#   90-99 = additional services (at, gpm, ...)
#
# Note that this scheme lists full services.
# However, Vector Linux decides to move fundamental services to rc.M
# including: hardware, networking, and some network clients (netfs).
# The reasons are for speed and stability.
#

service_order()
{
case $1 in
  ## Lets start the syslog first
  syslog|log)
    echo 2345 10
    ;;
  pcmcia)
    echo 2345 11
    ;;
  hotplug|usb)
    echo 2345 12
    ;;
  kudzu)
    echo 2345 13;
    ;;
  alsasound|alsa)
    echo 2345 14
    ;;
  apm|apmd|acpid)
    echo 2345 18
    ;;
  # Start networking ...
  # for paranoid admins to close the doors before changing their clothes ;)
  paranoid|paranoid_firewall)
    echo 2345 20
    ;;
  network)
    echo 2345 21
    ;;
  umlnet|wlan|pppd)
    echo 2345 22
    ;;
  # firewall that opens the things
  firewall*|portsentry|gshield)
    echo 2345 23
    ;;
  dhcpd)
    echo 2345 24
    ;;
  bind|named|dnsmasq)
    echo 2345 25
    ;;
  ## Start client networking ...
  rpc|portmap)
    echo 2345 30
    ;;
  ypbind)
    echo 2345 31
    ;;
  netfs)
    echo 2345 32
    ;;
  lisa)
    echo 45 33
    ;;
  printer|lpd|lp|cups)
    echo 2345 39
    ;;
  hplip)
    echo 2345 35
    ;;    
  ## Local daemons
  cron)
    echo 2345 40
    ;;
  at)
    echo 2345 41
    ;;
  quota)
    echo 2345 42
    ;;
  acc|accounting)
    echo 2345 43
    ;;
  ## Now turn on INTRANET server daemons
  inetd|inet|xinetd|xinet)
    echo 2345 50
    ;;
  sshd|ssh|openssh)
    echo 2345 51
    ;;
  nisd|nis|yp)
    echo 35 52
    ;;
  nfsd)
    echo 35 53
    ;;
  samba|smbd|nmbd)
    echo 2345 54
    ;;
  database|mysql|postgress)
    echo 2345 55
    ;;
  xfstt)
    echo 35 69
    ;;
  ## INTERNET server daemons can up now ...
  ftpd|proftp|proftpd)
    echo 35 71
    ;;
  smptd|sendmail|postfix|qmail)
    echo 35 72
    ;;
  imap|imapd)
    echo 35 73
    ;;
  nntp|nntpd)
    echo 35 74
    ;;
  identd|oidentd|midentd)
    echo 35 79
    ;;
  httpd|apache)
    echo 35 80
    ;;
  lampp|xampp)
    echo 35 80
    ;;
  jboss)
    echo 35 87
    ;;
  jsp|tomcat|jetty)
    echo 35 88
    ;;
  ## additional local jobs
  gpm)
    echo 2345 91
    ;;
  *) # find_next_order()
    ii=99
    while [ $ii -gt 50 ]; do
	if [ -f $1/S${ii}* ]; then
	    let ii=$ii+1
	    break
	fi
	let ii=$ii-1
    done
    echo 2345 $ii
    ;;
  esac
}

# return daemon description
service_desc()
{
case $1 in
apm|apmd)
  echo "Advanced Power Management"
  ;;
acpid)
  echo "Advanced Config & Power Interface"
  ;;
alsa|alsasound)
  echo "Advanced Linux Sound system"
  ;;
syslog|log) 
  echo "system and kernel loggers"
  ;;
at)
  echo "exact time tasks scheduler"
  ;;
cron)
  echo "periodic tasks scheduler"
  ;;
portmap)
  echo "network portmap, needed by NIS and NFS." 
  ;;
gpm)
  echo "console mouse daemon"
  ;;
lp|lpd)
  echo "classic Linux printing system"
  ;;
inetd|inet|xinet|xinetd)
  echo "internet service super server"
  ;;
dhcp|dhcpd)
  echo "DHCP server"
  ;;
cups)
  echo "Common Unix Printer Service"
  ;;
ssh|sshd) 
  echo "Secure shell daemon"
  ;;
lampp|xampp) 
  echo "Combo Apache+MySQL+PHP+Postfix"
  ;;
portsentry|gshield)  
  echo "Protect network ports from outside attack"
  ;;
xfstt)
  echo "TrueType font server for X. Not needed for XFree 4."
  ;;
apache|http|httpd|monkey|nanoweb)
  echo "HTTP web server"
  ;;
mysql|postgresql)
  echo "SQL database server"
  ;;
nisd|nis|ypserv|yp)
  echo "Server of Network Information Services"
  ;;
yp|ypbind)
  echo "Client for Network Information Service"
  ;;
netfs)
  echo "Mount remote NFS/SAMBA directories"
  ;; 
nfs|nfsd)
  echo "Network File Server"
  ;;
lisa)
  echo "LAN Information Server"
  ;;
postfix|qmail|sendmail)
  echo "mail server daemon"
  ;;
squid|tinyproxy)
  echo "HTTP/FTP proxy server"
  ;;
dnsmasq)
  echo "Light DNS and DHCP server"
  ;;
named|bind)
  echo "BIND Domain Name Server"
  ;;
quota)
  echo "Limit disk usage for users"
  ;;
network)
  echo "Initialize TCP/IP networking"
  ;;
firewall)
  echo "Filter and masquerade TCP/IP Networking"
  ;;
paranoid)
  echo "Initial firewall"
  ;;
identd|oidentd|midentd)
  echo "ident server for IRC (chatting)"
  ;;
*)
  echo "$1 daemon"
esac
}
