#!/bin/sh /etc/rc.common

START=50
CHAP_SECRET=/etc/ppp/chap-secrets
PAP_SECRET=/etc/ppp/pap-secrets

secret_add() {
	config_get user_name $1 user_name
	config_get provider $1 provider
	config_get pass_word $1 pass_word
	config_get ip_address $1 ip_address
	
	if   [ "$user_name" = "" ]; then
		echo "User name of VPN server is null!!"
		return 0;
	fi

	if   [ "$pass_word" = "" ]; then
		echo "Pass word of VPN server is null!!"
		return 0;
	fi	
	
	if   [ "$provider" = "" ]; then
		provider_com="*"
	else
		provider_com="$provider"
	fi
	
	if   [ "$ip_address" = "" ]; then
		ip_com="*"
	else
		ip_com="$ip_address"
	fi
	
	echo "$user_name $provider_com $pass_word $ip_com" >> $CHAP_SECRET
	echo "$user_name $provider_com $pass_word $ip_com" >> $PAP_SECRET
	
}
