bdisk/extra/pre-build.d/usr/lib/initcpio/hooks/ssh

68 lines
1.4 KiB
Plaintext
Raw Normal View History

2014-12-19 14:13:30 -05:00
#!/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
}