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.
 
 
 
 
 
 

101 lines
2.8 KiB

#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=50
STOP=10
USE_PROCD=1
PROG=/usr/lib/gnunet/libexec/gnunet-service-arm
GNUNET_HOME=/var/run/gnunet
LOGFILE=$GNUNET_HOME/gnunet.log
CONFIGFILE=$GNUNET_HOME/gnunet.conf
SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
chmodown_execbin() {
execname=/usr/lib/gnunet/libexec/gnunet-$1
if [ -x $execname ]; then
chmod $2 $execname
[ "$3" ] && chown $3 $execname
fi
}
fix_libexec_permissions() {
[ -e /usr/share/gnunet/.permfix ] && return
for helper in $SUID_ROOT_HELPERS; do
chmodown_execbin helper-$helper u+s
done
chmodown_execbin helper-dns 4750 root:gnunetdns
chmodown_execbin service-dns 2750 root:gnunetdns
touch /usr/share/gnunet/.permfix
}
prepare_config() {
if [ ! -e "$GNUNET_HOME" ]; then
mkdir -p $GNUNET_HOME
chown gnunet:gnunet $GNUNET_HOME
chmod 0750 $GNUNET_HOME
fi
touch $CONFIGFILE
chown root:gnunet $CONFIGFILE
chmod 0640 $CONFIGFILE
gnunet-config -c $CONFIGFILE -s PATHS -o GNUNET_HOME -V $GNUNET_HOME
# minimal persistency in /etc/gnunet
[ ! -d /etc/gnunet ] && {
mkdir -p /etc/gnunet
chown gnunet:gnunet /etc/gnunet
}
# defaults paths
gnunet-config -c $CONFIGFILE -s PATHS -o GNUNET_CONFIG_HOME -V /etc/gnunet
gnunet-config -c $CONFIGFILE -s PEER -o PRIVATE_KEY -V /etc/gnunet/private_key.ecc
gnunet-config -c $CONFIGFILE -s identity -o EGODIR -V /etc/gnunet/identity/egos
gnunet-config -c $CONFIGFILE -s revocation -o DATABASE -V /etc/gnunet/revocation.dat
gnunet-config -c $CONFIGFILE -s nse -o PROOFFILE -V /etc/gnunet/proof.dat
gnunet-config -c $CONFIGFILE -s namestore-sqlite -o FILENAME -V /etc/gnunet/namestore.sqlite
# enable all installed transport plugins
transport_plugins=$(gnunet-config -c $CONFIGFILE -s transport -o PLUGINS)
for transplug in /usr/lib/gnunet/libgnunet_plugin_transport_*.so; do
transplug=$( echo $transplug |
sed -ne 's!^.*_transport_\(.*\)\.so$!\1!p' )
[ -n "$( echo $transport_plugins | grep $transplug )" ] ||
transport_plugins="$transport_plugins $transplug"
done
gnunet-config -c $CONFIGFILE -s transport -o PLUGINS -V "$transport_plugins"
# apply config from UCI
_gnunet_section=""
config_cb()
{
# $1 "Type"
# $2 "Name"
local __TYPE="$1"
local __NAME="${2/_/-}"
[ "${__TYPE}" = "gnunet-config" ] && _gnunet_section="${__NAME}"
[ "${__TYPE}" = "gnunet-exit-service" ] && _gnunet_section="${__NAME}.gnunet."
}
option_cb() {
# $1 name of variable
# $2 value
local __OPT="$1"
local __VAL="$2"
gnunet-config -c $CONFIGFILE -s ${_gnunet_section} -o ${__OPT} -V "${__VAL}"
}
config_load gnunet
return 0
}
start_service() {
fix_libexec_permissions
prepare_config
procd_open_instance
procd_set_param user gnunet
procd_set_param command $PROG -c $CONFIGFILE -l $LOGFILE
procd_set_param respawn
procd_close_instance
}