done
# executables that we have to have
-exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed"
-lvmexe="/sbin/lvm"
-cryptexe="/sbin/cryptsetup"
+exe="bash mount mknod mkdir modprobe udevd udevadm nash pidof sleep chroot echo cat sed"
+lvmexe="lvm"
+cryptexe="cryptsetup"
# and some things that are nice for debugging
-debugexe="/bin/ls /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
+debugexe="ls ln ps grep more dmesg"
# udev things we care about
udevexe="/lib/udev/vol_id /lib/udev/console_init"
inst_simple() {
local src=$1 target="${initdir}${2:-$1}"
[[ -f $target ]] && return 0
- echo "Installing $src to $target"
mkdir -p "${target%/*}"
cp -fL "$src" "$target"
}
fi
}
-
+find_binary() {
+ local binpath="/bin /sbin /usr/bin /usr/sbin" p
+ [[ ${1##*/} = $1 ]] || { echo $1; return 0; }
+ for p in $binpath; do
+ [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
+ done
+ return 1
+}
# Same as above.
# If the file is a binary executable, install all its
inst "$realsrc" && ln -s "$realsrc" "$target"
}
+
# general purpose installation function
# Same args as above.
# Just tries to install as a binary, a shell script, then a simple data file.
echo "usage: inst <file> <root> [<destination file>]"
return 1
fi
- local src=$1 dest=${2:-$1}
+ local src=$(find_binary "$1") || {
+ echo "Cannot find requested file $1. Exiting."
+ exit 1
+ }
+ local dest=${2:-$src}
for x in inst_symlink inst_script inst_binary inst_simple; do
$x "$src" "$dest" && return 0
done