rescuegui 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: rescuegui
  4. # Required-Start: $local_fs
  5. # Should-Start:
  6. # Required-Stop: $local_fs
  7. # Should-Stop:
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: Start rescuegui application
  11. ### END INIT INFO
  12. # The definition of actions: (From LSB 3.1.0)
  13. # start start the service
  14. # stop stop the service
  15. # restart stop and restart the service if the service is already running,
  16. # otherwise start the service
  17. # try-restart restart the service if the service is already running
  18. # reload cause the configuration of the service to be reloaded without
  19. # actually stopping and restarting the service
  20. # force-reload cause the configuration to be reloaded if the service supports
  21. # this, otherwise restart the service if it is running
  22. # status print the current status of the service
  23. # The start, stop, restart, force-reload, and status actions shall be supported
  24. # by all init scripts; the reload and the try-restart actions are optional
  25. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  26. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  27. DESC="rescuegui"
  28. NAME="SWUpdateGUI"
  29. DAEMON=/opt/rescueGUI/SWUpdateGUI.lua
  30. PIDFILE=/var/run/$NAME.pid
  31. . /etc/init.d/functions || exit 1
  32. # Exit if the package is not installed
  33. [ -x "$DAEMON" ] || exit 0
  34. # Read configuration variable file if it is present
  35. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  36. #
  37. # Function that starts the daemon/service
  38. #
  39. do_start() {
  40. local status pid
  41. status=0
  42. pid=`pidofproc $NAME` || status=$?
  43. case $status in
  44. 0)
  45. echo "$DESC already running ($pid)."
  46. exit 1
  47. ;;
  48. *)
  49. echo "Starting $DESC ..."
  50. cd /opt/rescueGUI
  51. echo 0 > /sys/class/graphics/fbcon/cursor_blink
  52. export FONTDIR=/usr/share/fonts/truetype
  53. exec $DAEMON &
  54. exit 0
  55. ;;
  56. esac
  57. }
  58. #
  59. # Function that stops the daemon/service
  60. #
  61. do_stop() {
  62. local pid status
  63. status=0
  64. pid=`pidofproc $NAME` || status=$?
  65. case $status in
  66. 0)
  67. # Exit when fail to stop, the kill would complain when fail
  68. kill -s 15 $pid >/dev/null && rm -f $PIDFILE && \
  69. echo "Stopped $DESC ($pid)." || exit $?
  70. ;;
  71. *)
  72. echo "$DESC is not running; none killed." >&2
  73. ;;
  74. esac
  75. # Wait for children to finish too if this is a daemon that forks
  76. # and if the daemon is only ever run from this initscript.
  77. # If the above conditions are not satisfied then add some other code
  78. # that waits for the process to drop all resources that could be
  79. # needed by services started subsequently. A last resort is to
  80. # sleep for some time.
  81. return $status
  82. }
  83. #
  84. # Function that sends a SIGHUP to the daemon/service
  85. #
  86. do_reload() {
  87. local pid status
  88. status=0
  89. # If the daemon can reload its configuration without
  90. # restarting (for example, when it is sent a SIGHUP),
  91. # then implement that here.
  92. pid=`pidofproc $NAME` || status=$?
  93. case $status in
  94. 0)
  95. echo "Reloading $DESC ..."
  96. kill -s 1 $pid || exit $?
  97. ;;
  98. *)
  99. echo "$DESC is not running; none reloaded." >&2
  100. ;;
  101. esac
  102. exit $status
  103. }
  104. #
  105. # Function that shows the daemon/service status
  106. #
  107. status_of_proc () {
  108. local pid status
  109. status=0
  110. # pidof output null when no program is running, so no "2>/dev/null".
  111. pid=`pidofproc $NAME` || status=$?
  112. case $status in
  113. 0)
  114. echo "$DESC is running ($pid)."
  115. exit 0
  116. ;;
  117. *)
  118. echo "$DESC is not running." >&2
  119. exit $status
  120. ;;
  121. esac
  122. }
  123. case "$1" in
  124. start)
  125. do_start
  126. ;;
  127. stop)
  128. do_stop || exit $?
  129. ;;
  130. status)
  131. status_of_proc
  132. ;;
  133. restart)
  134. # Always start the service regardless the status of do_stop
  135. do_stop
  136. do_start
  137. ;;
  138. try-restart|force-reload)
  139. # force-reload is the same as reload or try-restart according
  140. # to its definition, the reload is not implemented here, so
  141. # force-reload is the alias of try-restart here, but it should
  142. # be the alias of reload if reload is implemented.
  143. #
  144. # Only start the service when do_stop succeeds
  145. do_stop && do_start
  146. ;;
  147. #reload)
  148. # If the "reload" action is implemented properly, then let the
  149. # force-reload be the alias of reload, and remove it from
  150. # try-restart|force-reload)
  151. #
  152. #do_reload
  153. #;;
  154. *)
  155. echo "Usage: $0 {start|stop|status|restart|try-restart|force-reload}" >&2
  156. exit 3
  157. ;;
  158. esac