Merge "Rescue extension for TinyIPA with DHCP network"

This commit is contained in:
Zuul 2018-01-26 19:59:05 +00:00 committed by Gerrit Code Review
commit c549f2cb93
3 changed files with 84 additions and 0 deletions

View File

@ -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

View File

@ -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

View 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