Startup Script Ubuntu per octvqed, soft-echo per zaptel

In questi giorni sto configurando un centralino voip utilizzando FreeSwitch utilizzando ubuntu 8.04.03 LTS come sistema operativo. Tra le altre cose abbiamo deciso di rivendere al cliente le licenze per il soft-echo sviluppato dalla Octasic.
Essendo i loro script di avvio specifici per i sistemi redhat e derivati ho deciso di riscrivere lo script di avvio del demone utilizzando le funzioni messe a disposizione da Ubuntu. Possibilmente lo script funzionerà senza problemi anche su Debian!

Per utilizzare questo script di startup è necessario creare un file dentro /etc/defaults chiamato octvqed contenente il percorso al file di configurazione, il percorso all'eseguibile, il percorso al file pid ed infine eventuali opzioni aggiuntive.

Ecco qui un esempio

  1. # Set path to octvqed binary
  2. OCTVQED_BIN=/usr/sbin/octvqed
  3.  
  4. # Set path to octvqed config file
  5. OCTVQED_CONF=/etc/octvqed.conf
  6.  
  7. # Set path to pidfile
  8. PIDFILE=/var/run/octvqed.pid
  9.  
  10. # Set octvqed options
  11. OPTIONS=

Di seguito il codice dello script di avvio

  1. #!/bin/bash
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: octvqed
  5. # Required-Start:
  6. # Required-Stop:
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: octvqed is the octvqe echo cancellation service daemon for zaptel module
  10. ### END INIT INFO
  11.  
  12. set -e
  13.  
  14. # Set Path
  15. PATH="/sbin:/bin:/usr/sbin:/usr/bin"
  16.  
  17. # Include lsb functions
  18. . /lib/lsb/init-functions
  19.  
  20. # Check if service config exists
  21. if [ -f /etc/default/octvqed ];
  22. then
  23. # Include service config
  24. . /etc/default/octvqed
  25. else
  26. log_failure_msg "Could not find /etc/default/octvqed (aborting)"
  27. exit 1
  28. fi
  29.  
  30. # Set daemon variable
  31. DAEMON=$OCTVQED_BIN;
  32.  
  33. # Check if OCTVQED_BIN exists or not
  34. test -x $DAEMON || exit 0 ;
  35.  
  36. # Check if config file exists
  37. if [ ! -f $OCTVQED_CONF ];
  38. then
  39. log_failure_msg "Could not find $OCTVQED_CONF (aborting)"
  40. exit 1
  41. fi
  42.  
  43. start()
  44. {
  45. # Check if octvqed pidfile exists
  46. if [ -f $PIDFILE ];
  47. then
  48. # Check if pid file contains a running octvqed instance
  49. if [ "$(ps -p $(cat $PIDFILE) >/dev/null 2>&1; echo $?)" == "0" ];
  50. then
  51. log_failure_msg "octvqed service already running"
  52. return
  53. fi
  54. fi
  55.  
  56. # Advise user
  57. log_action_begin_msg "Starting softecho for zaptel: octvqe"
  58.  
  59. # Load octvqe module
  60. log_action_cont_msg "loading octvqe module"
  61. modprobe octvqe || log_action_end_msg 1
  62.  
  63. # Start the daemon
  64. log_action_cont_msg "starting octvqed service"
  65. if [ "$QUIET" != yes ];
  66. then
  67. $OCTVQED_BIN $OPTIONS -f $OCTVQED_CONF > /dev/null;
  68. else
  69. $OCTVQED_BIN $OPTIONS -f $OCTVQED_CONF;
  70. fi
  71.  
  72. # Wait a couple of secs to let octvqed to do the job (creating devices and more)
  73. log_action_cont_msg "checking if octvqed is started"
  74. sleep 2
  75.  
  76. # Check if octvqed pidfile exists
  77. if [ -f $PIDFILE ];
  78. then
  79. # Check if pid file contains a running octvqed instance
  80. if [ "$(ps -p $(cat $PIDFILE) >/dev/null 2>&1; echo $?)" == "0" ];
  81. then
  82. log_action_end_msg 0
  83. return
  84. fi
  85. fi
  86.  
  87. # octvqed didn't started!
  88. log_action_end_msg 1
  89. exit 1
  90. }
  91.  
  92. stop()
  93. {
  94. # Advise user
  95. log_daemon_msg "Stopping softecho for zaptel: octvqe"
  96.  
  97. # Stop the daemon
  98. if start-stop-daemon --stop --pidfile $PIDFILE;
  99. then
  100. log_end_msg 0
  101. else
  102. log_end_msg 1
  103. exit 1
  104. fi
  105. }
  106.  
  107. case "$1" in
  108. start)
  109. start
  110. ;;
  111. stop)
  112. stop
  113. ;;
  114. restart)
  115. stop
  116. start
  117. ;;
  118. *)
  119. echo "Usage: {start|stop|restart}"
  120. exit 1
  121. ;;
  122. esac
  123. exit 0

Invia nuovo commento

Il contenuto di questo campo è privato e non verrà mostrato pubblicamente. If you have a Gravatar account, used to display your avatar.
  • Indirizzi web o e-mail vengono trasformati in link automaticamente
  • Elementi HTML permessi: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Linee e paragrafi vanno a capo automaticamente.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <csharp>, <diff>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <sql>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

Ulteriori informazioni sulle opzioni di formattazione

CAPTCHA
Test per verificare se la richiesta proviene da un software o meno.