Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### BEGIN INIT INFO
- # Provides: ipv6-start
- # Required-Start: $remote_fs $syslog $network $named $all
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start daemon at boot time
- # Description: Enable service provided by daemon.
- ### END INIT INFO
- Pidfile=/run/dhclient6.eth0.pid
- IP=2001:bc8:2782:100::/56
- IPS=2001:bc8:2782:100::
- if [ -f $Pidfile ]
- then
- Pid=`cat $Pidfile`
- fi
- case "$1" in
- 'start')
- if [ -f $Pidfile ] ; then
- if test `ps -e | grep -c $Pid` = 1; then
- echo "dhclient is already running"
- else
- echo "Starting dhclient"
- dhclient -1 -cf /etc/dhcp/dhclient6.conf -pf $Pidfile -v -nw -6 -P vmbr0 &> /dev/null
- ip -6 addr add $IP dev vmbr0
- ip -6 route add $IP dev vmbr0
- ip -6 route add default via $IPS
- fi
- else
- echo "Starting dhclient"
- dhclient -1 -cf /etc/dhcp/dhclient6.conf -pf $Pidfile -v -nw -6 -P vmbr0 &> /dev/null
- ip -6 addr add $IP dev vmbr0
- ip -6 route add $IP dev vmbr0
- ip -6 route add default via $IPS
- fi
- ;;
- 'stop')
- if [ -f $Pidfile ] ; then
- echo "stopping dhclient"
- dhclient -x -pf $Pidfile
- ip -6 route del default via $IPS
- ip -6 route del $IP dev vmbr0
- else
- echo "Cannot stop dhclient - no Pidfile found!"
- fi
- ;;
- 'restart')
- $0 stop
- sleep 5
- $0 start
- ;;
- 'status')
- if [ -f $Pidfile ] ; then
- if test `ps -e | grep -c $Pid` = 0; then
- echo "dhclient not running"
- else
- echo "dhclient running with PID: [$Pid]"
- fi
- else
- echo "$Pidfile does not exist! Cannot process dhclient status!"
- exit 1
- fi
- ;;
- *)
- echo "usage: $0 { start | stop | restart | status }"
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement