summaryrefslogtreecommitdiff
path: root/imagebuild
diff options
context:
space:
mode:
Diffstat (limited to 'imagebuild')
-rw-r--r--imagebuild/tinyipa/Makefile1
-rwxr-xr-ximagebuild/tinyipa/add-ssh-tinyipa.sh19
-rwxr-xr-ximagebuild/tinyipa/build_files/bootlocal.sh37
-rwxr-xr-ximagebuild/tinyipa/finalise-tinyipa.sh3
-rw-r--r--imagebuild/tinyipa/udhcpc.script44
5 files changed, 90 insertions, 14 deletions
diff --git a/imagebuild/tinyipa/Makefile b/imagebuild/tinyipa/Makefile
index 7fa83d72..ad0bf47b 100644
--- a/imagebuild/tinyipa/Makefile
+++ b/imagebuild/tinyipa/Makefile
@@ -27,6 +27,7 @@ clean_build:
sudo -v
sudo rm -rf tinyipabuild
sudo rm -rf tinyipafinal
+ sudo rm -rf tinyipaaddssh
rm -f *tinyipa*.vmlinuz
rm -f *tinyipa*.gz
rm -f *tinyipa*.sha256
diff --git a/imagebuild/tinyipa/add-ssh-tinyipa.sh b/imagebuild/tinyipa/add-ssh-tinyipa.sh
index a1de3506..c1372e0a 100755
--- a/imagebuild/tinyipa/add-ssh-tinyipa.sh
+++ b/imagebuild/tinyipa/add-ssh-tinyipa.sh
@@ -19,24 +19,16 @@
set -ex
WORKDIR=$(readlink -f $0 | xargs dirname)
-REBUILDDIR="$WORKDIR/rebuild"
+REBUILDDIR="$WORKDIR/tinyipaaddssh"
DST_DIR=$REBUILDDIR
source ${WORKDIR}/common.sh
-source ${WORKDIR}/build_files/tc-mirror.sh
TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-}
BRANCH_PATH=${BRANCH_PATH:-master}
TINYIPA_RAMDISK_FILE=${TINYIPA_RAMDISK_FILE:-}
SSH_PUBLIC_KEY=${SSH_PUBLIC_KEY:-}
-TC=1001
-STAFF=50
-
-CHROOT_PATH="/tmp/overides:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-CHROOT_CMD="sudo chroot $REBUILDDIR /usr/bin/env -i PATH=$CHROOT_PATH http_proxy=$http_proxy https_proxy=$https_proxy no_proxy=$no_proxy"
-TC_CHROOT_CMD="sudo chroot --userspec=$TC:$STAFF $REBUILDDIR /usr/bin/env -i PATH=$CHROOT_PATH http_proxy=$http_proxy https_proxy=$https_proxy no_proxy=$no_proxy"
-
function validate_params {
echo "Validating location of public SSH key"
if [ -n "$SSH_PUBLIC_KEY" ]; then
@@ -56,16 +48,14 @@ function validate_params {
echo "Failed to find neither provided nor default SSH key"
exit 1
fi
-
- choose_tc_mirror
}
function get_tinyipa {
if [ -z $TINYIPA_RAMDISK_FILE ]; then
mkdir -p $WORKDIR/build_files/cache
cd $WORKDIR/build_files/cache
- wget -N https://tarballs.openstack.org/ironic-python-agent/tinyipa/files/tinyipa-${BRANCH_PATH}.gz
- TINYIPA_RAMDISK_FILE="$WORKDIR/build_files/cache/tinyipa-${BRANCH_PATH}.gz"
+ wget -N https://tarballs.openstack.org/ironic-python-agent/tinyipa/files/tinyipa${BRANCH_EXT}.gz
+ TINYIPA_RAMDISK_FILE="$WORKDIR/build_files/cache/tinyipa${BRANCH_EXT}.gz"
fi
}
@@ -132,6 +122,7 @@ function rebuild_ramdisk {
sudo -v
+validate_params
get_tinyipa
unpack_ramdisk
setup_tce "$DST_DIR"
@@ -144,5 +135,5 @@ install_ssh
# with 'sudo' afterwards
fix_python_optimize
-cleanup_tce $DST_DIR
+cleanup_tce "$DST_DIR"
rebuild_ramdisk
diff --git a/imagebuild/tinyipa/build_files/bootlocal.sh b/imagebuild/tinyipa/build_files/bootlocal.sh
index dbc03ed0..a94a67d5 100755
--- a/imagebuild/tinyipa/build_files/bootlocal.sh
+++ b/imagebuild/tinyipa/build_files/bootlocal.sh
@@ -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
diff --git a/imagebuild/tinyipa/finalise-tinyipa.sh b/imagebuild/tinyipa/finalise-tinyipa.sh
index 972681e1..ed24ba4b 100755
--- a/imagebuild/tinyipa/finalise-tinyipa.sh
+++ b/imagebuild/tinyipa/finalise-tinyipa.sh
@@ -144,6 +144,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
diff --git a/imagebuild/tinyipa/udhcpc.script b/imagebuild/tinyipa/udhcpc.script
new file mode 100644
index 00000000..1de671ba
--- /dev/null
+++ b/imagebuild/tinyipa/udhcpc.script
@@ -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
+