From d52af28865a7e86580cbd9b11dc25a6539806dd54caba578889d38c12a5d143a Mon Sep 17 00:00:00 2001 From: Andrey Karepin Date: Sun, 26 Oct 2014 12:07:03 +0000 Subject: [PATCH] Accepting request 258364 from home:posophe:branches:network systemd + usrmove fixes OBS-URL: https://build.opensuse.org/request/show/258364 OBS-URL: https://build.opensuse.org/package/show/network/rp-pppoe?expand=0&rev=9 --- pppoe-connect | 398 ++++++++++++++++++++++++++++++++++ pppoe-server.service | 9 + pppoe-setup | 492 +++++++++++++++++++++++++++++++++++++++++++ pppoe-start | 228 ++++++++++++++++++++ pppoe-status | 105 +++++++++ pppoe-stop | 143 +++++++++++++ rp-pppoe.changes | 9 + rp-pppoe.spec | 103 +++++---- 8 files changed, 1444 insertions(+), 43 deletions(-) create mode 100644 pppoe-connect create mode 100644 pppoe-server.service create mode 100644 pppoe-setup create mode 100644 pppoe-start create mode 100644 pppoe-status create mode 100644 pppoe-stop diff --git a/pppoe-connect b/pppoe-connect new file mode 100644 index 0000000..6a311f6 --- /dev/null +++ b/pppoe-connect @@ -0,0 +1,398 @@ +#! /bin/bash +# Generated automatically from pppoe-connect.in by configure. +#*********************************************************************** +# +# pppoe-connect +# +# Shell script to connect to an PPPoE provider using PPPoE +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: pppoe-connect [config_file] +# pppoe-connect interface user [config_file] +# Second form overrides USER and ETH from config file. +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +# From AUTOCONF +prefix=/usr +exec_prefix=/usr +localstatedir=/var + +# Paths to programs +IP=/usr/sbin/ip +PPPD=/usr/sbin/pppd +SETSID=/usr/bin/setsid +PPPOE=/usr/sbin/pppoe +BR2684CTL=/usr/sbin/br2684ctl +LOGGER="/usr/bin/logger -t `basename $0`" +NETWORKDIR=/etc/sysconfig/network-scripts +LS=/usr/bin/ls + +get_device() { + if [ ! -d $NETWORKDIR ] ; then + $ECHO "** $NETWORKDIR not found" + $ECHO "** Quitting" + exit 1 + fi + + cd $NETWORKDIR + interfaces=$($LS ifcfg-ppp* 2>/dev/null | egrep -v '(~|\.bak)$' | \ + egrep -v '(rpmsave|rpmorig|rpmnew)' | sed 's/^ifcfg-//g') + + for i in $interfaces ; do + test -f ifcfg-$i && . ifcfg-$i 2>/dev/null + if [ "$TYPE" = "xDSL" ] ; then + CONFIG=$NETWORKDIR/ifcfg-$i + break + fi + done +} + +# Set to "C" locale so we can parse messages from commands +LANG=C +export LANG + +# Must be root +if test "`/usr/bin/id -u`" != 0 ; then + echo "$0: You must be root to run this script" >& 2 + exit 1 +fi + +if test "$SETSID" != "" -a ! -x "$SETSID"; then + SETSID="" +fi + +USER="" +ETH="" + +# Sort out command-line arguments +case "$#" in + 1) + CONFIG="$1" + ;; + 3) + CONFIG="$3" + ;; +esac + +if [ -z "$CONFIG" ] ; then + get_device + [ -z "$CONFIG" ] && CONFIG=/etc/ppp/pppoe.conf +fi + +if test ! -f "$CONFIG" -o ! -r "$CONFIG" ; then + echo "$0: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +export CONFIG +. $CONFIG + +DEVNAME="$DEVICE" +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" + +if [ "$CONFIG" != "/etc/ppp/pppoe.conf" ] ; then + DEVNAME=`basename $CONFIG | sed 's/^ifcfg-//g'` +fi + +if [ -n "$BR2684DEV" ]; then + [ -z "$ETH" ] && ETH="nas$BR2684DEV" + modprobe br2684 > /dev/null 2>&1 +fi + +# Check for command-line overriding of ETH and USER +case "$#" in + 2|3) + ETH="$1" + USER="$2" + ;; +esac + +# Check that config file is sane +if test "$USER" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for USER" >& 2 + exit 1 +fi +if test "`basename \"$LINUX_PLUGIN\"`" = "pppoatm.so" ; then + if test "$VCI" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for VCI" >& 2 + exit 1 + fi + if test "$VPI" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for VPI" >& 2 + exit 1 + fi +else + if test "$ETH" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for ETH" >& 2 + exit 1 + fi +fi + +PPPD_PID=0 + +# Catch common error +if test "$DEBUG" = "1" ; then + echo "*** If you want to use DEBUG, invoke pppoe-start, not pppoe-connect." + exit 1 +fi + +if test "$DEBUG" != "" ; then + if test "$LINUX_PLUGIN" != "" ; then + echo "Cannot use DEBUG mode and LINUX_PLUGIN at the same time." + echo "Kernel-mode PPPoE is experimental and unsupported." + exit 1 + fi + echo "* The following section identifies your Ethernet interface" >> $DEBUG + echo "* and user name. Some ISP's need 'username'; others" >> $DEBUG + echo "* need 'username@isp.com'. Try both" >> $DEBUG + echo "ETH=$ETH; USER=$USER" >> $DEBUG + echo "---------------------------------------------" >> $DEBUG +fi + +# MTU of Ethernet card attached to modem MUST be 1500. This apparently +# fails on some *BSD's, so we'll only do it under Linux + +if test `uname -s` = Linux ; then + $IP link set $ETH up mtu 1500 + # For 2.4 kernels. Will fail on 2.2.x, but who cares? + modprobe ppp_generic > /dev/null 2>&1 + modprobe ppp_async > /dev/null 2>&1 + modprobe ppp_synctty > /dev/null 2>&1 + if test -n "$LINUX_PLUGIN" ; then + modprobe pppox > /dev/null 2>&1 + modprobe pppoe > /dev/null 2>&1 + fi +fi + +if test "$SYNCHRONOUS" = "yes" ; then + PPPOE_SYNC=-s + PPPD_SYNC=sync + # Increase the chances of it working on Linux... + if test `uname -s` = Linux ; then + modprobe n_hdlc > /dev/null 2>&1 + fi +else + PPPOE_SYNC="" + PPPD_SYNC="" +fi + +if test -n "$ACNAME" ; then + ACNAME="-C $ACNAME" +fi + +if test -n "$SERVICENAME" ; then + SERVICENAMEOPT="-S $SERVICENAME" +else + SERVICENAMEOPT="" +fi + +if test "$CLAMPMSS" = "no" ; then + CLAMPMSS="" +else + CLAMPMSS="-m $CLAMPMSS" +fi + +# If DNSTYPE is SERVER, we must use "usepeerdns" option to pppd. +if test "$DNSTYPE" = "SERVER" ; then + PEERDNS=yes + USEPEERDNS=yes +fi + +if test "$PEERDNS" = "yes" ; then + PEERDNS="usepeerdns" +else + PEERDNS="" +fi + +# Backward config file compatibility -- PEERDNS used to be USEPEERDNS +if test "$USEPEERDNS" = "yes" ; then + PEERDNS="usepeerdns" +fi +if test "$USEPEERDNS" = "no" ; then + PEERDNS="" +fi + +if [ -z "$DEVICE" ] ; then + IPPARAM="" + LINKNAME="" +else + IPPARAM="ipparam ${DEVNAME}" + LINKNAME="linkname ${DEVICE}" +fi + +[ -z "$MTU" ] && MTU="1492" +[ -z "$MRU" ] && MRU="1492" + +# Backward config file compatibility +if test "$DEMAND" = "" ; then + DEMAND=no +fi + +if test "$DEMAND" = "no" ; then + DEMAND="" +else + [ -z "$IPADDR" ] && IPADDR=10.112.112.112 + [ -z "$REMIP" ] && REMIP=10.112.112.113 + + DEMAND="demand persist idle $CONNECT_TIMEOUT $IPADDR:$REMIP ipcp-accept-remote ipcp-accept-local noipdefault ktune" + # The plugin doesn't need (and may not _accept_) the 'connect' option + if [ -z "$LINUX_PLUGIN" ]; then + DEMAND="$DEMAND connect true" + fi +fi + +case "$FIREWALL" in + STANDALONE) + . /etc/ppp/firewall-standalone + ;; + MASQUERADE) + . /etc/ppp/firewall-masq + ;; +esac + +# If we're using kernel-mode PPPoE on Linux... +if test "`basename \"$LINUX_PLUGIN\"`" = "rp-pppoe.so" ; then + PLUGIN_OPTS="plugin $LINUX_PLUGIN nic-$ETH" + if test -n "$SERVICENAME" ; then + PLUGIN_OPTS="$PLUGIN_OPTS rp_pppoe_service $SERVICENAME" + fi + modprobe pppoe > /dev/null 2>&1 +fi +# If we're using kernel-mode PPPoATM on Linux... +if test "`basename \"$LINUX_PLUGIN\"`" = "pppoatm.so" ; then + PLUGIN_OPTS="plugin $LINUX_PLUGIN" + + # Interface name MUST BE LAST!! + PLUGIN_OPTS="$PLUGIN_OPTS $VPI.$VCI" + modprobe pppoatm > /dev/null 2>&1 +fi +if test "$DEFROUTE" != "no" ; then + DEFAULTROUTE="defaultroute" + # pppd will no longer delete an existing default route + # so we have to help it out a little here. + DEFRT=$(ip route list match 0/0) + [ -n "${DEFRT}" ] && echo "$DEFRT" > /etc/default-routes + echo "$DEFRT" | while read spec; do + $IP route del $spec; + done +else + DEFAULTROUTE="" +fi + +# Standard PPP options we always use +PPP_STD_OPTIONS="$IPPARAM $LINKNAME $PLUGIN_OPTS noipdefault noauth default-asyncmap $DEFAULTROUTE hide-password nodetach $PEERDNS mtu $MTU mru $MRU noaccomp nodeflate nopcomp novj novjccomp user $USER lcp-echo-interval $LCP_INTERVAL lcp-echo-failure $LCP_FAILURE $PPPD_EXTRA" + +# PPPoE invocation +PPPOE_CMD="$PPPOE -p $PPPOE_PIDFILE -I $ETH -T $PPPOE_TIMEOUT -U $PPPOE_SYNC $CLAMPMSS $ACNAME $SERVICENAMEOPT $PPPOE_EXTRA" +if test "$DEBUG" != "" ; then + if test "$DEMAND" != "" ; then + echo "(Turning off DEMAND for debugging purposes)" + DEMAND="" + fi + echo "* The following section shows the pppd command we will invoke" >> $DEBUG + echo "pppd invocation" >> $DEBUG + echo "$SETSID $PPPD pty '$PPPOE_CMD' $PPP_STD_OPTIONS $PPPD_SYNC debug" >> $DEBUG + echo "---------------------------------------------" >> $DEBUG + $SETSID $PPPD pty "$PPPOE_CMD -D $DEBUG-0" \ + $PPP_STD_OPTIONS \ + $PPPD_SYNC \ + debug >> $DEBUG 2>&1 + echo "---------------------------------------------" >> $DEBUG + echo "* The following section is an extract from your log." >> $DEBUG + echo "* Look for error messages from pppd, such as" >> $DEBUG + echo "* a lack of kernel support for PPP, authentication failure" >> $DEBUG + echo "* etc." >> $DEBUG + if test -f "/var/log/messages" ; then + echo "Extract from /var/log/messages" >> $DEBUG + grep 'ppp' /var/log/messages | tail -150 >> $DEBUG + elif test -f "/var/adm/messages"; then + echo "Extract from /var/adm/messages" >> $DEBUG + grep 'ppp' /var/adm/messages | tail -150 >> $DEBUG + else + echo "Can't find messages file (looked for /var/{log,adm}/messages" >> $DEBUG + fi + date >> $DEBUG + echo "---------------------------------------------" >> $DEBUG + echo "* The following section is a dump of the packets" >> $DEBUG + echo "* sent and received by rp-pppoe. If you don't see" >> $DEBUG + echo "* any output, it's an Ethernet driver problem. If you only" >> $DEBUG + echo "* see three PADI packets and nothing else, check your cables" >> $DEBUG + echo "* and modem. Make sure the modem lights flash when you try" >> $DEBUG + echo "* to connect. Check that your Ethernet card is in" >> $DEBUG + echo "* half-duplex, 10Mb/s mode. If all else fails," >> $DEBUG + echo "* try using pppoe-sniff." >> $DEBUG + echo "rp-pppoe debugging dump" >> $DEBUG + cat $DEBUG-0 >> $DEBUG + rm -f $DEBUG-0 + for i in 1 2 3 4 5 6 7 8 9 10 ; do + echo "" + echo "" + echo "" + done + echo "*** Finished debugging run. Please review the file" + echo "*** '$DEBUG' and try to" + echo "*** figure out what is going on." + echo "***" + echo "*** Unfortunately, we can NO LONGER accept debugging" + echo "*** output for analysis. Please do not send this to" + echo "*** Roaring Penguin; it is too time-consuming for" + echo "*** us to deal with all the analyses we have been sent." + exit 0 +fi + +echo $$ > $PIDFILE + +while [ true ] ; do + if [ "${DEFROUTE}" != "no" ] ; then + DEFRT=$(ip route list match 0/0) + [ -n "${DEFRT}" ] && echo "$DEFRT" > /etc/default-routes + echo "$DEFRT" | while read spec; do + $IP route del $spec; + done + fi + + if test "$BR2684DEV" != ""; then + $BR2684CTL -b -c $BR2684DEV -a $VPI.$VCI + $IP link set $ETH up + fi + if test "$OVERRIDE_PPPD_COMMAND" != "" ; then + $SETSID $OVERRIDE_PPPD_COMMAND & + echo "$!" > $PPPD_PIDFILE + elif test "$LINUX_PLUGIN" != "" ; then + $SETSID $PPPD $PPP_STD_OPTIONS $DEMAND & + echo "$!" > $PPPD_PIDFILE + else + $SETSID $PPPD pty "$PPPOE_CMD" \ + $PPP_STD_OPTIONS \ + $DEMAND \ + $PPPD_SYNC & + echo "$!" > $PPPD_PIDFILE + fi + wait + if test "$BR2684DEV" != ""; then + kill `cat /var/run/nas$BR2684DEV.pid` + rm /var/run/nas$BR2684DEV.pid + fi + + if test "$RETRY_ON_FAILURE" = "no" ; then + exit + fi + + # Run /etc/ppp/adsl-lost if it exists + test -x /etc/ppp/adsl-lost && /etc/ppp/adsl-lost + + # Re-establish the connection + $LOGGER -p daemon.notice "PPPoE connection lost; attempting re-connection." + + # Wait a bit in case a problem causes tons of log messages :-) + sleep 5 +done diff --git a/pppoe-server.service b/pppoe-server.service new file mode 100644 index 0000000..cde645b --- /dev/null +++ b/pppoe-server.service @@ -0,0 +1,9 @@ +[Unit] +Description=PPPoE Server. +After=syslog.target + +[Service] +ExecStart=/sbin/pppoe-server + +[Install] +WantedBy=multi-user.target diff --git a/pppoe-setup b/pppoe-setup new file mode 100644 index 0000000..e11ec9a --- /dev/null +++ b/pppoe-setup @@ -0,0 +1,492 @@ +#! /bin/bash +#*********************************************************************** +# +# pppoe-setup +# +# All-purpose slicing/dicing shell script to configure rp-pppoe. +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +#*********************************************************************** + +# Paths to programs and config files +IP=/usr/sbin/ip +PPPD=/usr/sbin/pppd +PPPOE=/sbin/pppoe +ECHO=/usr/bin/echo +LS=/usr/bin/ls +ID=/usr/bin/id +NETWORKDIR=/etc/sysconfig/network-scripts +PAPFILE=/etc/ppp/chap-secrets +CHAPFILE=/etc/ppp/pap-secrets +RESOLVFILE=/etc/resolv.conf + +# Set to "C" locale so we can parse messages from commands +LANG=C +export LANG + +# Protect created files +umask 077 + +copy() { + cp $1 $2 + if [ "$?" != 0 ] ; then + $ECHO "*** Error copying $1 to $2" + $ECHO "*** Quitting." + exit 1 + fi +} + +get_device() { + if [ ! -d $NETWORKDIR ] ; then + $ECHO "** $NETWORKDIR not found" + $ECHO "** Quitting" + exit 1 + fi + + cd $NETWORKDIR + interfaces=$($LS ifcfg-ppp* 2>/dev/null | egrep -v '(~|\.bak)$' | \ + egrep -v '(rpmsave|rpmorig|rpmnew)' | sed 's/^ifcfg-//g') + + for i in $interfaces ; do + test -f ifcfg-$i && . ifcfg-$i 2>/dev/null + if [ "$TYPE" = "xDSL" ] ; then + device_count=$[$device_count+1] + devices="$devices $DEVICE" + fi + done +} + +clear_env() { + unset USERCTL BOOTPROTO NAME DEVICE TYPE ONBOOT FIREWALL PING \ + PPPOE_TIMEOUT LCP_FAILURE LCP_INTERVAL CLAMPMSS CONNECT_POLL \ + CONNECT_TIMEOUT DEFROUTE SYNCHRONOUS ETH PROVIDER USER PEERDNS \ + DNS1 DNS2 +} + + +clear + +$ECHO "Welcome to the PPPoE client setup. First, I will run some checks on" +$ECHO "your system to make sure the PPPoE client is installed properly..." +$ECHO "" + +# Must be root +if [ "`$ID -u`" != 0 ] ; then + $ECHO "$0: Sorry, you must be root to run this script" + exit 1 +fi + +# Must have pppd +if [ ! -x $PPPD ] ; then + $ECHO "Oops, I can't execute the program '$PPPD'. You" + $ECHO "must install the PPP software suite, version 2.3.10 or later." + exit 1 +fi + +# get the DSL config files in /etc/sysconfig/network-scripts +devices="" +device_count=0 +get_device + +if [ $device_count -gt 0 ] ; then + $ECHO "The following DSL config was found on your system:" + $ECHO "" + $ECHO " Device: Name:" + + for i in $devices ; do + . $NETWORKDIR/ifcfg-$i + $ECHO " $i $NAME" + done + + $ECHO "" + + for i in $devices ; do + default_device=$i + break + done + + clear_env + + while [ true ] ; do + $ECHO "Please enter the device if you want to configure the present DSL config" + $ECHO -n "(default $default_device) or enter 'n' if you want to create a new one: " + + read dev + + if [ "$dev" = "n" ] ; then + i=0 + while true; do + found=0 + for j in $interfaces ; do + if [ "$j" = "ppp$i" ] ; then + found=1 + break + fi + done + if [ $found -eq 0 ] ; then + dsl_device="ppp$i" + break + fi + i=$[$i+1] + done + if [ -z "$dsl_device" ]; then + dev=0 + while [ -e $NETWORKDIR/ifcfg-ppp$dev ]; do + dev=`expr $dev + 1` + done + dsl_device="ppp$dev" + fi + break + else + if [ -n "$default_device" ] ; then + if [ -n "$dev" ] ; then + dsl_device="$dev" + else + dsl_device="$default_device" + fi + fi + for i in $devices ; do + [ "$dsl_device" = "$i" ] && break + done + if [ "$dsl_device" = "$i" ] ; then + break + fi + $ECHO "Device '$dsl_device' is not found in the list, please choose the correct one" + fi + done +else + dev=0 + while [ -e $NETWORKDIR/ifcfg-ppp$dev ]; do + dev=`expr $dev + 1` + done + dsl_device="ppp$dev" +fi + +CONFIG="$NETWORKDIR/ifcfg-$dsl_device" +DEVICE=$dsl_device +export CONFIG + +[ "$dev" = "n" ] || . $CONFIG 2>/dev/null +[ "$DEMAND" = "" ] && DEMAND=no + +while [ true ] ; do + $ECHO "" + $ECHO "LOGIN NAME" + $ECHO "" + if [ -z "$USER" ] ; then + $ECHO -n "Enter your Login Name: " + else + $ECHO -n "Enter your Login Name (default $USER): " + fi + + read U + + if [ -z "$U" ] ; then + if [ -z "$USER" ] ; then + continue + fi + else + USER="$U" + fi + + + # Under Linux, "fix" the default interface if eth1 is not available + [ -n "$ETH" ] || ETH=eth0 + if test `uname -s` = "Linux" ; then + $IP link show $ETH > /dev/null 2>&1 || ETH=eth0 + fi + $ECHO "" + $ECHO "INTERFACE" + $ECHO "" + $ECHO "Enter the Ethernet interface connected to the PPPoE modem" + $ECHO "For Solaris, this is likely to be something like /dev/hme0." + $ECHO "For Linux, it will be ethX, where 'X' is a number." + $ECHO -n "(default $ETH): " + read E + + if [ -n "$E" ] ; then + ETH="$E" + fi + + $ECHO "" + $ECHO "Do you want the link to come up on demand, or stay up continuously?" + $ECHO "If you want it to come up on demand, enter the idle time in seconds" + $ECHO "after which the link should be dropped. If you want the link to" + $ECHO "stay up permanently, enter 'no' (two letters, lower-case.)" + $ECHO "NOTE: Demand-activated links do not interact well with dynamic IP" + $ECHO "addresses. You may have some problems with demand-activated links." + $ECHO -n "Enter the demand value (default $DEMAND): " + read D + if [ -n "$D" ] ; then + DEMAND="$D" + fi + + $ECHO "" + $ECHO "DNS" + $ECHO "" + $ECHO "Please enter the IP address of your ISP's primary DNS server." + $ECHO "If your ISP claims that 'the server will provide dynamic DNS addresses'," + $ECHO "enter 'server' (all lower-case) here." + $ECHO "If you just press enter, I will assume you know what you are" + $ECHO "doing and not modify your DNS setup." + $ECHO -n "Enter the DNS information here: " + + read DNS1 + + + if [ -n "$DNS1" ] ; then + if [ "$DNS1" != "server" ] ; then + $ECHO "Please enter the IP address of your ISP's secondary DNS server." + $ECHO "If you just press enter, I will assume there is only one DNS server." + $ECHO -n "Enter the secondary DNS server address here: " + read DNS2 + fi + fi + + while [ true ] ; do + $ECHO "" + $ECHO "PASSWORD" + $ECHO "" + stty -echo + $ECHO -n "Please enter your Password: " + read PWD1 + $ECHO "" + $ECHO -n "Please re-enter your Password: " + read PWD2 + $ECHO "" + stty echo + if [ "$PWD1" = "$PWD2" ] ; then + break + fi + + $ECHO -n "Sorry, the passwords do not match. Try again? (y/n)" + read ANS + case "$ANS" in + N|No|NO|Non|n|no|non) + $ECHO "OK, quitting. Bye." + exit 1 + esac + done + + # Usercontrol + $ECHO "" + $ECHO "USERCTRL" + $ECHO + $ECHO "Please enter 'yes' (three letters, lower-case.) if you want to allow" + $ECHO -n "normal user to start or stop DSL connection (default yes): " + + read USERCTL + + if [ -z "$USERCTL" ] ; then + USERCTL="yes" + fi + + # Firewalling + $ECHO "" + $ECHO "FIREWALLING" + $ECHO "" + if test `uname -s` != "Linux" ; then + $ECHO "Sorry, firewalling is only supported under Linux. Consult" + $ECHO "your operating system manuals for details on setting up" + $ECHO "packet filters for your system." + FIREWALL=NONE + else + $ECHO "Please choose the firewall rules to use. Note that these rules are" + $ECHO "very basic. You are strongly encouraged to use a more sophisticated" + $ECHO "firewall setup; however, these will provide basic security. If you" + $ECHO "are running any servers on your machine, you must choose 'NONE' and" + $ECHO "set up firewalling yourself. Otherwise, the firewall rules will deny" + $ECHO "access to all standard servers like Web, e-mail, ftp, etc. If you" + $ECHO "are using SSH, the rules will block outgoing SSH connections which" + $ECHO "allocate a privileged source port." + $ECHO "" + while [ true ] ; do + $ECHO "The firewall choices are:" + $ECHO "0 - NONE: This script will not set any firewall rules. You are responsible" + $ECHO " for ensuring the security of your machine. You are STRONGLY" + $ECHO " recommended to use some kind of firewall rules." + $ECHO "1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation" + $ECHO "2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway" + $ECHO " for a LAN" + $ECHO -n "Choose a type of firewall (0-2): " + read a + if [ "$a" = 0 -o "$a" = 1 -o "$a" = 2 ] ; then + break + fi + $ECHO "Please enter a number from 0 to 2" + done + + case "$a" in + 0) + FIREWALL=NONE + ;; + 1) + FIREWALL=STANDALONE + ;; + 2) + FIREWALL=MASQUERADE + ;; + esac + fi + + $ECHO "" + $ECHO "Start this connection at boot time" + $ECHO "" + $ECHO "Do you want to start this connection at boot time?" + $ECHO -n "Please enter no or yes (default no):" + read boot + case "$boot" in + yes|YES) ONBOOT="yes";; + *) ONBOOT="no";; + esac + + $ECHO "" + $ECHO "** Summary of what you entered **" + $ECHO "" + $ECHO "Ethernet Interface: $ETH" + $ECHO "User name: $USER" + if [ "$DEMAND" = "no" ] ; then + $ECHO "Activate-on-demand: No" + else + $ECHO "Activate-on-demand: Yes; idle timeout = $DEMAND seconds" + fi + + if [ -n "$DNS1" ] ; then + if [ "$DNS1" = "server" ] ; then + $ECHO "DNS addresses: Supplied by ISP's server" + else + $ECHO "Primary DNS: $DNS1" + if [ -n "$DNS2" ] ; then + $ECHO "Secondary DNS: $DNS2" + fi + fi + else + $ECHO "DNS: Do not adjust" + fi + $ECHO "Firewalling: $FIREWALL" + $ECHO "User Control: $USERCTL" + while [ true ] ; do + $ECHO -n 'Accept these settings and adjust configuration files (y/n)? ' + read ANS + case "ANS" in + Y|y|yes|Yes|oui|Oui) + ANS=y + ;; + N|n|no|No|non|Non) + ANS=n + ;; + esac + if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then + break + fi + done + if [ "$ANS" = "y" ] ; then + break + fi +done + +# Adjust configuration files. First to $CONFIG + +$ECHO "Adjusting $CONFIG" + +test -f $CONFIG && copy $CONFIG $CONFIG.bak +if [ "$DNS1" = "server" ] ; then + DNS1="" + DNS2="" + PEERDNS=yes +else + PEERDNS=no +fi + +# Where is pppd likely to put its pid? +if [ -d /var/run ] ; then + VARRUN=/var/run +else + VARRUN=/etc/ppp +fi + +$ECHO "USERCTL=$USERCTL" >$CONFIG +$ECHO "BOOTPROTO=dialup" >>$CONFIG +[ -z "$NAME" ] && NAME="DSL$DEVICE" +$ECHO "NAME=DSL$DEVICE" >>$CONFIG +$ECHO "DEVICE=$DEVICE" >>$CONFIG +$ECHO "TYPE=xDSL" >>$CONFIG +$ECHO "ONBOOT=$ONBOOT" >>$CONFIG +$ECHO "PIDFILE=/var/run/pppoe-adsl.pid" >>$CONFIG +$ECHO "FIREWALL=$FIREWALL" >>$CONFIG +[ -z "$PING" ] && PING="." +$ECHO "PING=$PING" >>$CONFIG +[ -z "$PPPOE_TIMEOUT" ] && PPPOE_TIMEOUT=80 +$ECHO "PPPOE_TIMEOUT=$PPPOE_TIMEOUT" >>$CONFIG +[ -z "$LCP_FAILURE" ] && LCP_FAILURE=3 +$ECHO "LCP_FAILURE=$LCP_FAILURE" >>$CONFIG +[ -z "$LCP_INTERVAL" ] && LCP_INTERVAL=20 +$ECHO "LCP_INTERVAL=$LCP_INTERVAL" >>$CONFIG +[ -z "$CLAMPMSS" ] && CLAMPMSS=1412 +$ECHO "CLAMPMSS=$CLAMPMSS" >>$CONFIG +[ -z "$CONNECT_POLL" ] && CONNECT_POLL=6 +$ECHO "CONNECT_POLL=$CONNECT_POLL" >>$CONFIG +[ -z "$CONNECT_TIMEOUT" ] && CONNECT_TIMEOUT=60 +$ECHO "CONNECT_TIMEOUT=$CONNECT_TIMEOUT" >>$CONFIG +[ -z "$DEFROUTE" ] && DEFROUTE=yes +$ECHO "DEFROUTE=$DEFROUTE" >>$CONFIG +[ -z "$SYNCHRONOUS" ] && SYNCHRONOUS=no +$ECHO "SYNCHRONOUS=$SYNCHRONOUS" >>$CONFIG +$ECHO "ETH=$ETH" >> $CONFIG +[ -z "$PROVIDER" ] && PROVIDER="$NAME" +$ECHO "PROVIDER=$PROVIDER" >>$CONFIG +$ECHO "USER=$USER" >>$CONFIG +$ECHO "PEERDNS=$PEERDNS" >>$CONFIG +$ECHO "DEMAND=$DEMAND" >>$CONFIG + +if [ -n "$DNS1" ] ; then + if [ "$DNS1" != "server" ] ; then + $ECHO "Adjusting $RESOLVFILE" + if [ -r $RESOLVFILE ] ; then + grep -s "MADE-BY-RP-PPPOE" $RESOLVFILE > /dev/null 2>&1 + if [ "$?" != 0 ] ; then + $ECHO " (But first backing it up to $RESOLVFILE.bak)" + test -f $$RESOLVFILE && copy $RESOLVFILE $RESOLVFILE.bak + fi + fi + $ECHO "# MADE-BY-RP-PPPOE" > $RESOLVFILE + $ECHO "nameserver $DNS1" >> $RESOLVFILE + if [ -n "$DNS2" ] ; then + $ECHO "nameserver $DNS2" >> $RESOLVFILE + fi + fi +fi + +$ECHO "Adjusting $PAPFILE and $CHAPFILE" +if [ -r $PAPFILE ] ; then + $ECHO " (But first backing it up to $PAPFILE.bak)" + test -f $PAPFILE && copy $PAPFILE $PAPFILE.bak +else + cp /dev/null $PAPFILE.bak +fi +if [ -r $CHAPFILE ] ; then + $ECHO " (But first backing it up to $CHAPFILE.bak)" + test -f $CHAPFILE && copy $CHAPFILE $CHAPFILE.bak +else + cp /dev/null $CHAPFILE.bak +fi + +egrep -v "^$USER|^\"$USER\"" $PAPFILE.bak > $PAPFILE +$ECHO "\"$USER\" * \"$PWD1\"" >> $PAPFILE +egrep -v "^$USER|^\"$USER\"" $CHAPFILE.bak > $CHAPFILE +$ECHO "\"$USER\" * \"$PWD1\"" >> $CHAPFILE + +$ECHO "" +$ECHO "" +$ECHO "" +$ECHO "Congratulations, it should be all set up!" +$ECHO "" +$ECHO "Type '/sbin/ifup $dsl_device' to bring up your xDSL link and '/sbin/ifdown $dsl_device'" +$ECHO "to bring it down." +$ECHO "Type '/sbin/pppoe-status $NETWORKDIR/ifcfg-$dsl_device'" +$ECHO "to see the link status." +$ECHO "" + +exit 0 diff --git a/pppoe-start b/pppoe-start new file mode 100644 index 0000000..d0de82a --- /dev/null +++ b/pppoe-start @@ -0,0 +1,228 @@ +#! /bin/bash +# Generated automatically from pppoe-start.in by configure. +#*********************************************************************** +# +# pppoe-start +# +# Shell script to bring up an PPPoE connection +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: pppoe-start [config_file] +# pppoe-start interface user [config_file] +# Second form overrides USER and ETH from config file. +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +# From AUTOCONF +prefix=/usr +exec_prefix=/usr + +# Paths to programs +CONNECT=/usr/sbin/pppoe-connect +ECHO=/usr/bin/echo +IP=/usr/sbin/ip +LS=/usr/bin/ls +NETWORKDIR=/etc/sysconfig/network-scripts + +get_device() { + if [ ! -d $NETWORKDIR ] ; then + $ECHO "** $NETWORKDIR not found" + $ECHO "** Quitting" + exit 1 + fi + + cd $NETWORKDIR + interfaces=$($LS ifcfg-ppp* 2>/dev/null | egrep -v '(~|\.bak)$' | \ + egrep -v '(rpmsave|rpmorig|rpmnew)' | sed 's/^ifcfg-//g') + + for i in $interfaces ; do + test -f ifcfg-$i && . ifcfg-$i 2>/dev/null + if [ "$TYPE" = "xDSL" ] ; then + CONFIG=$NETWORKDIR/ifcfg-$i + break + fi + done +} + +# Set to "C" locale so we can parse messages from commands +LANG=C +export LANG + +# Defaults +USER="" +ETH="" +ME=`basename $0` + +# Must be root +if [ "`/usr/bin/id -u`" != 0 ] ; then + [ "$DEBUG" = "1" ] && $ECHO "$ME: You must be root to run this script" >& 2 + exit 1 +fi + +# Debugging +if [ "$DEBUG" = "1" ] ; then + $ECHO "*** Running in debug mode... please be patient..." + DEBUG=`mktemp -d /tmp/pppoe-debug-XXXXXXXX` + if [ $? -ne 0 ] ; then + $ECHO "Could not create directory $DEBUG... exiting" + exit 1 + fi + export DEBUG + DEBUG=$DEBUG/pppoe-debug.txt + + # Initial debug output + $ECHO "---------------------------------------------" > $DEBUG + $ECHO "* The following section contains information about your system" >> $DEBUG + date >> $DEBUG + $ECHO "Output of uname -a" >> $DEBUG + uname -a >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "* The following section contains information about your network" >> $DEBUG + $ECHO "* interfaces. The one you chose for PPPoE should contain the words:" >> $DEBUG + $ECHO "* 'UP' and 'RUNNING'. If it does not, you probably have an Ethernet" >> $DEBUG + $ECHO "* driver problem." >> $DEBUG + $ECHO "Output of ip addr show" >> $DEBUG + $IP addr show >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + if [ "`uname -s`" = "Linux" ] ; then + $ECHO "* The following section contains information about kernel modules" >> $DEBUG + $ECHO "* If the module for your Ethernet card is 'tulip', you might" >> $DEBUG + $ECHO "* want to look for an updated version at http://www.scyld.com" >> $DEBUG + $ECHO "Output of lsmod" >> $DEBUG + lsmod >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + fi + $ECHO "* The following section lists your routing table." >> $DEBUG + $ECHO "* If you have an entry which starts with '0.0.0.0', you probably" >> $DEBUG + $ECHO "* have defined a default route and gateway, and pppd will" >> $DEBUG + $ECHO "* not create a default route using your ISP. Try getting" >> $DEBUG + $ECHO "* rid of this route." >> $DEBUG + $ECHO "Output of ip route" >> $DEBUG + $IP route >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "Contents of /etc/resolv.conf" >> $DEBUG + $ECHO "* The following section lists DNS setup." >> $DEBUG + $ECHO "* If you can browse by IP address, but not name, suspect" >> $DEBUG + $ECHO "* a DNS problem." >> $DEBUG + cat /etc/resolv.conf >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "* The following section lists /etc/ppp/options." >> $DEBUG + $ECHO "* You should have NOTHING in that file." >> $DEBUG + $ECHO "Contents of /etc/ppp/options" >> $DEBUG + cat /etc/ppp/options >> $DEBUG 2>/dev/null + $ECHO "---------------------------------------------" >> $DEBUG + DEBUG="1" +fi + +# Sort out command-line arguments +case "$#" in + 1) + CONFIG="$1" + ;; + 3) + CONFIG="$3" + ;; +esac + +if [ -z "$CONFIG" ] ; then + get_device + [ -z "$CONFIG" ] && CONFIG=/etc/ppp/pppoe.conf +fi + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + [ "$DEBUG" = "1" ] && $ECHO "$ME: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +export CONFIG +. $CONFIG + +# Check for command-line overriding of ETH and USER +case "$#" in + 2|3) + ETH="$1" + USER="$2" + ;; +esac + +# Check for pidfile +if [ -r "$PIDFILE" ] ; then + PID=`cat "$PIDFILE"` + # Check if still running + kill -0 $PID > /dev/null 2>&1 + if [ $? = 0 ] ; then + [ "$DEBUG" = "1" ] && $ECHO "$ME: There already seems to be an PPPoE connection up (PID $PID)" >& 2 + exit 1 + fi + # Delete bogus PIDFILE + rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start" +fi + +echo $$ > $PIDFILE.start + +# Start the connection in the background unless we're debugging +if [ "$DEBUG" != "" ] ; then + $CONNECT "$@" + exit 0 +fi + +$CONNECT "$@" > /dev/null 2>&1 & +CONNECT_PID=$! + +if [ "$CONNECT_TIMEOUT" = "" -o "$CONNECT_TIMEOUT" = 0 ] ; then + exit 0 +fi + +# Don't monitor connection if dial-on-demand +if [ "$DEMAND" != "" -a "$DEMAND" != "no" ] ; then + exit 0 +fi + +# Monitor connection +TIME=0 +while [ true ] ; do + /sbin/pppoe-status $CONFIG > /dev/null 2>&1 + + # Looks like the interface came up + if [ $? = 0 ] ; then + # Print newline if standard input is a TTY + [ "$DEBUG" = "1" ] && tty -s && $ECHO " Connected!" + exit 0 + fi + + if test -n "$FORCEPING" ; then + [ "$DEBUG" = "1" ] && $ECHO -n "$FORCEPING" + else + [ "$DEBUG" = "1" ] && tty -s && $ECHO -n "$PING" + fi + sleep $CONNECT_POLL + TIME=`expr $TIME + $CONNECT_POLL` + if [ $TIME -gt $CONNECT_TIMEOUT ] ; then + break + fi +done + +[ "$DEBUG" = "1" ] && $ECHO "TIMED OUT" >& 2 +# Timed out! Kill the pppoe-connect process and quit +kill $CONNECT_PID > /dev/null 2>&1 + +# Clean up PIDFILE(s) +rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start" + +# add old default gw back +if [ -s /etc/default-routes ] ; then + while read spec; do + $IP route add $spec + done < /etc/default-routes + rm -f /etc/default-routes +fi + +exit 1 + diff --git a/pppoe-status b/pppoe-status new file mode 100644 index 0000000..0918e81 --- /dev/null +++ b/pppoe-status @@ -0,0 +1,105 @@ +#! /bin/bash +#*********************************************************************** +# +# pppoe-status +# +# Shell script to report on status of PPPoE connection +# +# Copyright (C) 2000-2001 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# LIC: GPL +# +# Usage: pppoe-status [config_file] +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +# Defaults +LS=/usr/bin/ls +IP=/usr/sbin/ip +NETWORKDIR=/etc/sysconfig/network-scripts + +get_device() { + if [ ! -d $NETWORKDIR ] ; then + $ECHO "** $NETWORKDIR not found" + $ECHO "** Quitting" + exit 1 + fi + + cd $NETWORKDIR + interfaces=$($LS ifcfg-ppp* 2>/dev/null | egrep -v '(~|\.bak)$' | \ + egrep -v '(rpmsave|rpmorig|rpmnew)' | sed 's/^ifcfg-//g') + + for i in $interfaces ; do + test -f ifcfg-$i && . ifcfg-$i 2>/dev/null + if [ "$TYPE" = "xDSL" ] ; then + CONFIG=$NETWORKDIR/ifcfg-$i + break + fi + done +} + +CONFIG="$1" +if [ -z "$CONFIG" ] ; then + get_device + [ -z "$CONFIG" ] && CONFIG=/etc/ppp/pppoe.conf +fi + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + echo "$0: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +. $CONFIG + +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" + +if [ "$DEMAND" != "no" ] ; then + echo "Note: You have enabled demand-connection; pppoe-status may be inaccurate." +fi + +# If no PPPOE_PIDFILE, connection is down, unless we're using the Linux plugin +if [ "$LINUX_PLUGIN" = "" ] ; then + if [ ! -r "$PPPOE_PIDFILE" ] ; then + echo "pppoe-status: Link is down (can't read pppoe PID file $PPPOE_PIDFILE)" + exit 1 + fi +fi + +# If no PPPD_PIDFILE, something fishy! +if [ ! -r "$PPPD_PIDFILE" ] ; then + echo "pppoe-status: Link is down (can't read pppd PID file $PPPD_PIDFILE)" + exit 1 +fi + +PPPD_PID=`cat "$PPPD_PIDFILE"` + +# Sigh. Some versions of pppd put PID files in /var/run; others put them +# in /etc/ppp. Since it's too messy to figure out what pppd does, we +# try both locations. +for i in /etc/ppp/ppp*.pid /var/run/ppp*.pid ; do + if [ -r $i ] ; then + PID=`cat $i` + if [ "$PID" = "$PPPD_PID" ] ; then + IF=`basename $i .pid` + $IP route | grep "dev ${IF}\s" > /dev/null + if [ "$?" != "0" ] ; then + echo "pppoe-status: Link is attached to $IF, but $IF is down" + exit 1 + fi + echo "pppoe-status: Link is up and running on interface $IF" + $IP addr show $IF + exit 0 + fi + fi +done + +echo "ppppoe-status: Link is down -- could not find interface corresponding to" +echo "pppd pid $PPPD_PID" +exit 1 diff --git a/pppoe-stop b/pppoe-stop new file mode 100644 index 0000000..26c48bb --- /dev/null +++ b/pppoe-stop @@ -0,0 +1,143 @@ +#! /bin/bash +# Generated automatically from pppoe-stop.in by configure. +#*********************************************************************** +# +# pppoe-stop +# +# Shell script to bring down an PPPoE connection +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# LIC: GPL +# +# Usage: pppoe-stop [config_file] +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +export PATH=/sbin:/bin:/usr/sbin:/usr/bin + +IP=/usr/sbin/ip +LS=/bin/ls +NETWORKDIR=/etc/sysconfig/network-scripts + +# Set to "C" locale so we can parse messages from commands +LANG=C +export LANG + +get_device() { + if [ ! -d $NETWORKDIR ] ; then + $ECHO "** $NETWORKDIR not found" + $ECHO "** Quitting" + exit 1 + fi + + cd $NETWORKDIR + interfaces=$($LS ifcfg-ppp* 2>/dev/null | egrep -v '(~|\.bak)$' | \ + egrep -v '(rpmsave|rpmorig|rpmnew)' | sed 's/^ifcfg-//g') + + for i in $interfaces ; do + test -f ifcfg-$i && . ifcfg-$i 2>/dev/null + if [ "$TYPE" = "xDSL" ] ; then + CONFIG=$NETWORKDIR/ifcfg-$i + break + fi + done +} + +ME="`basename $0`" +LOGGER="/usr/bin/logger -t $ME" +CONFIG="$1" +if [ -z "$CONFIG" ] ; then + get_device + [ -z "$CONFIG" ] && CONFIG=/etc/ppp/pppoe.conf +fi + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + [ "$DEBUG" = "1" ] && echo "$ME: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +export CONFIG +. $CONFIG + +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" +STARTPID="$PIDFILE.start" + +# Backward config file compatibility +if test "$DEMAND" = "" ; then + DEMAND=no +fi + +# Ignore SIGTERM +trap "" 15 + +# Check for pidfile +if [ -r "$PIDFILE" ] ; then + PID=`cat $PIDFILE` + + # Check if still running + kill -0 $PID > /dev/null 2>&1 + if [ $? != 0 ] ; then + [ "$DEBUG" = "1" ] && echo "$ME: The pppoe-connect script (PID $PID) appears to have died" >& 2 + fi + + # Kill pppd, which should in turn kill pppoe + if [ -r "$PPPD_PIDFILE" ] ; then + PPPD_PID=`cat "$PPPD_PIDFILE"` + $LOGGER -p daemon.notice "Killing pppd" + [ "$DEBUG" = "1" ] && echo "Killing pppd ($PPPD_PID)" + kill $PPPD_PID > /dev/null 2>&1 + fi + + # Kill pppoe-start + PIDS=`cat $STARTPID` + kill -0 $PIDS > /dev/null 2>&1 + if [ $? = 0 ] ; then + $LOGGER -p daemon.notice "Killing pppoe-connect" + kill $PIDS > /dev/null 2>&1 + fi + + # Kill pppoe-connect + $LOGGER -p daemon.notice "Killing pppoe-connect" + [ "$DEBUG" = "1" ] && echo "Killing pppoe-connect ($PID)" + kill $PID > /dev/null 2>&1 + + # Kill pppd again, in case it's still hanging around + if [ -r "$PPPD_PIDFILE" ] ; then + PPPD_PID=`cat "$PPPD_PIDFILE"` + kill -9 $PPPD_PID > /dev/null 2>&1 || exit 1 + fi + + # Kill br2684ctl if necessary + if [ -n "$BR2684DEV" -a -r /var/run/nas$BR2684DEV.pid ]; then + PIDS=`cat /var/run/nas$BR2684DEV.pid` + kill -0 $PIDS > /dev/null 2>&1 + if [ $? = 0 ]; then + $LOGGER -p daemon.notice "Killing br2684ctl for nas$BR2684DEV" + kill $PIDS > /dev/null 2>&1 + fi + rm -f /var/run/nas$BR2684DEV.pid + fi + + rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID" +else + [ "$DEBUG" = "1" ] && echo "$ME: No PPPoE connection appears to be running" >&2 + exit 1 +fi + +# add old default gw back +if [ -s /etc/default-routes ] ; then + while read spec; do + $IP route add $spec + done < /etc/default-routes + rm -f /etc/default-routes +fi + +exit 0 diff --git a/rp-pppoe.changes b/rp-pppoe.changes index 1156b27..26acf00 100644 --- a/rp-pppoe.changes +++ b/rp-pppoe.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Sat Oct 25 09:51:24 UTC 2014 - p.drouand@gmail.com + +- Use systemd instead of sysvinit; add pppoe-server.service +- Install fixed versions of rp-pppoe scripts for openSUSE > 11.4 + most of fixes are about paths, because of /usr move + Added: pppoe-setup, ,pppoe-start, pppoe-connect, pppoe-status , + pppoe-stop + ------------------------------------------------------------------- Tue Apr 23 10:01:52 UTC 2013 - binli@opensuse.org diff --git a/rp-pppoe.spec b/rp-pppoe.spec index a752926..e68be4d 100644 --- a/rp-pppoe.spec +++ b/rp-pppoe.spec @@ -1,7 +1,7 @@ # # spec file for package rp-pppoe # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,9 +15,8 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # - -%if %{?rel:0}%{!?rel:1} -%define rel 1 +%if 0%{?suse_version} > 1140 +%define has_systemd 1 %endif Name: rp-pppoe @@ -27,6 +26,12 @@ Group: Productivity/Networking/PPP Version: 3.11 Release: 0 Source: http://www.roaringpenguin.com/pppoe/rp-pppoe-%{version}.tar.bz2 +Source1: pppoe-connect +Source2: pppoe-setup +Source3: pppoe-start +Source4: pppoe-status +Source5: pppoe-stop +Source6: pppoe-server.service Url: http://www.roaringpenguin.com/pppoe #Patch0: init-suse.diff Patch1: docdir.diff @@ -40,23 +45,19 @@ Patch11: %{name}-3.10-config.patch Patch12: rp-pppoe-pie.patch Requires: ppp >= 2.3.7 BuildRoot: %{_tmppath}/%{name}-%{version}-build -PreReq: %insserv_prereq %fillup_prereq BuildRequires: ppp -#---------------------------------------------------------------------------------- +%if 0%{?has_systemd} +BuildRequires: systemd +%else +PreReq: %insserv_prereq %fillup_prereq +%endif %description rp-pppoe is a user-space redirector which permits the use of PPPoE (Point-to-Point Protocol Over Ethernet) with Linux. PPPoE is used by many ADSL service providers. - - -Authors: --------- - David F. Skoll - %prep -#---------------------------------------------------------------------------------- %setup -q #%patch0 %patch1 @@ -68,57 +69,67 @@ Authors: %patch10 -p1 %patch11 -p1 %patch12 -#---------------------------------------------------------------------------------- %build -#---------------------------------------------------------------------------------- cd src -CFLAGS=$RPM_OPT_FLAGS \ %configure -%{__make} +make cd ../gui -%{__make} -#---------------------------------------------------------------------------------- +make %install -#---------------------------------------------------------------------------------- -cd src -%{__make} install DESTDIR=$RPM_BUILD_ROOT +make -C src install DESTDIR=$RPM_BUILD_ROOT +%if 0%{?has_systemd} +mkdir -p %{buildroot}%{_sbindir} %{buildroot}%{_unitdir} +install -m 0755 %{SOURCE1} %{buildroot}%{_sbindir} +install -m 0755 %{SOURCE2} %{buildroot}%{_sbindir} +install -m 0755 %{SOURCE3} %{buildroot}%{_sbindir} +install -m 0755 %{SOURCE4} %{buildroot}%{_sbindir} +install -m 0755 %{SOURCE5} %{buildroot}%{_sbindir} +install -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/pppoe-server.service +ln -sf pppoe-stop %{buildroot}%{_sbindir}/adsl-stop +ln -sf pppoe-start %{buildroot}%{_sbindir}/adsl-start +rm -rf %{buildroot}/etc/ppp/pppoe.conf \ + %{buildroot}/etc/rc.d/init.d/pppoe \ + %{buildroot}/etc/init.d +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcpppoe-server +%else %{__ln_s} -f ../../etc/init.d/pppoe $RPM_BUILD_ROOT%{_sbindir}/rcpppoe -cd ../gui -%{__make} install DESTDIR=$RPM_BUILD_ROOT -%{__install} -d $RPM_BUILD_ROOT%_defaultdocdir/rp-pppoe -%{__mv} $RPM_BUILD_ROOT/etc/ppp/plugins/README $RPM_BUILD_ROOT%_defaultdocdir/rp-pppoe/README.plugins -%{__rm} -rf $RPM_BUILD_ROOT/etc/ppp/plugins -#---------------------------------------------------------------------------------- +%endif +make -C gui install DESTDIR=$RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT%_defaultdocdir/rp-pppoe +mv $RPM_BUILD_ROOT/etc/ppp/plugins/README $RPM_BUILD_ROOT%_defaultdocdir/rp-pppoe/README.plugins +%{__rm} -rf %{buildroot}%{_sysconfdir}/ppp/plugins -%clean -#---------------------------------------------------------------------------------- -[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && %{__rm} -rf $RPM_BUILD_ROOT -#---------------------------------------------------------------------------------- +%if 0%{?has_systemd} +%pre +%service_add_pre pppoe-server.service %preun -#---------------------------------------------------------------------------------- +%service_del_preun pppoe-server.service +%else %stop_on_removal pppoe -#---------------------------------------------------------------------------------- +%endif %post -#---------------------------------------------------------------------------------- +%if 0%{?has_systemd} +%service_add_post pppoe-server.service +%else %{fillup_and_insserv pppoe} -#---------------------------------------------------------------------------------- +%endif %postun -#---------------------------------------------------------------------------------- +%if 0%{?has_systemd} +%service_del_postun pppoe-server.service +%else %restart_on_update pppoe %{insserv_cleanup} -#---------------------------------------------------------------------------------- +%endif %files -#---------------------------------------------------------------------------------- %defattr(-,root,root) %dir %_defaultdocdir/rp-pppoe %doc %_defaultdocdir/rp-pppoe/* -%config(noreplace) /etc/ppp/pppoe.conf %config(noreplace) /etc/ppp/pppoe-server-options %config(noreplace) /etc/ppp/firewall-masq %config(noreplace) /etc/ppp/firewall-standalone @@ -133,7 +144,6 @@ cd ../gui %{_sbindir}/pppoe-setup %{_sbindir}/pppoe-status %attr (4750,root,dialout) %{_sbindir}/pppoe-wrapper -%{_sbindir}/rcpppoe %{_mandir}/man5/pppoe.conf.5* %{_mandir}/man8/pppoe.8* %{_mandir}/man8/pppoe-server.8* @@ -144,7 +154,16 @@ cd ../gui %{_mandir}/man8/pppoe-stop.8* %{_mandir}/man8/pppoe-status.8* %{_mandir}/man8/pppoe-setup.8* +%if 0%{?has_systemd} +%{_sbindir}/adsl-start +%{_sbindir}/adsl-stop +%{_sbindir}/rcpppoe-server +%{_unitdir}/pppoe-server.service +%else /etc/init.d/pppoe +%{_sbindir}/rcpppoe +%config(noreplace) /etc/ppp/pppoe.conf +%endif %dir /etc/ppp/rp-pppoe-gui %{_mandir}/man1/tkpppoe.1* %{_mandir}/man1/pppoe-wrapper.1* @@ -159,7 +178,5 @@ cd ../gui /usr/share/tkpppoe/props-options.png /usr/share/tkpppoe/en.msg /usr/share/tkpppoe/ja.msg -#---------------------------------------------------------------------------------- -#---------------------------------------------------------------------------------- %changelog