diff options
Diffstat (limited to 'hooks')
-rw-r--r-- | hooks/consolefont | 10 | ||||
-rw-r--r-- | hooks/keymap | 17 | ||||
-rw-r--r-- | hooks/net | 72 | ||||
-rw-r--r-- | hooks/raid | 9 | ||||
-rw-r--r-- | hooks/resume | 32 | ||||
-rw-r--r-- | hooks/udev | 8 |
6 files changed, 128 insertions, 20 deletions
diff --git a/hooks/consolefont b/hooks/consolefont new file mode 100644 index 0000000..f35869e --- /dev/null +++ b/hooks/consolefont @@ -0,0 +1,10 @@ +# vim: set ft=sh: + +run_hook () +{ + if [ -e /consolefont.psfu ]; then + msg -n ":: Loading console font..." + /usr/sbin/setfont -C /dev/console /consolefont.psfu + msg "done." + fi +} diff --git a/hooks/keymap b/hooks/keymap new file mode 100644 index 0000000..9557c26 --- /dev/null +++ b/hooks/keymap @@ -0,0 +1,17 @@ +# vim: set ft=sh: +run_hook () +{ + if [ -e /keymap.bin ]; then + msg -n ":: Loading keymap..." + . /keymap.utf8 + if [ "${UTF8}" = "yes" ]; then + /usr/bin/kbd_mode -u -C /dev/console + printf "\033%%G" >> /dev/console + else + /usr/bin/kbd_mode -a -C /dev/console + printf "\033%%@" >> /dev/console + fi + /sbin/loadkmap < /keymap.bin + msg "done." + fi +} diff --git a/hooks/net b/hooks/net new file mode 100644 index 0000000..9b97e39 --- /dev/null +++ b/hooks/net @@ -0,0 +1,72 @@ +# vim: set ft=sh: +run_hook () +{ + local line i address rootserver rootpath + + : > /ip_opts + + if [ -n "${ip}" ]; then + # setup network and save some values + ipconfig "${ip}" | while read line; do + # echo ":: ${line}" + 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 + + . /ip_opts + + echo "IP-Config: ${address}/${netmask}" + echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}" + + # calculate nfs_server, nfs_path and nfs_option for later nfs mount + if [ "${root}" = "/dev/nfs" -o "${nfsroot}" != "" ]; then + # default rootpath + if [ "${rootpath}" = "" ]; then + rootpath="/tftpboot/${address}" + fi + + # parse nfsroot + line="${nfsroot}" + nfs_server="${line%%:*}" + [ "${nfs_server}" = "${line}" ] && nfs_server="${rootserver}" + line="${line#*:}" + nfs_path="${line%%,*}" + line="${line#"${nfs_path}"}" + [ "${nfs_path}" = "" ] && nfs_path="${rootpath}" + nfs_option="${line#","}" + + # ensure root and filesystem type are set proper for nfs boot + root="/dev/nfs" + rootfstype="nfs" + + echo "NFS-root: ${nfs_server}:${nfs_path}" + fi + fi +} diff --git a/hooks/raid b/hooks/raid deleted file mode 100644 index cd1a920..0000000 --- a/hooks/raid +++ /dev/null @@ -1,9 +0,0 @@ -# vim: set ft=sh: -run_hook () -{ - #TODO scan for these somehow... - /sbin/modprobe -aq linear multipath raid0 raid1 raid456 raid10 >/dev/null 2>&1 - # md= can be specified multiple times. The simplistic commandline - # parsing does not handle this, so we will let mdassemble parse it - /bin/mdassemble ${CMDLINE} -} diff --git a/hooks/resume b/hooks/resume index 0632fed..f514eb6 100644 --- a/hooks/resume +++ b/hooks/resume @@ -3,18 +3,28 @@ run_hook () { fmtdevice () { echo "${1}:${2}"; } - if [ -n "${resume}" ] && poll_device "${resume}" ${rootdelay}; then - # Try resuming with tuxonice - tuxoniceroot="/sys/power/tuxonice" - if [ -d "${tuxoniceroot}" ]; then - echo ${resume} > ${tuxoniceroot}/resume - echo > ${tuxoniceroot}/do_resume + if [ -n "${resume}" ]; then + if echo ${resume} | grep -q ':'; then + # Tux-on-ice syntax: swap:/dev/sda2 or file:/dev/sda2:0xdeadbeef + resumedev="$(echo ${resume} | cut -d: -f2)" + else + # Classical syntax: just a device + resumedev="${resume}" fi - - # Try resuming with vanilla hibernation - if [ -e "/sys/power/resume" ]; then - eval $(/bin/parseblock "${resume}") - fmtdevice ${BLOCKDEVICE} > /sys/power/resume + if poll_device "${resumedev}" ${rootdelay}; then + if echo ${resume} | grep -q ':'; then + # Try resuming with tuxonice + tuxoniceroot="/sys/power/tuxonice" + if [ -d "${tuxoniceroot}" ]; then + echo ${resume} > ${tuxoniceroot}/resume + echo > ${tuxoniceroot}/do_resume + fi + else + # Try resuming with vanilla hibernation + if [ -e "/sys/power/resume" ]; then + printf "%d:%d" $(stat -Lc "0x%t 0x%T" ${resume}) > /sys/power/resume + fi + fi fi fi } diff --git a/hooks/udev b/hooks/udev new file mode 100644 index 0000000..57a90f7 --- /dev/null +++ b/hooks/udev @@ -0,0 +1,8 @@ +# vim: set ft=sh: +run_hook () +{ + msg -n ":: Triggering uevents..." + /sbin/udevadm trigger + /sbin/udevadm settle + msg "done." +} |