Hi,

On 10 October 2013 20:16, Bruno Randolf <b...@einfach.org> wrote:
> Signed-off-by: Bruno Randolf <b...@einfach.org>
> ---
>  net/pptpd/Makefile            |  3 +++
>  net/pptpd/files/pptpd.init    | 41 +++++++++++++++++++++++++++++++++++++++--
>  net/pptpd/files/pptpd.uciconf |  8 ++++++++
>  3 files changed, 50 insertions(+), 2 deletions(-)
>  create mode 100644 net/pptpd/files/pptpd.uciconf
>
> diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
> index e79e0a7..0a2f642 100644
> --- a/net/pptpd/Makefile
> +++ b/net/pptpd/Makefile
> @@ -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.uciconf $(1)/etc/config/pptpd
>  endef
>
>  $(eval $(call BuildPackage,pptpd))
> diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
> index a74973c..849b34e 100644
> --- a/net/pptpd/files/pptpd.init
> +++ b/net/pptpd/files/pptpd.init
> @@ -6,14 +6,51 @@ BIN=pptpd
>  DEFAULT=/etc/default/$BIN
>  RUN_D=/var/run
>  PID_F=$RUN_D/$BIN.pid
> +CONFIG=/tmp/pptpd.conf
> +CHAP_SECRETS=/etc/ppp/chap-secrets
>
> -start() {
> +setup_user() {
> +       local section="$1"
> +
> +       config_get user "$section" user
> +       config_get passwd "$section" passwd
> +       [ -n "$user" ] || return 0
> +       [ -n "$passwd" ] || return 0
> +
> +       echo "$user pptp-server $passwd *" >> $CHAP_SECRETS
> +}
> +
> +setup_config() {
> +       local section="$1"
> +
> +       config_get enabled "$section" enabled
> +       [ "$enabled" -eq 0 ] && return 1
> +
> +       config_get localip "$section" localip
> +       config_get remoteip "$section" remoteip
> +       [ -n "$localip" ] || return 0
> +       [ -n "$remoteip" ] || return 0
> +
> +       cp /etc/pptpd.conf $CONFIG
> +       echo "localip  $localip" >> $CONFIG
> +       echo "remoteip  $remoteip" >> $CONFIG
> +}
> +
> +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
>                 insmod $m >/dev/null 2>&1
>         done
> -       $BIN $OPTIONS
> +       $BIN $OPTIONS -c $CONFIG
> +}
> +
> +start() {
> +       [ -e "$CHAP_SECRETS" ] && rm -f $CHAP_SECRETS
> +       config_load pptpd
> +       config_foreach setup_user key
> +       setup_config pptpd
> +       start_pptpd

To make `enabled 0` a working option, it should be something like

                setup_config pptpd && start_pptpd


>  }
>
>  stop() {
> diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
> new file mode 100644
> index 0000000..66cf0be
> --- /dev/null
> +++ b/net/pptpd/files/pptpd.uciconf
> @@ -0,0 +1,8 @@
> +config service 'pptpd'
> +       option 'enabled' '0'
> +       option 'localip' '192.168.0.1'
> +       option 'remoteip' '192.168.0.20-30'
> +
> +config 'key'
> +       option 'user' 'youruser'
> +       option 'passwd' 'yourpass'
> --
> 1.8.1.2
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

On 10 October 2013 20:16, Bruno Randolf <b...@einfach.org> wrote:
> Signed-off-by: Bruno Randolf <b...@einfach.org>
> ---
>  net/pptpd/Makefile            |  3 +++
>  net/pptpd/files/pptpd.init    | 41 +++++++++++++++++++++++++++++++++++++++--
>  net/pptpd/files/pptpd.uciconf |  8 ++++++++
>  3 files changed, 50 insertions(+), 2 deletions(-)
>  create mode 100644 net/pptpd/files/pptpd.uciconf
>
> diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
> index e79e0a7..0a2f642 100644
> --- a/net/pptpd/Makefile
> +++ b/net/pptpd/Makefile
> @@ -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.uciconf $(1)/etc/config/pptpd
>  endef
>
>  $(eval $(call BuildPackage,pptpd))
> diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
> index a74973c..849b34e 100644
> --- a/net/pptpd/files/pptpd.init
> +++ b/net/pptpd/files/pptpd.init
> @@ -6,14 +6,51 @@ BIN=pptpd
>  DEFAULT=/etc/default/$BIN
>  RUN_D=/var/run
>  PID_F=$RUN_D/$BIN.pid
> +CONFIG=/tmp/pptpd.conf
> +CHAP_SECRETS=/etc/ppp/chap-secrets
>
> -start() {
> +setup_user() {
> +       local section="$1"
> +
> +       config_get user "$section" user
> +       config_get passwd "$section" passwd
> +       [ -n "$user" ] || return 0
> +       [ -n "$passwd" ] || return 0
> +
> +       echo "$user pptp-server $passwd *" >> $CHAP_SECRETS
> +}
> +
> +setup_config() {
> +       local section="$1"
> +
> +       config_get enabled "$section" enabled
> +       [ "$enabled" -eq 0 ] && return 1
> +
> +       config_get localip "$section" localip
> +       config_get remoteip "$section" remoteip
> +       [ -n "$localip" ] || return 0
> +       [ -n "$remoteip" ] || return 0
> +
> +       cp /etc/pptpd.conf $CONFIG
> +       echo "localip  $localip" >> $CONFIG
> +       echo "remoteip  $remoteip" >> $CONFIG
> +}
> +
> +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
>                 insmod $m >/dev/null 2>&1
>         done
> -       $BIN $OPTIONS
> +       $BIN $OPTIONS -c $CONFIG
> +}
> +
> +start() {
> +       [ -e "$CHAP_SECRETS" ] && rm -f $CHAP_SECRETS
> +       config_load pptpd
> +       config_foreach setup_user key
> +       setup_config pptpd
> +       start_pptpd
>  }
>
>  stop() {
> diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
> new file mode 100644
> index 0000000..66cf0be
> --- /dev/null
> +++ b/net/pptpd/files/pptpd.uciconf
> @@ -0,0 +1,8 @@
> +config service 'pptpd'
> +       option 'enabled' '0'
> +       option 'localip' '192.168.0.1'
> +       option 'remoteip' '192.168.0.20-30'
> +
> +config 'key'
> +       option 'user' 'youruser'
> +       option 'passwd' 'yourpass'
> --
> 1.8.1.2
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to