Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. #!/bin/sh
  2. ### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
  3. ### BEGIN INIT INFO
  4. # Provides: freeswitch
  5. # Required-Start: $network $remote_fs $local_fs
  6. # Required-Stop: $network $remote_fs $local_fs
  7. # Should-Start: postgresql mysql memcached mongodb
  8. # Should-Stop: postgresql mysql memcached mongodb
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: FreeSWITCH Softswitch
  12. # Description: FreeSWITCH Softswitch
  13. ### END INIT INFO
  14.  
  15. # Author: Travis Cross <tc@traviscross.com>
  16.  
  17. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  18. DESC=freeswitch
  19. NAME=freeswitch
  20. DAEMON=/usr/bin/freeswitch
  21. USER=www-data
  22. GROUP=www-data
  23. DAEMON_ARGS="-u $USER -g $GROUP-ncwait"
  24. CONFDIR=/etc/$NAME
  25. RUNDIR=/var/run/$NAME
  26. PIDFILE=$RUNDIR/$NAME.pid
  27. SCRIPTNAME=/etc/init.d/$NAME
  28. WORKDIR=/var/log/$NAME
  29.  
  30. [ -x $DAEMON ] || exit 0
  31. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  32. . /lib/init/vars.sh
  33. . /lib/lsb/init-functions
  34.  
  35. do_start() {
  36. if ! [ -f $CONFDIR/freeswitch.xml ]; then
  37. echo "$NAME is not configured so not starting.">&2
  38. echo "Please add configuration under /etc/freeswitch">&2
  39. echo "e.g. Install freeswitch-conf-vanilla, then:">&2
  40. echo "cp -a /usr/share/freeswitch/conf/vanilla /etc/freeswitch">&2
  41. return 3
  42. fi
  43.  
  44. # Directory in /var/run may disappear on reboot (e.g. when tmpfs used for /var/run).
  45. mkdir -p $RUNDIR
  46. chown -R $USER: $RUNDIR
  47. chmod -R ug=rwX,o= $RUNDIR
  48.  
  49. start-stop-daemon --start --quiet \
  50. --pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
  51. --test > /dev/null \
  52. || return 1
  53. ulimit -s 240
  54. start-stop-daemon --start --quiet \
  55. --pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
  56. --chdir $WORKDIR -- $DAEMON_ARGS $DAEMON_OPTS \
  57. || return 2
  58. return 0
  59. }
  60.  
  61. stop_fs() {
  62. start-stop-daemon --stop --quiet \
  63. --pidfile $PIDFILE --name $NAME --user $USER \
  64. --retry=TERM/30/KILL/5
  65. }
  66.  
  67. stop_fs_children() {
  68. start-stop-daemon --stop --quiet \
  69. --exec $DAEMON \
  70. --oknodo --retry=0/30/KILL/5
  71. }
  72.  
  73. do_stop() {
  74. stop_fs
  75. RETVAL="$?"
  76. [ "$RETVAL" -eq 2 ] && return 2
  77. stop_fs_children
  78. [ "$?" -eq 2 ] && return 2
  79. rm -f $PIDFILE
  80. return "$RETVAL"
  81. }
  82.  
  83. do_reload() {
  84. start-stop-daemon --stop --quiet \
  85. --pidfile $PIDFILE --name $NAME --user $USER \
  86. --signal HUP
  87. }
  88.  
  89. case "$1" in
  90. start)
  91. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
  92. do_start
  93. case "$?" in
  94. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  95. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  96. esac
  97. ;;
  98. stop)
  99. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  100. do_stop
  101. case "$?" in
  102. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  103. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  104. esac
  105. ;;
  106. status)
  107. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  108. ;;
  109. reload|force-reload)
  110. log_daemon_msg "Reloading $DESC" "$NAME"
  111. do_reload
  112. log_end_msg $?
  113. ;;
  114. restart)
  115. log_daemon_msg "Restarting $DESC" "$NAME"
  116. do_stop
  117. case "$?" in
  118. 0|1)
  119. do_start
  120. case "$?" in
  121. 0) log_end_msg 0 ;;
  122. 1|*) log_end_msg 1 ;;
  123. esac
  124. ;;
  125. *) log_end_msg 1 ;;
  126. esac
  127. ;;
  128. *)
  129. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  130. exit 3
  131. ;;
  132. esac
  133.  
  134. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement