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.

66 lines
1.9 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. LOGFILE=$GNUNET_HOME/gnunet.log
  9. CONFIGFILE=$GNUNET_HOME/gnunet.conf
  10. SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
  11. chmodown_execbin() {
  12. execname=/usr/lib/gnunet/libexec/gnunet-$1
  13. if [ -x $execname ]; then
  14. chmod $2 $execname
  15. [ "$3" ] && chown $3 $execname
  16. fi
  17. }
  18. fix_libexec_permissions() {
  19. [ -e /usr/share/gnunet/.permfix ] && return
  20. for helper in $SUID_ROOT_HELPERS; do
  21. chmodown_execbin helper-$helper u+s
  22. done
  23. chmodown_execbin helper-dns 4750 root:gnunetdns
  24. chmodown_execbin service-dns 2750 root:gnunetdns
  25. touch /usr/share/gnunet/.permfix
  26. }
  27. prepare_config() {
  28. mkdir -p $GNUNET_HOME
  29. chown gnunet:gnunet $GNUNET_HOME
  30. chmod 0750 $GNUNET_HOME
  31. touch $CONFIGFILE
  32. chown root:gnunet $CONFIGFILE
  33. chmod 0640 $CONFIGFILE
  34. gnunet-config -c $CONFIGFILE -s PATHS -o GNUNET_HOME -V $GNUNET_HOME
  35. # enable gns2dns service
  36. defaultservices=$( gnunet-config -c /tmp/run/gnunet/gnunet.conf -s arm -o DEFAULTSERVICES )
  37. defaultservices="$defaultservices dns2gns"
  38. # enable all installed transport plugins
  39. gnunet-config -c $CONFIGFILE -s arm -o DEFAULTSERVICES -V "$defaultservices"
  40. transport_plugins=$(gnunet-config -c $CONFIGFILE -s transport -o PLUGINS)
  41. for transplug in /usr/lib/gnunet/libgnunet_plugin_transport_*.so; do
  42. transplug=$( echo $transplug |
  43. sed -ne 's!^.*_transport_\(.*\)\.so$!\1!p' )
  44. [ -n "$( echo $transport_plugins | grep $transplug )" ] ||
  45. transport_plugins="$transport_plugins $transplug"
  46. done
  47. gnunet-config -c $CONFIGFILE -s transport -o PLUGINS -V "$transport_plugins"
  48. }
  49. start_service() {
  50. fix_libexec_permissions
  51. [ ! -e $GNUNET_HOME ] && prepare_config
  52. procd_open_instance
  53. procd_set_param user gnunet
  54. procd_set_param command $PROG -c $CONFIGFILE -l $LOGFILE
  55. procd_set_param respawn
  56. procd_close_instance
  57. }