blob: 9777fc1dbacd0e577ed6584db030a8027283f9cb (
plain) (
blame)
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
|
#!/bin/bash
ROOT_DIR=$(dirname $(readlink -f $0))
SELF=$(readlink -f $0)
TMP_DIR="/tmp/pbstick-$$"
OUT_DEV=$1
if [ $(whoami) != "root" ]; then
echo "you should be root"
exit 1;
fi
if [ -z $OUT_DEV ]; then
echo "no outputdev specified - usage $0 [devicename of usbstick] (eg sdc for /dev/sdc)"
exit 1
fi
mkdir -p $TMP_DIR
match=$(grep --text --line-number '^PAYLOAD:$' $SELF | cut -d ':' -f 1)
payload_start=$((match + 1))
cd $TMP_DIR
tail -n +$payload_start $SELF | uudecode | tar -xjvf -
cd $ROOT_DIR
PATH="$PATH:$TMP_DIR/bin/"
for i in 1 2 3 4 5 6 7 8 9; do
umount /dev/${OUT_DEV}$i &> /dev/null
done
# create bootable vfat partition with 96cylinders and a ext3 partition for the
# rest of the stick
sfdisk /dev/${OUT_DEV} << EOF
,96,6,*
,,L
EOF
sync
# copy mbr to stick
dd bs=440 count=1 conv=notrunc if=$TMP_DIR/share/mbr.bin of=/dev/${OUT_DEV}
# create filesystems on newly createt partitions
mkfs.vfat -F 16 -n PBStick /dev/${OUT_DEV}1
mkfs.ext2 -L OpenSLX-Home /dev/${OUT_DEV}2
mkdir -p /media/openslx-stick /media/openslx-stick-usrhome
sync
mount /dev/${OUT_DEV}1 /media/openslx-stick
mount /dev/${OUT_DEV}2 /media/openslx-stick-usrhome
mkdir -p /media/openslx-stick/boot
cp -v $TMP_DIR/boot/* /media/openslx-stick/boot/
sync
umount /media/openslx-stick
umount /media/openslx-stick-usrhome
$TMP_DIR/bin/syslinux --install -d /boot -f /dev/${OUT_DEV}1
exit 0
|