-------------------- ---------- cat ltihook -------------------- -----

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#------------------------------
#cat ltihook
#------------------------------
#!/bin/sh -e
# initramfs hook for liteinstaller
PREREQ=""
# Output pre-requisites
prereqs()
{
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
inject_pkg()
{
echo "inject_pkg $1"
apt-get install $1
copy_exec_ex "`dpkg -L $1 |grep -v /man |grep -v /doc | grep ^/[^.]`"
}
copy_exec_ex()
{
echo "$1" |
while read dir ; do
if [ -d $dir ] ; then
continue
fi
if [ -e $dir ] ; then
ddir=`dirname $dir`
echo "copy_exec $dir ${DESTDIR}$ddir"
mkdir -p "${DESTDIR}$ddir"
if [ -x "$dir" ] ; then
copy_exec "$dir" "$ddir"
else
cp -d "$dir" "${DESTDIR}$ddir"
fi
fi
done
}
list="/bin/bunzip2
/bin/tar
/bin/chown
/bin/chmod
/bin/nano
/usr/bin/ar
/usr/bin/perl
/usr/bin/md5sum
/usr/bin/wc
/usr/bin/head
/sbin/lvm
/sbin/fdisk
/sbin/mkfs
/sbin/mkfs.ext3
/sbin/mkfs.vfat
/sbin/badblocks
/sbin/blkid
/etc/inputrc
/bin/df
/sbin/mkfs.reiserfs"
cp -fdr /lib/terminfo $DESTDIR/lib/
inject_pkg grub-pc
inject_pkg grub-common
inject_pkg debootstrap
inject_pkg dialog
dpkg --print-installation-architecture>$DESTDIR/usr/share/debootstrap/arch
copy_exec_ex "$list"
rm -rf $DESTDIR/usr/share/doc
rm -rf $DESTDIR/usr/share/man
echo "Done."
#------------------------------
#cat mkinitrd.sh
#------------------------------
#!/bin/sh
make_initrd()
{
INITRD_OUT="$1"
TMP_DIR="$2"
mkdir -p "$TMP_DIR/scripts"
mkdir -p "$TMP_DIR/hooks"
cp -rap /etc/initramfs-tools/* $TMP_DIR/
d="./user_initrd"
if [ -d "$d" ] ; then
cp -rap $d/* $TMP_DIR/
fi
cp -rap ./ltihook $TMP_DIR/hooks/
cat > "$TMP_DIR/initramfs.conf" << EOF
MODULES=most
BUSYBOX=y
BOOT=liteinstaller
DEVICE=eth0
NFSROOT=auto
EOF
mkinitramfs -d "$TMP_DIR" -o "$INITRD_OUT"
rm -rf "$TMP_DIR"
cp /vmlinuz $(dirname "$INITRD_OUT")
}
if [ ! "$1" ]; then
echo "Makes initrd image in directory"
echo "example: $0 initrd.gz"
exit 1
else
TMP_DIR=$(mktemp -d "/tmp/irmfs_tmp.XXXXXX")
make_initrd "$1" "$TMP_DIR"
fi