Re: Writing udebs
Michael S. Peek wrote:
Hello again gurus,
I'm attempting to update a couple of small udebs to work under etch
and I've run into a snag. For some reason I seem to be killing
/sbin/debian-installer with my udebs and I don't know what's causing it.
Aha! Got it!
The problem was a combination of old script that I had ripped from
sarge's preseed stuff and the use of a db_stop command in my script.
The correct answer is:
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
. /lib/preseed/preseed.sh
___my_name=$(basename $0 ".postinst")
log () {
while [ $# -gt 0 ]; do
logger -t "${___my_name}" -- "$@"
shift
done
}
log_output () {
while read line; do
log "| ${line}"
done
}
preseed_fetch () {
local url="${1}"
local dst="${2}"
local src="${1#file://*}"
if [ ! -e "${src}" ] || ! cp "${src}" "${dst}" ; then
return 1
else
return 0
fi
}
set_netcfg_interface () {
db_register debian-installer/dummy netcfg/choose_interface
db_set netcfg/choose_interface "${1}"
db_subst netcfg/choose_interface ID netcfg/choose_interface
db_fset netcfg/choose_interface seen true
}
log "Searching for network card(s)..."
dev_list=$( \
ifconfig -a 2>&1 \
| grep '^[^ ]' \
| cut -d' ' -f1 \
| grep -v '^lo$' \
)
db_get multi-netcfg/preseed-dir
dir="${RET}"
log "Auto-NetCfg Dir: ${dir}"
for dev in ${dev_list}; do
hwaddr=$( \
ifconfig -a \
| grep ${dev} \
| grep HWaddr \
| cut -b39- \
| sed 's, ,,g' \
)
log "Found device: ${dev} (HWaddr: ${hwaddr})"
file=$(echo "${hwaddr}" | sed 's,:,-,g')
log "Searching for File or Dir: ${dir}/${file}"
if [ -f "${dir}/${file}" ]; then
log "Found file"
set_netcfg_interface ${dev}
preseed_location "file://${dir}/${file}"
elif [ -d "${dir}/${file}" ]; then
log "Found directory"
set_netcfg_interface ${dev}
ls -1 "${dir}/${file}/" \
| while read line; do
if [ -f "${line}" ]; then
log "Reading file: ${line}"
preseed_location "file://${line}"
else
log "Skipping subdirectory: ${line}"
fi
done
else
log "No such file or directory found"
fi
done
# vim:ts=2:shiftwidth=2:filetype=sh:syntax=sh:
Reply to: