[1c48007] | 1 | #!/bin/sh
|
---|
| 2 | ########################################################################
|
---|
[0cda898] | 3 | # Begin network
|
---|
[1c48007] | 4 | #
|
---|
| 5 | # Description : Network Control Script
|
---|
| 6 | #
|
---|
| 7 | # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
|
---|
[0cda898] | 8 | # Nathan Coulson - nathan@linuxfromscratch.org
|
---|
| 9 | # Kevin P. Fleming - kpfleming@linuxfromscratch.org
|
---|
[f874424] | 10 | # DJ Lucas - dj@linuxfromscratch.org
|
---|
[0cda898] | 11 | # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
|
---|
[1c48007] | 12 | #
|
---|
[0cda898] | 13 | # Version : LFS 7.0
|
---|
[1c48007] | 14 | #
|
---|
| 15 | ########################################################################
|
---|
| 16 |
|
---|
[0cda898] | 17 | ### BEGIN INIT INFO
|
---|
| 18 | # Provides: $network
|
---|
[f92b8de] | 19 | # Required-Start: $local_fs localnet swap
|
---|
| 20 | # Should-Start: $syslog firewalld iptables nftables
|
---|
| 21 | # Required-Stop: $local_fs localnet swap
|
---|
| 22 | # Should-Stop: $syslog firewalld iptables nftables
|
---|
[96a636b] | 23 | # Default-Start: 2 3 4 5
|
---|
| 24 | # Default-Stop: 0 1 6
|
---|
[0cda898] | 25 | # Short-Description: Starts and configures network interfaces.
|
---|
| 26 | # Description: Starts and configures network interfaces.
|
---|
| 27 | # X-LFS-Provided-By: LFS
|
---|
| 28 | ### END INIT INFO
|
---|
[1c48007] | 29 |
|
---|
| 30 | case "${1}" in
|
---|
[0cda898] | 31 | start)
|
---|
[ed6ffcb] | 32 | # if the default route exists, network is already configured
|
---|
| 33 | if ip route | grep -q "^default"; then return 0; fi
|
---|
[0cda898] | 34 | # Start all network interfaces
|
---|
| 35 | for file in /etc/sysconfig/ifconfig.*
|
---|
| 36 | do
|
---|
| 37 | interface=${file##*/ifconfig.}
|
---|
[1c48007] | 38 |
|
---|
[f874424] | 39 | # Skip if $file is * (because nothing was found)
|
---|
[25596ffb] | 40 | if [ "${interface}" = "*" ]; then continue; fi
|
---|
[1c48007] | 41 |
|
---|
[0cda898] | 42 | /sbin/ifup ${interface}
|
---|
| 43 | done
|
---|
| 44 | ;;
|
---|
[1c48007] | 45 |
|
---|
[0cda898] | 46 | stop)
|
---|
[94cea1d] | 47 | # Unmount any network mounted file systems
|
---|
[a44ae577] | 48 | umount --all --force --types nfs,cifs,nfs4
|
---|
[94cea1d] | 49 |
|
---|
[0cda898] | 50 | # Reverse list
|
---|
[f874424] | 51 | net_files=""
|
---|
[0cda898] | 52 | for file in /etc/sysconfig/ifconfig.*
|
---|
| 53 | do
|
---|
[f874424] | 54 | net_files="${file} ${net_files}"
|
---|
[0cda898] | 55 | done
|
---|
[1c48007] | 56 |
|
---|
[0cda898] | 57 | # Stop all network interfaces
|
---|
[f874424] | 58 | for file in ${net_files}
|
---|
[0cda898] | 59 | do
|
---|
| 60 | interface=${file##*/ifconfig.}
|
---|
[1c48007] | 61 |
|
---|
[f874424] | 62 | # Skip if $file is * (because nothing was found)
|
---|
[25596ffb] | 63 | if [ "${interface}" = "*" ]; then continue; fi
|
---|
| 64 |
|
---|
| 65 | # See if interface exists
|
---|
| 66 | if [ ! -e /sys/class/net/$interface ]; then continue; fi
|
---|
| 67 |
|
---|
| 68 | # Is interface UP?
|
---|
| 69 | ip link show $interface 2>/dev/null | grep -q "state UP"
|
---|
| 70 | if [ $? -ne 0 ]; then continue; fi
|
---|
[1c48007] | 71 |
|
---|
[0cda898] | 72 | /sbin/ifdown ${interface}
|
---|
| 73 | done
|
---|
| 74 | ;;
|
---|
[1c48007] | 75 |
|
---|
[0cda898] | 76 | restart)
|
---|
| 77 | ${0} stop
|
---|
| 78 | sleep 1
|
---|
| 79 | ${0} start
|
---|
| 80 | ;;
|
---|
[1c48007] | 81 |
|
---|
[0cda898] | 82 | *)
|
---|
| 83 | echo "Usage: ${0} {start|stop|restart}"
|
---|
| 84 | exit 1
|
---|
| 85 | ;;
|
---|
[1c48007] | 86 | esac
|
---|
| 87 |
|
---|
[f874424] | 88 | exit 0
|
---|
| 89 |
|
---|
[0cda898] | 90 | # End network
|
---|