smb.initd 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2018 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License, v2 or later
  4. extra_started_commands="reload"
  5. [ -z "${piddir}" ] && piddir="/run/samba"
  6. depend() {
  7. after slapd
  8. need net
  9. use cupsd
  10. }
  11. DAEMONNAME="${SVCNAME##smb.}"
  12. [ "${DAEMONNAME}" != "smb" ] && daemon_list=${DAEMONNAME}
  13. signal_do() {
  14. local signal="$1"
  15. [ -z "${signal}" ] && return 0
  16. local result=0 last_result=0 daemon= cmd_exec=
  17. for daemon in ${daemon_list} ; do
  18. eval cmd_exec=\$${daemon}_${signal}
  19. if [ -n "${cmd_exec}" ]; then
  20. ebegin "${my_service_name} -> ${signal}: ${daemon}"
  21. #echo ${cmd} '->' ${!cmd}
  22. ${cmd_exec} > /dev/null
  23. last_result=$?
  24. eend ${last_result}
  25. fi
  26. result=$(( ${result} + ${last_result} ))
  27. done
  28. return ${result}
  29. }
  30. start() {
  31. ${my_service_PRE}
  32. [ -d "${piddir}" ] || mkdir -p "${piddir}"
  33. signal_do start && return 0
  34. eerror "Error: starting services (see system logs)"
  35. signal_do stop
  36. return 1
  37. }
  38. stop() {
  39. ${my_service_PRE}
  40. if signal_do stop ; then
  41. ${my_service_POST}
  42. return 0
  43. fi
  44. }
  45. reload() {
  46. ${my_service_PRE}
  47. signal_do reload
  48. }