Advertisement
imKobz

Untitled

Apr 7th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Init Script to run stunnel in daemon mode at boot time.
  4. #
  5. # Author: Riccardo Riva - RPM S.r.l.
  6. # Revision 1.0 - 2010 November, 11
  7.  
  8. #====================================================================
  9. # Run level information:
  10. #
  11. # chkconfig: 2345 99 99
  12. # description: Secure Tunnel
  13. # processname: stunnel
  14. #
  15. # Run "/sbin/chkconfig --add stunnel" to add the Run levels.
  16. # This will setup the symlinks and set the process to run at boot.
  17. #====================================================================
  18.  
  19. #====================================================================
  20. # Paths and variables and system checks.
  21.  
  22. # Source function library
  23. . /etc/rc.d/init.d/functions
  24.  
  25. # Check that networking is up.
  26. #
  27. [ ${NETWORKING} ="yes" ] || exit 0
  28.  
  29. # Path to the executable.
  30. #
  31. SEXE=/usr/bin/stunnel
  32.  
  33. # Path to the configuration file.
  34. #
  35. CONF=/etc/stunnel/stunnel.conf
  36.  
  37. # Check the configuration file exists.
  38. #
  39. if [ ! -f $CONF ] ; then
  40. echo "The configuration file cannot be found!"
  41. exit 0
  42. fi
  43.  
  44. # Path to the lock file.
  45. #
  46. LOCK_FILE=/var/lock/subsys/stunnel
  47.  
  48. #====================================================================
  49.  
  50. # Run controls:
  51.  
  52. prog=$"stunnel"
  53.  
  54. RETVAL=0
  55.  
  56. # Start stunnel as daemon.
  57. #
  58. start() {
  59. if [ -f $LOCK_FILE ]; then
  60. echo "stunnel is already running!"
  61. exit 0
  62. else
  63. echo -n $"Starting $prog: "
  64. $SEXE $CONF
  65. fi
  66.  
  67. RETVAL=$?
  68. [ $RETVAL -eq 0 ] && success
  69. echo
  70. [ $RETVAL -eq 0 ] && touch $LOCK_FILE
  71. return $RETVAL
  72. }
  73.  
  74. # Stop stunnel.
  75. #
  76. stop() {
  77. if [ ! -f $LOCK_FILE ]; then
  78. echo "stunnel is not running!"
  79. exit 0
  80.  
  81. else
  82.  
  83. echo -n $"Shutting down $prog: "
  84. killproc stunnel
  85. RETVAL=$?
  86. [ $RETVAL -eq 0 ]
  87. rm -f $LOCK_FILE
  88. echo
  89. return $RETVAL
  90.  
  91. fi
  92. }
  93.  
  94. # See how we were called.
  95. case "$1" in
  96. start)
  97. start
  98. ;;
  99. stop)
  100. stop
  101. ;;
  102. restart)
  103. stop
  104. start
  105. ;;
  106. condrestart)
  107. if [ -f $LOCK_FILE ]; then
  108. stop
  109. start
  110. RETVAL=$?
  111. fi
  112. ;;
  113. status)
  114. status stunnel
  115. RETVAL=$?
  116. ;;
  117. *)
  118. echo $"Usage: $0 {start|stop|restart|condrestart|status}"
  119. RETVAL=1
  120. esac
  121.  
  122. exit $RETVAL
  123.  
  124. #--- End of file ---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement