Advertisement
Guest User

A Samba4 init Script

a guest
Sep 28th, 2011
1,300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: samba
  5. # Required-Start: $network $local_fs $remote_fs
  6. # Required-Stop: $network $local_fs $remote_fs
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: start Samba daemons
  10. ### END INIT INFO
  11.  
  12. #
  13. # Start/stops the Samba daemon (samba).
  14. # Adapted from the Samba 3 packages.
  15. #
  16.  
  17. SAMBAPID=/var/run/samba/samba.pid
  18.  
  19. # clear conflicting settings from the environment
  20. unset TMPDIR
  21.  
  22. # See if the daemon and the config file are there
  23. test -x /usr/local/samba/sbin -a -r /usr/local/samba/etc/ || exit 0
  24.  
  25. . /lib/lsb/init-functions
  26.  
  27. case "$1" in
  28. start)
  29. log_daemon_msg "Starting Samba 4 daemon" "samba"
  30.  
  31. if ! start-stop-daemon --start --quiet --oknodo --exec /usr/local/samba/sbin/samba -- -D; then
  32. log_end_msg 1
  33. exit 1
  34. fi
  35.  
  36. log_end_msg 0
  37. ;;
  38. stop)
  39. log_daemon_msg "Stopping Samba 4 daemon" "samba"
  40.  
  41. start-stop-daemon --stop --quiet --name samba $SAMBAPID
  42. # Wait a little and remove stale PID file
  43. sleep 1
  44. if [ -f $SAMBAPID ] && ! ps h `cat $SAMBAPID` > /dev/null
  45. then
  46. # Stale PID file (samba was succesfully stopped),
  47. # remove it (should be removed by samba itself IMHO.)
  48. rm -f $SAMBAPID
  49. fi
  50.  
  51. log_end_msg 0
  52.  
  53. ;;
  54. restart|force-reload)
  55. $0 stop
  56. sleep 1
  57. $0 start
  58. ;;
  59. *)
  60. echo "Usage: /etc/init.d/samba {start|stop|restart|force-reload}"
  61. exit 1
  62. ;;
  63. esac
  64.  
  65. exit 0
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement