dnscrypt-proxy.initd 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2014 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. DNSCRYPT_LOGFILE=${DNSCRYPT_LOGFILE:-/var/log/dnscrypt-proxy.log}
  5. rundir=${rundir:-/var/run/dnscrypt-proxy}
  6. pidfile=${pidfile:-${rundir}/dnscrypt-proxy.pid}
  7. rundir=${rundir:-/var/run/dnscrypt-proxy}
  8. runas_user=${runas_user:-dnscrypt}
  9. runas_group=${runas_user:-dnscrypt}
  10. depend() {
  11. use net
  12. before dns
  13. after logger
  14. }
  15. start() {
  16. if [ ! -d "${rundir}" ]; then
  17. mkdir "${rundir}"
  18. if [ -n "${runas_user}" ]; then
  19. touch "${DNSCRYPT_LOGFILE}"
  20. chown ${runas_user}:${runas_group} "${DNSCRYPT_LOGFILE}"
  21. chown -R ${runas_user}:${runas_group} "${rundir}"
  22. fi
  23. fi
  24. ebegin "Starting dnscrypt-proxy"
  25. start-stop-daemon --start --quiet \
  26. --exec /usr/sbin/dnscrypt-proxy \
  27. -- \
  28. --pidfile="${pidfile}" \
  29. --logfile="${DNSCRYPT_LOGFILE}" \
  30. --daemonize --user=${runas_user} \
  31. --local-address=${DNSCRYPT_LOCALIP}:${DNSCRYPT_LOCALPORT} \
  32. --resolver-address=${DNSCRYPT_RESOLVERIP}:${DNSCRYPT_RESOLVERPORT} \
  33. --provider-name=${DNSCRYPT_PROVIDER_NAME} \
  34. --provider-key=${DNSCRYPT_PROVIDER_KEY}
  35. eend $?
  36. }
  37. stop() {
  38. ebegin "Stopping dnscrypt-proxy"
  39. start-stop-daemon --stop --quiet --exec /usr/sbin/dnscrypt-proxy
  40. eend $?
  41. }