finishing up booting/burning/flashing docs for netboot

This commit is contained in:
2016-12-19 01:16:09 -05:00
parent 2db5a8f0f6
commit d6f76dbfdc
8 changed files with 101 additions and 188 deletions

View File

@@ -51,7 +51,7 @@ FILES="/usr/bin/pkill"
#HOOKS="base udev autodetect modconf block filesystems keyboard fsck"
#HOOKS="base udev memdisk archiso_shutdown archiso modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd"
#HOOKS="base udev memdisk archiso_shutdown archiso-custom modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_http_custom archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd"
HOOKS="base udev memdisk archiso_shutdown archiso modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd"
HOOKS="base udev memdisk archiso_shutdown archiso modconf net archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd"
#HOOKS="base memdisk systemd archiso_shutdown archiso modconf ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd"
# COMPRESSION

View File

@@ -23,6 +23,7 @@ lz4
lzo
lzop
mkinitcpio-nfs-utils
mkinitcpio-utils
ms-sys
mtools
net-tools

View File

@@ -177,8 +177,8 @@ then
rm -f /root/pre-build.arch.sh
fi
# Cleanup
#yes | pacman -Scc # doesn't parse yes(1) output correctly, it seems.
# TODO: look into https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Removing_unused_packages_.28orphans.29
mkinitcpio -p linux
paccache -rk0
localepurge-config
localepurge

View File

@@ -1,67 +0,0 @@
#!/usr/bin/ash
run_hook ()
{
local line i address netmask gateway dns0 dns1 rootserver rootpath defaultrootpath defaultserver
: > /ip_opts
if [ -z "${ip}" -a -n "${nfsaddrs}" ]; then
ip="${nfsaddrs}"
fi
if [ -n "${ip}" ]; then
# setup network and save some values
ipconfig "ip=${ip}" | while read line; do
if [ "${line#"IP-Config:"}" != "${line}" ]; then
continue
fi
line="$(echo ${line} | sed -e 's/ :/:/g;s/: /=/g')"
for i in ${line}; do
case "${i}" in
address=*)
echo "${i}" >> /ip_opts
;;
netmask=*)
echo "${i}" >> /ip_opts
;;
gateway=*)
echo "${i}" >> /ip_opts
;;
dns0=*)
echo "${i}" >> /ip_opts
;;
dns1=*)
echo "${i}" >> /ip_opts
;;
rootserver=*)
echo "${i}" >> /ip_opts
;;
rootpath=*)
echo "${i}" >> /ip_opts
;;
esac
done
done
echo "device=$(echo ${ip} | cut -d: -f6)" >> /ip_opts
fi
. /ip_opts
echo "IP-Config: ${address}/${netmask}"
echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}"
[ -d /dev/pts ] || mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
echo "Starting dropbear"
/usr/sbin/dropbear -E
}
run_cleanuphook ()
{
pkill -9 dropbear
}

View File

@@ -1,111 +0,0 @@
#!/bin/bash
get_fingerprint() {
local keyfile="$1"
dropbearkey -y -f "${keyfile}" | sed -n '/^Fingerprint:/ {s/Fingerprint: *//; p}'
}
display_fingerprints() {
local keyfile
for keyfile in "/etc/dropbear/dropbear_dss_host_key" "/etc/dropbear/dropbear_rsa_host_key" ; do
if [ ! -r "${keyfile}" ] ; then
return 1
fi
echo "$(basename "${keyfile}") : $(get_fingerprint "${keyfile}")"
done
}
copy_openssh_keys() {
local osshrsa="/etc/ssh/ssh_host_rsa_key"
local osshdsa="/etc/ssh/ssh_host_dsa_key"
local dbpre="/etc/dropbear/dropbear_"
[ -f "$osshrsa" ] && [ -f "$osshdsa" ] || return 1
dropbearconvert openssh dropbear $osshrsa ${dbpre}rsa_host_key
dropbearconvert openssh dropbear $osshdsa ${dbpre}dss_host_key
}
generate_keys() {
local keyfile keytype
for keytype in dss rsa ; do
keyfile="/etc/dropbear/dropbear_${keytype}_host_key"
echo "Generating ${keytype} host key for dropbear ..."
dropbearkey -t "${keytype}" -f "${keyfile}"
done
}
make_etc_passwd() {
echo 'root:x:0:0:root:/:/bin/ash' > "${TMPDIR}"/passwd
}
build ()
{
#
# Begin real processing
#
# Are we even needed?
if [ ! -e "/etc/dropbear/root_key" ]; then
echo "There is no root key in /etc/dropbear/root_key existent; exit"
return 0
fi
# if TMPDIR is set leave it alone otherwise set
[ -z $TMPDIR ] && TMPDIR='/tmp/dropbear_initrd_encrypt'
# check if TMPDIR exsists if not make it
[ -d $TMPDIR ] || mkdir -p $TMPDIR
umask 0022
[ -d /etc/dropbear ] && mkdir -p /etc/dropbear
display_fingerprints || copy_openssh_keys || generate_keys
[ -e "${TMPDIR}/passwd" ] && ( grep -q -e '^root:' "${TMPDIR}/passwd" ) || make_etc_passwd
add_checked_modules "/drivers/net/"
add_binary "/usr/bin/rm"
add_binary "/usr/bin/dropbear"
add_binary "/usr/bin/killall"
add_binary "/usr/bin/pkill"
echo '/bin/ash' > "${TMPDIR}"/shells
add_file "${TMPDIR}/shells" "/etc/shells"
cat /etc/dropbear/root_key > "${TMPDIR}"/authorized_keys
add_dir "/.ssh"
add_file "${TMPDIR}/authorized_keys" "/.ssh/authorized_keys"
add_file "${TMPDIR}/passwd" "/etc/passwd"
add_dir "/etc/dropbear"
add_file "/etc/dropbear/dropbear_rsa_host_key"
add_file "/etc/dropbear/dropbear_dss_host_key"
add_file "/lib/libnss_files.so.2"
add_binary "ip" "/sbin/ip"
add_dir "/var/run"
touch "${TMPDIR}"/lastlog
add_dir "/var/log"
add_file "${TMPDIR}/lastlog" "/var/log/lastlog"
add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig"
# cleanup
rm "${TMPDIR}/shells"
rm "${TMPDIR}/authorized_keys"
rm "${TMPDIR}/passwd"
rm "${TMPDIR}/lastlog"
add_runscript
}
help ()
{
cat<<HELPEOF
Allow SSH access to an initial environment for debugging.
HELPEOF
}