Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: pcscd
  4. # Required-Start: $local_fs $remote_fs $syslog
  5. # Required-Stop: $local_fs $remote_fs $syslog
  6. # Should-Start: udev hal
  7. # Should-Stop: udev hal
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: Daemon to access a smart card using PC/SC
  11. # Description: The PC/SC daemon is used to dynamically
  12. # allocate/deallocate reader drivers at runtime and manage
  13. # connections to the readers.
  14. ### END INIT INFO
  15.  
  16. # Authors:
  17. # Carlos Prados Bocos <cprados@debian.org>
  18. # Ludovic Rousseau <rousseau@debian.org>
  19.  
  20. # Do NOT "set -e"
  21.  
  22. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  23. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  24. DESC="PCSC Lite resource manager"
  25. NAME=pcscd
  26. DAEMON=/usr/sbin/local/$NAME
  27. PIDFILE=/var/run/pcscd/$NAME.pid
  28. SCRIPTNAME=/etc/init.d/$NAME
  29.  
  30. # if you need to pass arguments to pcscd you should edit the file
  31. # /etc/default/pcscd and add a line
  32. # DAEMON_ARGS="--your-option"
  33.  
  34. # Exit if the package is not installed
  35. [ -x "$DAEMON" ] || exit 0
  36.  
  37. # Read configuration variable file if it is present
  38. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  39.  
  40. # Load the VERBOSE setting and other rcS variables
  41. . /lib/init/vars.sh
  42.  
  43. # Define LSB log_* functions.
  44. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  45. . /lib/lsb/init-functions
  46.  
  47. # get LANG variable (code from /etc/init.d/keymap.sh)
  48. ENV_FILE="none"
  49. [ -r /etc/environment ] && ENV_FILE="/etc/environment"
  50. [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
  51.  
  52. value=$(egrep "^[^#]*LANG=" $ENV_FILE | tail -n1 | cut -d= -f2)
  53. eval LANG=$value
  54.  
  55. #
  56. # Function that starts the daemon/service
  57. #
  58. do_start()
  59. {
  60. # Return
  61. # 0 if daemon has been started
  62. # 1 if daemon was already running
  63. # 2 if daemon could not be started
  64. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  65. || return 1
  66. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  67. $DAEMON_ARGS \
  68. || return 2
  69. # Add code here, if necessary, that waits for the process to be ready
  70. # to handle requests from services started subsequently which depend
  71. # on this one. As a last resort, sleep for some time.
  72. }
  73.  
  74. #
  75. # Function that stops the daemon/service
  76. #
  77. do_stop()
  78. {
  79. # Return
  80. # 0 if daemon has been stopped
  81. # 1 if daemon was already stopped
  82. # 2 if daemon could not be stopped
  83. # other if a failure occurred
  84. start-stop-daemon --stop --quiet --retry=3 --pidfile $PIDFILE --name $NAME
  85. RETVAL="$?"
  86. [ "$RETVAL" = 2 ] && return 2
  87. }
  88.  
  89. #
  90. # Function that sends a SIGHUP to the daemon/service
  91. #
  92. do_reload() {
  93. #
  94. # If the daemon can reload its configuration without
  95. # restarting (for example, when it is sent a SIGHUP),
  96. # then implement that here.
  97. #
  98. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  99. return 0
  100. }
  101.  
  102. case "$1" in
  103. start)
  104. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  105. do_start
  106. case "$?" in
  107. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  108. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  109. esac
  110. ;;
  111. stop)
  112. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  113. do_stop
  114. case "$?" in
  115. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  116. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  117. esac
  118. ;;
  119. #reload|force-reload)
  120. #
  121. # If do_reload() is not implemented then leave this commented out
  122. # and leave 'force-reload' as an alias for 'restart'.
  123. #
  124. #log_daemon_msg "Reloading $DESC" "$NAME"
  125. #do_reload
  126. #log_end_msg $?
  127. #;;
  128. restart|force-reload)
  129. #
  130. # If the "reload" option is implemented then remove the
  131. # 'force-reload' alias
  132. #
  133. log_daemon_msg "Restarting $DESC" "$NAME"
  134. do_stop
  135. case "$?" in
  136. 0|1)
  137. do_start
  138. case "$?" in
  139. 0) log_end_msg 0 ;;
  140. 1) log_end_msg 1 ;; # Old process is still running
  141. *) log_end_msg 1 ;; # Failed to start
  142. esac
  143. ;;
  144. *)
  145. # Failed to stop
  146. log_end_msg 1
  147. ;;
  148. esac
  149. ;;
  150. *)
  151. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  152. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  153. exit 3
  154. ;;
  155. esac
  156.  
  157. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement