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.

58 lines
1.2 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006 OpenWrt.org
  3. START=60
  4. BIN=/usr/sbin/pptpd
  5. DEFAULT=/etc/default/$BIN
  6. RUN_D=/var/run
  7. PID_F=$RUN_D/$BIN.pid
  8. CONFIG=/var/etc/pptpd.conf
  9. CHAP_SECRETS=/var/etc/chap-secrets
  10. setup_login() {
  11. local section="$1"
  12. config_get username "$section" username
  13. config_get password "$section" password
  14. [ -n "$username" ] || return 0
  15. [ -n "$password" ] || return 0
  16. echo "$username pptp-server $password *" >> $CHAP_SECRETS
  17. }
  18. setup_config() {
  19. local section="$1"
  20. config_get enabled "$section" enabled
  21. [ "$enabled" -eq 0 ] && return 1
  22. mkdir -p /var/etc
  23. cp /etc/pptpd.conf $CONFIG
  24. config_get localip "$section" localip
  25. config_get remoteip "$section" remoteip
  26. [ -n "$localip" ] && echo "localip $localip" >> $CONFIG
  27. [ -n "$remoteip" ] && echo "remoteip $remoteip" >> $CONFIG
  28. return 0
  29. }
  30. start_pptpd() {
  31. [ -f $DEFAULT ] && . $DEFAULT
  32. mkdir -p $RUN_D
  33. for m in arc4 sha1_generic slhc crc-ccitt ppp_generic ppp_async ppp_mppe; do
  34. insmod $m >/dev/null 2>&1
  35. done
  36. ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets
  37. service_start $BIN $OPTIONS -c $CONFIG
  38. }
  39. start() {
  40. config_load pptpd
  41. setup_config pptpd || return
  42. config_foreach setup_login login
  43. start_pptpd
  44. }
  45. stop() {
  46. service_stop $BIN
  47. }