You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

starwelsd.openrc 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/sbin/openrc-run
  2. # backward compatibility for existing gentoo layout
  3. #
  4. if [ -d "/var/lib/starwels/.starwels" ]; then
  5. STARWELSD_DEFAULT_DATADIR="/var/lib/starwels/.starwels"
  6. else
  7. STARWELSD_DEFAULT_DATADIR="/var/lib/starwelsd"
  8. fi
  9. STARWELSD_CONFIGFILE=${STARWELSD_CONFIGFILE:-/etc/starwels/starwels.conf}
  10. STARWELSD_PIDDIR=${STARWELSD_PIDDIR:-/var/run/starwelsd}
  11. STARWELSD_PIDFILE=${STARWELSD_PIDFILE:-${STARWELSD_PIDDIR}/starwelsd.pid}
  12. STARWELSD_DATADIR=${STARWELSD_DATADIR:-${STARWELSD_DEFAULT_DATADIR}}
  13. STARWELSD_USER=${STARWELSD_USER:-${STARWELS_USER:-starwels}}
  14. STARWELSD_GROUP=${STARWELSD_GROUP:-starwels}
  15. STARWELSD_BIN=${STARWELSD_BIN:-/usr/bin/starwelsd}
  16. STARWELSD_NICE=${STARWELSD_NICE:-${NICELEVEL:-0}}
  17. STARWELSD_OPTS="${STARWELSD_OPTS:-${STARWELS_OPTS}}"
  18. name="Starwels Daemon"
  19. description="Starwels cryptocurrency P2P network daemon"
  20. command="/usr/bin/starwelsd"
  21. command_args="-pid=\"${STARWELSD_PIDFILE}\" \
  22. -conf=\"${STARWELSD_CONFIGFILE}\" \
  23. -datadir=\"${STARWELSD_DATADIR}\" \
  24. -daemon \
  25. ${STARWELSD_OPTS}"
  26. required_files="${STARWELSD_CONFIGFILE}"
  27. start_stop_daemon_args="-u ${STARWELSD_USER} \
  28. -N ${STARWELSD_NICE} -w 2000"
  29. pidfile="${STARWELSD_PIDFILE}"
  30. # The retry schedule to use when stopping the daemon. Could be either
  31. # a timeout in seconds or multiple signal/timeout pairs (like
  32. # "SIGKILL/180 SIGTERM/300")
  33. retry="${STARWELSD_SIGTERM_TIMEOUT}"
  34. depend() {
  35. need localmount net
  36. }
  37. # verify
  38. # 1) that the datadir exists and is writable (or create it)
  39. # 2) that a directory for the pid exists and is writable
  40. # 3) ownership and permissions on the config file
  41. start_pre() {
  42. checkpath \
  43. -d \
  44. --mode 0750 \
  45. --owner "${STARWELSD_USER}:${STARWELSD_GROUP}" \
  46. "${STARWELSD_DATADIR}"
  47. checkpath \
  48. -d \
  49. --mode 0755 \
  50. --owner "${STARWELSD_USER}:${STARWELSD_GROUP}" \
  51. "${STARWELSD_PIDDIR}"
  52. checkpath -f \
  53. -o ${STARWELSD_USER}:${STARWELSD_GROUP} \
  54. -m 0660 \
  55. ${STARWELSD_CONFIGFILE}
  56. checkconfig || return 1
  57. }
  58. checkconfig()
  59. {
  60. if ! grep -qs '^rpcpassword=' "${STARWELSD_CONFIGFILE}" ; then
  61. eerror ""
  62. eerror "ERROR: You must set a secure rpcpassword to run starwelsd."
  63. eerror "The setting must appear in ${STARWELSD_CONFIGFILE}"
  64. eerror ""
  65. eerror "This password is security critical to securing wallets "
  66. eerror "and must not be the same as the rpcuser setting."
  67. eerror "You can generate a suitable random password using the following"
  68. eerror "command from the shell:"
  69. eerror ""
  70. eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
  71. eerror ""
  72. eerror "It is also recommended that you also set alertnotify so you are "
  73. eerror "notified of problems:"
  74. eerror ""
  75. eerror "ie: alertnotify=echo %%s | mail -s \"Starwels Alert\"" \
  76. "admin@foo.com"
  77. eerror ""
  78. return 1
  79. fi
  80. }