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.

55 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=50
  4. STOP=10
  5. USE_PROCD=1
  6. PROG=/usr/lib/gnunet/libexec/gnunet-service-arm
  7. GNUNET_HOME=/var/run/gnunet
  8. CONFIGFILE=$GNUNET_HOME/gnunet.conf
  9. SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
  10. chmodown_execbin() {
  11. execname=/usr/lib/gnunet/libexec/gnunet-$1
  12. if [ -x $execname ]; then
  13. chmod $2 $execname
  14. [ "$3" ] && chown $3 $execname
  15. fi
  16. }
  17. fix_libexec_permissions() {
  18. [ -e /usr/share/gnunet/.permfix ] && return
  19. for helper in $SUID_ROOT_HELPERS; do
  20. chmodown_execbin helper-$helper u+s
  21. done
  22. chmodown_execbin helper-dns 4750 root:gnunetdns
  23. chmodown_execbin service-dns 2750 root:gnunetdns
  24. touch /usr/share/gnunet/.permfix
  25. }
  26. prepare_config() {
  27. mkdir -p $GNUNET_HOME
  28. chown gnunet:gnunet $GNUNET_HOME
  29. chmod 0750 $GNUNET_HOME
  30. touch $CONFIGFILE
  31. chown root:gnunet $CONFIGFILE
  32. chmod 0640 $CONFIGFILE
  33. gnunet-config -c /tmp/run/gnunet/gnunet.conf -s PATHS -o GNUNET_HOME -V $GNUNET_HOME
  34. defaultservices=$( gnunet-config -c /tmp/run/gnunet/gnunet.conf -s arm -o DEFAULTSERVICES )
  35. defaultservices="$defaultservices gns2dns"
  36. gnunet-config -c /tmp/run/gnunet/gnunet.conf -s arm -o DEFAULTSERVICES -V "$defaultservices"
  37. }
  38. start_service() {
  39. fix_libexec_permissions
  40. [ ! -e $GNUNET_HOME ] && prepare_config
  41. procd_open_instance
  42. procd_set_param user gnunet
  43. procd_set_param command $PROG -c $CONFIGFILE
  44. procd_set_param respawn
  45. procd_close_instance
  46. }