fix broken initramfs tmpfs and refactor initramfs init sequence
This commit is contained in:
@@ -104,7 +104,7 @@ func init() {
|
||||
fmt.Fprintf(c, "nodeprofiles:\n")
|
||||
fmt.Fprintf(c, " default:\n")
|
||||
fmt.Fprintf(c, " comment: This profile is automatically included for each node\n")
|
||||
fmt.Fprintf(c, " kernel args: crashkernel=no quiet\n")
|
||||
fmt.Fprintf(c, " kernel args: crashkernel=no vga=791 rootfstype=ramfs quiet\n")
|
||||
fmt.Fprintf(c, "nodes: {}\n")
|
||||
|
||||
c.Close()
|
||||
|
||||
@@ -4,86 +4,36 @@
|
||||
# know what you are doing and even then you should make a backup.
|
||||
#
|
||||
# Edit at your own risk! DANGER DANGER.
|
||||
mkdir /newroot
|
||||
mount wwroot /newroot -t tmpfs
|
||||
|
||||
cat <<EOF >/newroot/wwinit
|
||||
#!/bin/sh
|
||||
|
||||
mount -t proc none /proc
|
||||
mount -t sysfs none /sys
|
||||
echo "Warewulf v4 is now booting"
|
||||
|
||||
chmod 755 /warewulf/wwinit
|
||||
|
||||
echo "Mounting up kernel file systems"
|
||||
mkdir /proc /dev /sys /run 2>/dev/null
|
||||
mount -t proc proc /proc
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t tmpfs tmpfs /run
|
||||
|
||||
# This will eventually be optional
|
||||
if true; then
|
||||
if [ -f "/etc/pam.d/system-auth" ]; then
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/system-auth
|
||||
fi
|
||||
echo "Checking for 'rootfstype=ramfs'"
|
||||
ROOTFSTYPE=`stat -f -c "%T" /`
|
||||
|
||||
if [ -f "/etc/pam.d/password-auth" ]; then
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/password-auth
|
||||
fi
|
||||
|
||||
if [ -f "/etc/pam.d/common-account" ]; then
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/common-account
|
||||
fi
|
||||
if test "$ROOTFSTYPE" == "ramfs"; then
|
||||
echo "Running on ramfs, setting up tmpfs"
|
||||
mkdir /newroot
|
||||
mount wwroot /newroot -t tmpfs
|
||||
echo "Moving RAMFS to TMPFS"
|
||||
tar -cf - --exclude ./proc --exclude ./sys --exclude ./dev --exclude ./newroot . | tar -xf - -C /newroot
|
||||
mkdir /newroot/proc /newroot/dev /newroot/sys /newroot/run 2>/dev/null
|
||||
echo "Calling switch_root() and invoking WW Init"
|
||||
exec /sbin/switch_root /newroot /warewulf/wwinit
|
||||
else
|
||||
echo "Running on tmpfs"
|
||||
echo "Calling WW Init"
|
||||
exec /warewulf/wwinit
|
||||
fi
|
||||
|
||||
/sbin/ip link set dev lo up
|
||||
|
||||
nohup /warewulf/bin/wwclient >/var/log/wwclient.log 2>&1 </dev/null &
|
||||
|
||||
if test -x /sbin/load_policy && test -x /sbin/restorecon; then
|
||||
/sbin/load_policy -i
|
||||
/sbin/restorecon -r /
|
||||
fi
|
||||
|
||||
echo "Calling {{$.Init}}..."
|
||||
echo
|
||||
|
||||
rm /wwinit
|
||||
chmod 755 /
|
||||
|
||||
sleep 2
|
||||
exec {{$.Init}}
|
||||
EOF
|
||||
chmod 755 /newroot/wwinit
|
||||
|
||||
tar -cf - --exclude /proc --exclude /sys --exclude /dev --exclude /newroot . | tar -xf - -C /newroot
|
||||
mount proc /proc -t proc
|
||||
exec /sbin/switch_root /newroot /wwinit
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/bin/bash
|
||||
|
||||
# Considering what to do if we are operating on a read only root
|
||||
if false; then
|
||||
mkdir -p /mnt/.lowerdir
|
||||
mkdir -p /mnt/.overlaytmp
|
||||
mount -t tmpfs -o size=10M none /mnt/.overlaytmp
|
||||
mkdir -p /mnt/.overlaytmp/upperdir
|
||||
mkdir -p /mnt/.overlaytmp/workdir
|
||||
mkdir -p /mnt/.newroot
|
||||
|
||||
mount -t overlay -o lowerdir=/mnt/.lowerdir,upperdir=/mnt/.overlaytmp/upperdir,workdir=/mnt/.overlaytmp/workdir none /mnt/.newroot
|
||||
|
||||
cd /mnt/.newroot
|
||||
pivot_root . /mnt
|
||||
|
||||
fi
|
||||
|
||||
nohup /warewulf/bin/wwclient >/var/log/wwclient.log 2>&1 </dev/null &
|
||||
|
||||
nohup /ipmi >/var/log/ipmi.log 2>&1 </dev/null &
|
||||
|
||||
chmod 755 /
|
||||
echo "Calling {{$.Init}}..."
|
||||
echo
|
||||
|
||||
sleep 2
|
||||
exec {{$.Init}}
|
||||
echo "We should never ever get here, but since we did, it means something went wrong so rebooting"
|
||||
/sbin/reboot
|
||||
4
overlays/system/default/warewulf/init.d/20-localhost
Normal file
4
overlays/system/default/warewulf/init.d/20-localhost
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Bringing up lo:127.0.0.1"
|
||||
/sbin/ip link set dev lo up
|
||||
@@ -7,8 +7,6 @@ error_exit() {
|
||||
|
||||
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
|
||||
set -x
|
||||
|
||||
IP="{{$.IpmiIpaddr}}"
|
||||
NETMASK="{{$.IpmiNetmask}}"
|
||||
[ -z "$NETMASK" ] && NETMASK="{{$.NetDevs.eth0.Netmask}}"
|
||||
24
overlays/system/default/warewulf/init.d/75-vnfs_fixes
Normal file
24
overlays/system/default/warewulf/init.d/75-vnfs_fixes
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
|
||||
# This will eventually be optional
|
||||
if true; then
|
||||
if [ -f "/etc/pam.d/system-auth" ]; then
|
||||
echo "FIXING: system-auth"
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/system-auth
|
||||
fi
|
||||
|
||||
if [ -f "/etc/pam.d/password-auth" ]; then
|
||||
echo "FIXING: password-auth"
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/password-auth
|
||||
fi
|
||||
|
||||
if [ -f "/etc/pam.d/common-account" ]; then
|
||||
echo "FIXING: common-account"
|
||||
sed -i -e '/^account.*pam_unix\.so\s*$/s/\s*$/\ broken_shadow/' /etc/pam.d/common-account
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
chmod 755 /
|
||||
4
overlays/system/default/warewulf/init.d/80-wwclient
Normal file
4
overlays/system/default/warewulf/init.d/80-wwclient
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Starting wwclient"
|
||||
nohup /warewulf/bin/wwclient >/var/log/wwclient.log 2>&1 </dev/null &
|
||||
17
overlays/system/default/warewulf/init.d/90-selinux
Normal file
17
overlays/system/default/warewulf/init.d/90-selinux
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
if test -f "/etc/sysconfig/selinux"; then
|
||||
. /etc/sysconfig/selinux
|
||||
if test "\$SELINUX" == "disabled"; then
|
||||
echo "Skipping SELinux setup per /etc/sysconfig/selinux"
|
||||
elif grep -q "selinux=0" /proc/cmdline; then
|
||||
echo "Skipping SELinux setup per kernel command line"
|
||||
else
|
||||
echo "Setting up SELinux"
|
||||
/sbin/load_policy -i
|
||||
/sbin/restorecon -r /
|
||||
fi
|
||||
else
|
||||
echo "Skipping SELinux setup"
|
||||
fi
|
||||
19
overlays/system/default/warewulf/wwinit.ww
Normal file
19
overlays/system/default/warewulf/wwinit.ww
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Hello from WWINIT"
|
||||
|
||||
for i in /warewulf/init.d/*; do
|
||||
NAME=`basename $i`
|
||||
echo "Launching: $NAME"
|
||||
sh "$i"
|
||||
done
|
||||
|
||||
/bin/bash
|
||||
|
||||
echo "Cleaning up"
|
||||
|
||||
echo "Calling {{$.Init}}..."
|
||||
echo
|
||||
|
||||
sleep 2
|
||||
exec {{$.Init}}
|
||||
Reference in New Issue
Block a user