2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-05-17 11:54:16 +00:00
Files
xcat-core/xCAT-genesis-scripts/usr/bin/restart
T
Vinícius Ferrão e239e04843 genesis-scripts: improve shell quoting and syntax hygiene
Replace backtick command substitutions with $(), quote variable
expansions to prevent word splitting, replace useless cat pipes with
redirections, use grep -q instead of redirecting to /dev/null, and use
bash parameter expansion for case conversion.

Based on the work from PR #6366, rebased and adapted to current master.
Shebangs already merged separately via df64bf8fe are excluded.

Co-Authored-By: Samveen <samveen@yahoo.com>
2026-05-07 18:17:00 -03:00

86 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#Redhcp, do the xcat part again
FORCENICS="$(awk '{print $2}' /restart)"
rm /restart
if [ ! -z "$FORCENICS" ]; then
echo "Forcing down nics aside from $FORCENICS due to discoverynics setting"
for pidfile in /var/run/dhclient.*.pid; do
NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
if [ ! -z "$NIC" ] && echo "$NIC" | egrep -qv "$FORCENICS"; then
dhclient -r -1 -cf /etc/dhclient.conf -pf "$pidfile" "$NIC"
rm "$pidfile"
ip link set "$NIC" down
fi
done
for pidfile in /var/run/dhclient6.*.pid; do
NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
if [ ! -z "$NIC" ] && echo "$NIC" | egrep -qv "$FORCENICS"; then
dhclient -6 -r -1 -pf "$pidfile" -lf /var/lib/dhclient/dhclient6.leases "$NIC"
rm "$pidfile"
ip link set "$NIC" down
fi
done
fi
WAITING=1
while [ $WAITING -gt 0 ]; do
for pidfile in /var/run/dhclient.*.pid; do
NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
dhclient -r -1 -cf /etc/dhclient.conf -pf "$pidfile" "$NIC"
ip -4 addr flush dev "$NIC"
dhclient -cf /etc/dhclient.conf -nw -pf "$pidfile" "$NIC"
done
for pidfile in /var/run/dhclient6.*.pid; do
NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
dhclient -6 -r -1 -pf "$pidfile" -lf /var/lib/dhclient/dhclient6.leases "$NIC"
ip -6 addr flush dev "$NIC" scope global
ip -6 addr flush dev "$NIC" scope site
dhclient -6 -pf "$pidfile" -nw -lf /var/lib/dhclient/dhclient6.leases "$NIC"
done
echo -en "Waiting 10 seconds for DHCP changes to take effect \r"
for i in 9 8 7 6 5 4 3 2 1; do
sleep 1
echo -en "Waiting $i seconds for DHCP changes to take effect \r"
done
# restart rsyslog after dhclient
if [ -f /var/run/syslogd.pid ]; then
kill -TERM "$(cat /var/run/syslogd.pid)"
fi
if [ -f /var/run/rsyslogd.pid ]; then
kill -TERM "$(cat /var/run/rsyslogd.pid)"
fi
sleep 3
RSYSLOGD_VERSION="$(rsyslogd -v | grep -m1 "rsyslogd" | tr -s ' ' | cut -d" " -f2 | cut -d"." -f1)"
if [ $RSYSLOGD_VERSION -ge 8 ]; then
# Newer versions of rsyslogd do not support -c flag anymore
/sbin/rsyslogd
else
/sbin/rsyslogd -c4
fi
WAITING=0
if [ ! -z "$FORCENICS" ]; then
#for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep "$FORCENICS"`; do
for nic in $(ip -oneline link show |grep -i ether |awk -F ':' '{print $2}'|grep -o "[^ ]\+\( \+[^ ]\+\)*"|egrep "$FORCENICS"); do
# if ! ifconfig $nic|grep "inet addr" > /dev/null; then
if ! ip -4 -oneline addr show "$nic"|grep -qi inet; then
WAITING=1
fi
done
if [ $WAITING -gt 0 ]; then
delay=30
while [ $delay -gt 0 ]; do
echo -en "Not all of the nics $FORCENICS managed to acquire an address, retrying in $delay seconds... \r"
done
echo " \r"
fi
fi
done
echo "Done waiting ";
#/etc/init.d/S11stunnel #redo stunnel config
#exec /etc/init.d/S99xcat.sh