Advertisement
Guest User

ip-up modified

a guest
Oct 19th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.21 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # This script is run by the pppd after the link is established.
  4. # It uses run-parts to run scripts in /etc/ppp/ip-up.d, so to add routes,
  5. # set IP address, run the mailq etc. you should create script(s) there.
  6. #
  7. # Be aware that other packages may include /etc/ppp/ip-up.d scripts (named
  8. # after that package), so choose local script names with that in mind.
  9. #
  10. # This script is called with the following arguments:
  11. #    Arg  Name                          Example
  12. #    $1   Interface name                ppp0
  13. #    $2   The tty                       ttyS1
  14. #    $3   The link speed                38400
  15. #    $4   Local IP number               12.34.56.78
  16. #    $5   Peer  IP number               12.34.56.99
  17. #    $6   Optional ``ipparam'' value    foo
  18.  
  19. # The  environment is cleared before executing this script
  20. # so the path must be reset
  21. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
  22. export PATH
  23.  
  24. # These variables are for the use of the scripts run by run-parts
  25. PPP_IFACE="$1"
  26. PPP_TTY="$2"
  27. PPP_SPEED="$3"
  28. PPP_LOCAL="$4"
  29. PPP_REMOTE="$5"
  30. PPP_IPPARAM="$6"
  31. export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
  32.  
  33. # as an additional convenience, $PPP_TTYNAME is set to the tty name,
  34. # stripped of /dev/ (if present) for easier matching.
  35. PPP_TTYNAME=`/usr/bin/basename "$2"`
  36. export PPP_TTYNAME
  37.  
  38. # If /var/log/ppp-ipupdown.log exists use it for logging.
  39. if [ -e /var/log/ppp-ipupdown.log ]; then
  40.   exec > /var/log/ppp-ipupdown.log 2>&1
  41.   echo $0 $*
  42.   echo
  43. fi
  44.  
  45. # This script can be used to override the .d files supplied by other packages.
  46. if [ -x /etc/ppp/ip-up.local ]; then
  47.   exec /etc/ppp/ip-up.local "$*"
  48. fi
  49.  
  50. run-parts /etc/ppp/ip-up.d \
  51.   --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"
  52.  
  53. # if pon was called with the "quick" argument, stop pppd
  54. if [ -e /var/run/ppp-quick ]; then
  55.   rm /var/run/ppp-quick
  56.   wait
  57.   kill $PPPD_PID
  58. fi
  59.  
  60. if [ "$PEERNAME" != "" ]; then
  61.     PPP_IPPARAM=pptp`echo $PEERNAME | /usr/bin/tr a-z A-Z`
  62. fi
  63.  
  64. #################################
  65. if [ -x /sbin/ip ] && [ "$PPP_IPPARAM" != "" ]; then
  66.         /sbin/ip link set $1 down
  67.         /sbin/ip link set $1 name $PPP_IPPARAM
  68.         /sbin/ip link set $PPP_IPPARAM up
  69. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement