# Contributed by: Thomas Bächler : ${PPPD:=pppd} quote_word() { set -- "${@//\\/\\\\}" printf '"%s"\n' "${@//\"/\\\"}" } pppoe_up() { local cfg if ! is_interface "$Interface"; then report_error "Interface '$Interface' does not exist" return 1 fi if ! bring_interface_up "$Interface"; then report_error "Failed to bring interface '$Interface' up" return 1 fi mkdir -p "$STATE_DIR/pppoe.${Interface}.${Profile}/" chmod 700 "$STATE_DIR/pppoe.${Interface}.${Profile}/" cfg="$STATE_DIR/pppoe.${Interface}.${Profile}/options" echo "linkname $(quote_word "${Profile}")" > "${cfg}" chmod 600 "${cfg}" echo "plugin rp-pppoe.so" >> "${cfg}" echo "nic-${Interface}" >> "${cfg}" echo "noauth" >> "${cfg}" if is_yes "${DefaultRoute:-yes}"; then echo "defaultroute" >> "${cfg}" else echo "nodefaultroute" >> "${cfg}" fi if is_yes "${UsePeerDNS:-yes}"; then echo "usepeerdns" >> "${cfg}" fi echo "maxfail ${MaxFail:-5}" >> "${cfg}" echo "updetach" >> "${cfg}" if [[ ${ConnectionMode} == demand ]]; then echo "demand" >> "${cfg}" echo "idle ${IdleTimeout}" >> "${cfg}" else echo "persist" >> "${cfg}" fi echo "user $(quote_word "${User}")" >> "${cfg}" echo "password $(quote_word "${Password}")" >> "${cfg}" [[ -n ${LCPEchoInterval} ]] && echo "lcp-echo-interval ${LCPEchoInterval}" >> "${cfg}" [[ -n ${LCPEchoFailure} ]] && echo "lcp-echo-failure ${LCPEchoFailure}" >> "${cfg}" [[ -n ${PPPoEService} ]] && echo "rp_pppoe_service $(quote_word "${PPPoEService}")" >> "${cfg}" [[ -n ${PPPoEAC} ]] && echo "rp_pppoe_ac $(quote_word "${PPPoEAC}")" >> "${cfg}" [[ -n ${PPPoESession} ]] && echo "rp_pppoe_sess $(quote_word "${PPPoESession}")" >> "${cfg}" [[ -n ${PPPoEMAC} ]] && echo "pppoe-mac $(quote_word "${PPPoEMAC}")" >> "${cfg}" [[ ${PPPoEIP6} == yes ]] && echo "+ipv6" >> "${cfg}" if ! $PPPD file "${cfg}"; then rm "${cfg}" rmdir "$STATE_DIR/pppoe.${Interface}.${Profile}/" report_error "Couldn't make pppd connection." return 1 fi } pppoe_down() { local cfg pidfile pid cfg="$STATE_DIR/pppoe.${Interface}.${Profile}/options" pidfile="/var/run/ppp-${Profile}.pid" if [[ -e $pidfile ]]; then read pid < "$pidfile" [[ "$pid" ]] && kill "$pid" fi rm "${cfg}" rmdir "$STATE_DIR/pppoe.${Interface}.${Profile}/" bring_interface_down "$Interface" } # vim: ft=sh ts=4 et sw=4: