<commit_before># Copyright 2005-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

pppd_depend() {
	program /usr/sbin/pppd
	after interface
	before dhcp
	provide ppp
}

is_ppp() {
	[ -e /var/run/ppp-"${IFACE}".pid ]
}

requote() {
	printf "'%s' " "$@"
}

pppd_pre_start() {
	# Interface has to be called ppp
	[ "${IFACE%%[0-9]*}" = "ppp" ] || return 0

	if ${IN_BACKGROUND} ; then
		local config=
		eval config=\$config_${IFVAR}
		# If no config for ppp then don't default to DHCP 
		if [ -z "${config}" ] ; then
			eval config_${IFVAR}=\"null\"
		fi
		return 0
	fi

	local link= i= opts= unit="${IFACE#ppp}" mtu=
	
	# PPP requires a link to communicate over - normally a serial port
	# PPPoE communicates over Ethernet
	# PPPoA communicates over ATM
	# In all cases, the link needs to be available before we start PPP
	eval link=\$link_${IFVAR}
	[ -n "${link}" ] || return 0

	case "${link}" in
		/*)
			if [ ! -e "${link}" ] ; then
				eerror "${link} does not exist"
				eerror "Please verify hardware or kernel module (driver)"
				return 1
			fi
			;;
	esac

	if [ -z "${unit}" ] ; then
		eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp"
		return 1
	fi

	eval $(_get_array "pppd_${IFVAR}")
	opts="$@"

	local mtu= hasmtu=false hasmru=false hasmaxfail=false haspersits=false
	local hasupdetach=false
	for i in "$@" ; do
		set -- ${i}
		case "$1" in
			unit|nodetach|linkname)
				eerror "The option \"$1\" is not allowed in pppd_${IFVAR}"
				return 1
			;;
			mtu) hasmtu=true ;;
			mru) hasmru=true ;;
			maxfail) hasmaxfail=true ;;
			persist) haspersist=true ;;
			updetach) hasupdetach=true;
		esac
	done

	# Might be set in conf.d/net
	local username= password= passwordset=
	eval username=\$username_${IFVAR}
	eval password=\$password_${IFVAR}
	eval passwordset=\${password_${IFVAR}-x}
	if [ -n "${username}" ] \
	&& [ -n "${password}" -o -z "${passwordset}" ] ; then
		opts="${opts} plugin passwordfd.so passwordfd 0"
	fi
	
	if [ -n "${mtu}" ] ; then
		${hasmtu} || opts="${opts} mtu ${mtu}"
		${hasmru} || opts="${opts} mru ${mtu}"
	fi
	${hasmailfail} || opts="${opts} maxfail 0"
	${haspersist} || opts="${opts} persist"

	# Set linkname because we need /var/run/ppp-${linkname}.pid
	# This pidfile has the advantage of being there,
	# even if ${IFACE} interface was never started
	opts="linkname ${IFACE} ${opts}"

	# Setup auth info
	if [ -n "${username}" ] ; then
		opts="user '${username}' remotename ${IFACE} ${opts}"
	fi

	# Load a custom interface configuration file if it exists
	[ -f "/etc/ppp/options.${IFACE}" ] \
		&& opts="${opts} file /etc/ppp/options.${IFACE}"

	# Set unit
	opts="unit ${unit} ${opts}"
	
	# Setup connect script
	local chatopts="/usr/sbin/chat -e -E -v"
	eval $(_get_array "phone_number_${IFVAR}")
	[ -n "$1" ] && chatopts="${chatopts} -T '$1'"
	[ -n "$2" ] && chatopts="${chatopts} -U '$2'"
	eval $(_get_array "chat_${IFVAR}")
	if [ $# != 0 ] ; then
		opts="${opts} connect $(printf "'%s' " "${chatopts} $(printf "'%s' " "$@")")"
	fi

	# Add plugins
	local haspppoa=false haspppoe=false
	eval $(_get_array "plugins_${IFVAR}")
	for i in "$@" ; do
		set -- ${i}
		case "$1" in
			passwordfd) continue;;
			pppoa) shift; set -- "pppoatm" "$@" ;;
			pppoe) shift; set -- "rp-pppoe" "$@" ;;
			capi) shift; set -- "capiplugin" "$@" ;;
		esac
		case "$1" in
			rp-pppoe) haspppoe=true ;;
			pppoatm)  haspppoa=true ;;
		esac
		if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ] ; then
			opts="${opts} connect true"
			set -- "$@" "${link}"
		fi
		opts="${opts} plugin $1.so"
		shift
		opts="${opts} $@"
	done

	#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
	local insert_link_in_opts=1
	if ${haspppoe} ; then
		if [ ! -e /proc/net/pppoe ] ; then
			# Load the PPPoE kernel module<commit_msg>Fix chat connects for pppd<commit_after># Copyright 2005-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

pppd_depend() {
	program /usr/sbin/pppd
	after interface
	before dhcp
	provide ppp
}

is_ppp() {
	[ -e /var/run/ppp-"${IFACE}".pid ]
}

requote() {
	printf "'%s' " "$@"
}

pppd_pre_start() {
	# Interface has to be called ppp
	[ "${IFACE%%[0-9]*}" = "ppp" ] || return 0

	if ${IN_BACKGROUND} ; then
		local config=
		eval config=\$config_${IFVAR}
		# If no config for ppp then don't default to DHCP 
		if [ -z "${config}" ] ; then
			eval config_${IFVAR}=\"null\"
		fi
		return 0
	fi

	local link= i= opts= unit="${IFACE#ppp}" mtu=
	
	# PPP requires a link to communicate over - normally a serial port
	# PPPoE communicates over Ethernet
	# PPPoA communicates over ATM
	# In all cases, the link needs to be available before we start PPP
	eval link=\$link_${IFVAR}
	[ -n "${link}" ] || return 0

	case "${link}" in
		/*)
			if [ ! -e "${link}" ] ; then
				eerror "${link} does not exist"
				eerror "Please verify hardware or kernel module (driver)"
				return 1
			fi
			;;
	esac

	if [ -z "${unit}" ] ; then
		eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp"
		return 1
	fi

	eval $(_get_array "pppd_${IFVAR}")
	opts="$@"

	local mtu= hasmtu=false hasmru=false hasmaxfail=false haspersits=false
	local hasupdetach=false
	for i in "$@" ; do
		set -- ${i}
		case "$1" in
			unit|nodetach|linkname)
				eerror "The option \"$1\" is not allowed in pppd_${IFVAR}"
				return 1
			;;
			mtu) hasmtu=true ;;
			mru) hasmru=true ;;
			maxfail) hasmaxfail=true ;;
			persist) haspersist=true ;;
			updetach) hasupdetach=true;
		esac
	done

	# Might be set in conf.d/net
	local username= password= passwordset=
	eval username=\$username_${IFVAR}
	eval password=\$password_${IFVAR}
	eval passwordset=\${password_${IFVAR}-x}
	if [ -n "${username}" ] \
	&& [ -n "${password}" -o -z "${passwordset}" ] ; then
		opts="${opts} plugin passwordfd.so passwordfd 0"
	fi
	
	if [ -n "${mtu}" ] ; then
		${hasmtu} || opts="${opts} mtu ${mtu}"
		${hasmru} || opts="${opts} mru ${mtu}"
	fi
	${hasmailfail} || opts="${opts} maxfail 0"
	${haspersist} || opts="${opts} persist"

	# Set linkname because we need /var/run/ppp-${linkname}.pid
	# This pidfile has the advantage of being there,
	# even if ${IFACE} interface was never started
	opts="linkname ${IFACE} ${opts}"

	# Setup auth info
	if [ -n "${username}" ] ; then
		opts="user '${username}' remotename ${IFACE} ${opts}"
	fi

	# Load a custom interface configuration file if it exists
	[ -f "/etc/ppp/options.${IFACE}" ] \
		&& opts="${opts} file /etc/ppp/options.${IFACE}"

	# Set unit
	opts="unit ${unit} ${opts}"
	
	# Setup connect script
	local chatopts="/usr/sbin/chat -e -E -v"
	eval $(_get_array "phone_number_${IFVAR}")
	[ -n "$1" ] && chatopts="${chatopts} -T '$1'"
	[ -n "$2" ] && chatopts="${chatopts} -U '$2'"
	eval $(_get_array "chat_${IFVAR}")
	if [ $# != 0 ] ; then
		opts="${opts} connect $(printf "\\'%s\\'" "${chatopts} $(printf "\\'\\\\'\\'%s\\'\\\'' " "$@")")"
	fi

	# Add plugins
	local haspppoa=false haspppoe=false
	eval $(_get_array "plugins_${IFVAR}")
	for i in "$@" ; do
		set -- ${i}
		case "$1" in
			passwordfd) continue;;
			pppoa) shift; set -- "pppoatm" "$@" ;;
			pppoe) shift; set -- "rp-pppoe" "$@" ;;
			capi) shift; set -- "capiplugin" "$@" ;;
		esac
		case "$1" in
			rp-pppoe) haspppoe=true ;;
			pppoatm)  haspppoa=true ;;
		esac
		if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ] ; then
			opts="${opts} connect true"
			set -- "$@" "${link}"
		fi
		opts="${opts} plugin $1.so"
		shift
		opts="${opts} $@"
	done

	#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
	local insert_link_in_opts=1
	if ${haspppoe} ; then
		if [ ! -e /proc/net/pppoe ] ; then
			# Load the PPPoE kernel module
{'fraction_non_alphanumeric': 0.18539543284737453, 'fraction_numerical': 0.008773061540446395, 'mean_word_length': 3.417094017094017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5279125', 'n_tokens_mistral': 3241, 'n_tokens_neox': 2952, 'n_words': 853}