# Contributed by: Thomas Bächler _quotestring() { echo "\"${1/\"/\\\"}\"" } pppoe_up() { local cfg mkdir -p "$STATE_DIR/pppoe.${Interface}.$1/" chmod 700 "$STATE_DIR/pppoe.${Interface}.${Profile}/" cfg="$STATE_DIR/pppoe.${Interface}.${Profile}/options" : > "${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 "linkname $(_quotestring "${Profile}")" >> "${cfg}" echo "maxfail 5" >> "${cfg}" echo "updetach" >> "${cfg}" if [[ ${ConnectionMode} == demand ]]; then echo "demand" >> "${cfg}" echo "idle ${IdleTimeout}" >> "${cfg}" else echo "persist" >> "${cfg}" fi echo "user $(_quotestring "${User}")" >> "${cfg}" echo "password $(_quotestring "${Password}")" >> "${cfg}" [[ -n ${LCPEchoInterval} ]] && echo "lcp-echo-interval ${LCPEchoInterval}" >> "${cfg}" [[ -n ${LCPEchoFailure} ]] && echo "lcp-echo-failure ${LCPEchoFailure}" >> "${cfg}" [[ -n ${PPPoEService} ]] && echo "rp_pppoe_service $(_quotestring "${PPPoEService}")" >> "${cfg}" [[ -n ${PPPoEAC} ]] && echo "rp_pppoe_ac $(_quotestring "${PPPoEAC}")" >> "${cfg}" [[ -n ${PPPoESession} ]] && echo "rp_pppoe_sess $(_quotestring "${PPPoESession}")" >> "${cfg}" [[ -n ${PPPoEMAC} ]] && echo "pppoe-mac $(_quotestring "${PPPoEMAC}")" >> "${cfg}" [[ ${PPPoEIP6} == yes ]] && echo "+ipv6" >> "${cfg}" /sbin/ip link set dev "${Interface}" up /usr/sbin/pppd file "${cfg}" if [[ $? -ne 0 ]]; then rm "${cfg}" rmdir "$STATE_DIR/pppoe.${Interface}.${Profile}/" report_error "Couldn't make pppd connection." return 1 fi } pppoe_down() { local cfg 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}/" } # vim: ft=sh ts=4 et sw=4: