ip-up 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. # The environment is cleared before executing this script
  19. # so the path must be reset
  20. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
  21. export PATH
  22. # These variables are for the use of the scripts run by run-parts
  23. PPP_IFACE="$1"
  24. PPP_TTY="$2"
  25. PPP_SPEED="$3"
  26. PPP_LOCAL="$4"
  27. PPP_REMOTE="$5"
  28. PPP_IPPARAM="$6"
  29. export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
  30. # as an additional convenience, $PPP_TTYNAME is set to the tty name,
  31. # stripped of /dev/ (if present) for easier matching.
  32. PPP_TTYNAME=`/usr/bin/basename "$2"`
  33. export PPP_TTYNAME
  34. # If /var/log/ppp-ipupdown.log exists use it for logging.
  35. if [ -e /var/log/ppp-ipupdown.log ]; then
  36. exec > /var/log/ppp-ipupdown.log 2>&1
  37. echo $0 $@
  38. echo
  39. fi
  40. # This script can be used to override the .d files supplied by other packages.
  41. if [ -x /etc/ppp/ip-up.local ]; then
  42. exec /etc/ppp/ip-up.local "$@"
  43. fi
  44. run-parts /etc/ppp/ip-up.d \
  45. --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"
  46. # if pon was called with the "quick" argument, stop pppd
  47. if [ -e /var/run/ppp-quick ]; then
  48. rm /var/run/ppp-quick
  49. wait
  50. kill $PPPD_PID
  51. fi
  52. /bin/touch /tmp/network-is-up