source: bootscripts/lfs/init.d/network@ 16cd0963

11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 bdubbs/gcc13 multilib renodr/libudev-from-systemd trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 16cd0963 was ed6ffcb, checked in by Pierre Labastie <pierre.labastie@…>, 2 years ago

network bootscript: Don't run ifup if route already set

Otherwise, warnings are issued when changing runlevel. "ip route"
is a good test of whether network is already up. If users want to
change some config, they should use ifup/down, not the network
bootscript.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[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
30case "${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]86esac
87
[f874424]88exit 0
89
[0cda898]90# End network
Note: See TracBrowser for help on using the repository browser.