Advertisement
Guest User

ipv6

a guest
Feb 11th, 2017
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: ipv6-start
  4. # Required-Start: $remote_fs $syslog $network $named $all
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Start daemon at boot time
  9. # Description: Enable service provided by daemon.
  10. ### END INIT INFO
  11. Pidfile=/run/dhclient6.eth0.pid
  12. IP=2001:bc8:2782:100::/56
  13. IPS=2001:bc8:2782:100::
  14. if [ -f $Pidfile ]
  15. then
  16. Pid=`cat $Pidfile`
  17. fi
  18.  
  19. case "$1" in
  20. 'start')
  21. if [ -f $Pidfile ] ; then
  22. if test `ps -e | grep -c $Pid` = 1; then
  23. echo "dhclient is already running"
  24. else
  25. echo "Starting dhclient"
  26. dhclient -1 -cf /etc/dhcp/dhclient6.conf -pf $Pidfile -v -nw -6 -P vmbr0 &> /dev/null
  27. ip -6 addr add $IP dev vmbr0
  28. ip -6 route add $IP dev vmbr0
  29. ip -6 route add default via $IPS
  30. fi
  31. else
  32. echo "Starting dhclient"
  33. dhclient -1 -cf /etc/dhcp/dhclient6.conf -pf $Pidfile -v -nw -6 -P vmbr0 &> /dev/null
  34. ip -6 addr add $IP dev vmbr0
  35. ip -6 route add $IP dev vmbr0
  36. ip -6 route add default via $IPS
  37. fi
  38. ;;
  39.  
  40. 'stop')
  41. if [ -f $Pidfile ] ; then
  42. echo "stopping dhclient"
  43. dhclient -x -pf $Pidfile
  44. ip -6 route del default via $IPS
  45. ip -6 route del $IP dev vmbr0
  46. else
  47. echo "Cannot stop dhclient - no Pidfile found!"
  48. fi
  49. ;;
  50.  
  51. 'restart')
  52. $0 stop
  53. sleep 5
  54. $0 start
  55. ;;
  56.  
  57. 'status')
  58. if [ -f $Pidfile ] ; then
  59. if test `ps -e | grep -c $Pid` = 0; then
  60. echo "dhclient not running"
  61. else
  62. echo "dhclient running with PID: [$Pid]"
  63. fi
  64. else
  65. echo "$Pidfile does not exist! Cannot process dhclient status!"
  66. exit 1
  67. fi
  68. ;;
  69.  
  70. *)
  71. echo "usage: $0 { start | stop | restart | status }"
  72. ;;
  73.  
  74. esac
  75. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement