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.

59 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2017 OpenWrt.org
  3. USE_PROCD=1
  4. START=90
  5. STOP=10
  6. # default params
  7. PROG=/usr/sbin/i2pd
  8. USER="i2pd"
  9. GROUP="i2pd"
  10. PIDFILE=/var/run/i2pd.pid
  11. #DATADIR=/var/lib/i2pd
  12. CONFFILE=/etc/i2pd/i2pd.conf
  13. . /lib/functions.sh
  14. start_service() {
  15. local data_dir
  16. local addressbook_dir
  17. config_load i2pd
  18. config_get data_dir i2pd data_dir
  19. config_get addressbook_dir i2pd addressbook_dir
  20. ## Setting up data dir
  21. if [ ! -d "$data_dir" ]; then
  22. mkdir -p "$data_dir"
  23. ln -s /usr/share/i2pd/certificates "$data_dir/certificates"
  24. ln -s /etc/i2pd/tunnels.conf "$data_dir/tunnels.conf"
  25. if [ -n "$addressbook_dir" ]; then
  26. if [ ! -d "$addressbook_dir" ]; then
  27. mkdir -p "$addressbook_dir"
  28. fi
  29. ln -s "$addressbook_dir" "$data_dir/addressbook"
  30. fi
  31. fi
  32. ## We need permissions
  33. chown "$USER:$GROUP" "$data_dir"
  34. chown "$USER:$GROUP" "$addressbook_dir"
  35. touch "$PIDFILE"
  36. chown "$USER:adm" "$PIDFILE"
  37. procd_open_instance
  38. procd_set_param command "$PROG" --service --conf="$CONFFILE" --pidfile "$PIDFILE"
  39. ## Don't know about i2pd user's HOME
  40. procd_set_param env "HOME=$DATADIR"
  41. procd_set_param limits nofile=4096
  42. procd_set_param stdout 1
  43. procd_set_param stderr 1
  44. procd_set_param user "$USER"
  45. procd_set_param pidfile "$PIDFILE"
  46. procd_close_instance
  47. }