Rescue extension for TinyIPA with DHCP network
The patch adds the support for rescue mode with DHCP network in TinyIPA. Change-Id: I10cdb47eb3815db097bb3088d9dd4804b9d6a5d0 Depends-On: I9b4c1278dc5fab7888fbfe586c15e31ed3958978 Partial-Bug: #1526449
This commit is contained in:
parent
5ee16ee2e8
commit
71c89c99fa
@ -23,9 +23,46 @@ if ! type "ironic-python-agent" > /dev/null ; then
|
||||
python /tmp/get-pip.py --no-wheel --no-index --find-links=file:///tmp/wheelhouse ironic_python_agent
|
||||
fi
|
||||
|
||||
# Create ipa-rescue-config directory for rescue password
|
||||
sudo mkdir -p /etc/ipa-rescue-config
|
||||
|
||||
export PYTHONOPTIMIZE=1
|
||||
|
||||
# Run IPA
|
||||
echo "Starting Ironic Python Agent:"
|
||||
date
|
||||
ironic-python-agent 2>&1 | tee /var/log/ironic-python-agent.log
|
||||
|
||||
|
||||
create_rescue_user() {
|
||||
crypted_pass=$(cat /etc/ipa-rescue-config/ipa-rescue-password)
|
||||
sudo adduser rescue -D -G root # no useradd
|
||||
echo "rescue:$crypted_pass" | sudo chpasswd -e
|
||||
sudo sh -c "echo \"rescue ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers" # no suooers.d in tiny core.
|
||||
|
||||
# Restart sshd with allowing password authentication
|
||||
sudo sed -i -e 's/^PasswordAuthentication no/PasswordAuthentication yes/' /usr/local/etc/ssh/sshd_config
|
||||
sudo /usr/local/etc/init.d/openssh restart
|
||||
}
|
||||
|
||||
# Setup DHCP network
|
||||
configure_dhcp_network() {
|
||||
for pidfile in `ls /var/run/udhcpc/*.pid`; do
|
||||
kill `cat $pidfile`
|
||||
done
|
||||
|
||||
# NOTE(TheJulia): We may need to add a short wait here as
|
||||
# network interface plugging actions may not be asynchronous.
|
||||
INTERFACES=$(ip -o link |grep "LOWER_UP"|cut -f2 -d" "|sed 's/://'|grep -v "lo")
|
||||
for interface in $INTERFACES; do
|
||||
pidfile="/var/run/udhcpc/${interface}.pid"
|
||||
/sbin/udhcpc -b -p ${pidfile} -i ${interface} -s /opt/udhcpc.script >> /var/log/udhcpc.log 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
if [ -f /etc/ipa-rescue-config/ipa-rescue-password ]; then
|
||||
create_rescue_user || exit 0
|
||||
configure_dhcp_network || exit 0
|
||||
else
|
||||
echo "IPA has exited. No rescue password file was defined."
|
||||
fi
|
||||
|
@ -141,6 +141,9 @@ cleanup_tce "$DST_DIR"
|
||||
# Copy bootlocal.sh to opt
|
||||
sudo cp "$WORKDIR/build_files/bootlocal.sh" "$FINALDIR/opt/."
|
||||
|
||||
# Copy udhcpc.script to opt
|
||||
sudo cp "$WORKDIR/udhcpc.script" "$FINALDIR/opt/"
|
||||
|
||||
# Disable ZSwap
|
||||
sudo sed -i '/# Main/a NOZSWAP=1' "$FINALDIR/etc/init.d/tc-config"
|
||||
# sudo cp $WORKDIR/build_files/tc-config $FINALDIR/etc/init.d/tc-config
|
||||
|
44
imagebuild/tinyipa/udhcpc.script
Normal file
44
imagebuild/tinyipa/udhcpc.script
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
||||
|
||||
# file created to be used for static network configuration as well
|
||||
|
||||
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
||||
|
||||
RESOLV_CONF="/etc/resolv.conf"
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
|
||||
case "$1" in
|
||||
deconfig)
|
||||
/sbin/ifconfig $interface 0.0.0.0
|
||||
;;
|
||||
|
||||
renew|bound)
|
||||
/sbin/ifconfig $interface up
|
||||
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
|
||||
if [ -n "$router" ] ; then
|
||||
echo "deleting routers"
|
||||
while route del default gw 0.0.0.0 dev $interface ; do
|
||||
:
|
||||
done
|
||||
|
||||
metric=0
|
||||
for i in $router ; do
|
||||
route add default gw $i dev $interface metric $((metric++))
|
||||
done
|
||||
fi
|
||||
|
||||
echo -n > $RESOLV_CONF
|
||||
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
|
||||
for i in $dns ; do
|
||||
echo adding dns $i
|
||||
echo nameserver $i >> $RESOLV_CONF
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user