Signed-off-by: Bruno Randolf <b...@einfach.org> --- net/pptpd/Makefile | 5 ++++- net/pptpd/files/pptpd.config | 8 ++++++++ net/pptpd/files/pptpd.init | 46 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 net/pptpd/files/pptpd.config
diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile index e79e0a7..318ed11 100644 --- a/net/pptpd/Makefile +++ b/net/pptpd/Makefile @@ -22,7 +22,7 @@ include $(INCLUDE_DIR)/package.mk define Package/pptpd SECTION:=net CATEGORY:=Network - DEPENDS:=+kmod-ppp +kmod-gre +ppp + DEPENDS:=+kmod-ppp +kmod-gre +kmod-mppe +ppp TITLE:=PopTop pptp server URL:=http://www.poptop.org/ SUBMENU:=VPN @@ -41,6 +41,7 @@ MAKE_FLAGS += \ define Package/pptpd/conffiles /etc/pptpd.conf /etc/ppp/options.pptpd +/etc/config/pptpd endef define Package/pptpd/install @@ -58,6 +59,8 @@ define Package/pptpd/install $(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd $(INSTALL_DIR) $(1)/etc/ppp $(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/pptpd.config $(1)/etc/config/pptpd endef $(eval $(call BuildPackage,pptpd)) diff --git a/net/pptpd/files/pptpd.config b/net/pptpd/files/pptpd.config new file mode 100644 index 0000000..b2d5df5 --- /dev/null +++ b/net/pptpd/files/pptpd.config @@ -0,0 +1,8 @@ +config service 'pptpd' + option 'enabled' '0' + option 'localip' '192.168.0.1' + option 'remoteip' '192.168.0.20-30' + +config 'login' + option 'username' 'youruser' + option 'password' 'yourpass' diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init index a74973c..b1381b2 100644 --- a/net/pptpd/files/pptpd.init +++ b/net/pptpd/files/pptpd.init @@ -2,20 +2,56 @@ # Copyright (C) 2006 OpenWrt.org START=60 -BIN=pptpd +BIN=/usr/sbin/pptpd DEFAULT=/etc/default/$BIN RUN_D=/var/run PID_F=$RUN_D/$BIN.pid +CONFIG=/var/etc/pptpd.conf +CHAP_SECRETS=/var/etc/chap-secrets -start() { +setup_login() { + local section="$1" + + config_get username "$section" username + config_get password "$section" password + [ -n "$username" ] || return 0 + [ -n "$password" ] || return 0 + + echo "$username pptp-server $password *" >> $CHAP_SECRETS +} + +setup_config() { + local section="$1" + + config_get enabled "$section" enabled + [ "$enabled" -eq 0 ] && return 1 + + cp /etc/pptpd.conf $CONFIG + + config_get localip "$section" localip + config_get remoteip "$section" remoteip + [ -n "$localip" ] && echo "localip $localip" >> $CONFIG + [ -n "$remoteip" ] && echo "remoteip $remoteip" >> $CONFIG + return 0 +} + +start_pptpd() { [ -f $DEFAULT ] && . $DEFAULT mkdir -p $RUN_D - for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; do + for m in arc4 sha1_generic slhc crc-ccitt ppp_generic ppp_async ppp_mppe; do insmod $m >/dev/null 2>&1 done - $BIN $OPTIONS + ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets + service_start $BIN $OPTIONS -c $CONFIG +} + +start() { + config_load pptpd + setup_config pptpd || return + config_foreach setup_login login + start_pptpd } stop() { - [ -f $PID_F ] && kill $(cat $PID_F) + service_stop $BIN } -- 1.8.1.2 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel