I did some testing for dzz. Bottom line: I think we should just edit 9990-hooks and be done with it.
(I apologize for the big code and quote blocks, but I'm too lazy to edit out all the slashes.)
add to cmdline -
hooks=file:///lib/live/mount/medium/live/myscript
myscript must be in place and executable. In this case, it contains:
touch /home/user/Desktop/testhooks
/lib/live/config/9990-hooks has an error that prevents it from using the hook.
Create /lib/live/config/9991-hooks with correction, and it will execute myscript. I've got the testhooks file on my desktop when I log in.
As a test, I also created 9992-hooks:
- Code: Select all
#!/bin/sh
if [ -n "${LIVE_HOOKS}" ]; then
echo "LIVE_HOOKS = ${LIVE_HOOKS}" > /home/user/Desktop/livehooks
elif [ -z "${LIVE_HOOKS}" ]; then
echo "LIVE_HOOKS is null." > /home/user/Desktop/nohooks
else
echo "Something else is going on." > /home/user/Desktop/something_else
fi
echo "${_CMDLINE}" > /home/user/Desktop/cmdline
exit 0
Two files appeared on the desktop - nohooks and cmdline
${_CMDLINE} is set in /lib/live/config thus:
_CMDLINE="$(cat /proc/cmdline)"
Why does _CMDLINE exist outside the script in which it gets its value?
I tried exporting LIVE_HOOKS in the first script, so it would be available to the second, but that didn't work.
9991-hooks:
- Code: Select all
#!/bin/sh
## live-config(7) - System Configuration Scripts
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#### This version was modified by dzz and fsr
Hooks ()
{
echo -n " hooks"
for _PARAMETER in ${_CMDLINE}
do
case "${_PARAMETER}" in
live-config.hooks=*|hooks=*)
LIVE_HOOKS="${_PARAMETER#*hooks=}"
;;
esac
done
if [ -z "${LIVE_HOOKS}" ]
then
return
fi
# export LIVE_HOOKS # This didn't work
Process_hooks
}
Process_hooks ()
{
if [ -z "${LIVE_HOOKS}" ]
then
return
fi
for _HOOK in $(echo ${LIVE_HOOKS} | sed -e 's/|/ /g')
do
case "${_HOOK}" in
filesystem)
if ls /lib/live/config-hooks/* 2>&1
then
_HOOKS="${_HOOKS} $(for _FILE in /lib/live/config-hooks/*; do echo file://${_FILE}; done)"
fi
;;
medium)
if ls /lib/live/mount/medium/live/config-hooks/* 2>&1
then
_HOOKS="${_HOOKS} $(for _FILE in /lib/live/mount/medium/live/config-hooks/*; do echo file://${_FILE}; done)"
fi
;;
*)
_HOOKS="${_HOOKS} ${_HOOK}"
;;
esac
done
for _HOOK in ${_HOOKS}
do
_TMPFILE="$(mktemp -t live-config.XXXXXXXX)"
if echo "${_HOOK}" | grep -qs file://
then
# local file
cp $(echo ${_HOOK} | sed 's|file://||') "${_TMPFILE}"
else
# remote file
Start_network
wget --quiet "${_HOOK}" -O "${_TMPFILE}"
fi
chmod 0755 "${_TMPFILE}"
./"${_TMPFILE}"
rm -f "${_TMPFILE}"
done
}
Hooks