]> Raphaƫl G. Git Repositories - distgen/blob - genimg
Initial import
[distgen] / genimg
1 #! /bin/sh -xe
2
3 # Export safe locale
4 export LC_ALL=C
5
6 # Get distcook path
7 . config/distcook.conf
8
9 # Copy distcook root config
10 cp $DISTCOOK/root.conf config/
11
12 # Extract configuration
13 echo '#! /bin/sh -e' > lib/config.sh
14 cat config/*.conf | perl -pne 'if (/^#/) {undef $_;} else {s/^/export /}' >> lib/config.sh
15
16 # Source config
17 . lib/config.sh
18
19 # Test mapper entries
20 if [ -f "/dev/mapper/$SLASHNAME" -o -f "/dev/mapper/$DATANAME" ]; then
21 echo "Mapper name already exists, try to run:"
22 echo "cryptsetup close $SLASHNAME"
23 echo "cryptsetup close $DATANAME"
24 exit 1
25 fi
26
27 # Test loopa and loopb
28 if [ `losetup ${LOOPA} >/dev/null 2>&1; echo $?` -ne 1 -o `losetup ${LOOPB} >/dev/null 2>&1; echo $?` -ne 1 ]; then
29 echo "Loopa or loopb already exists, try to run:"
30 echo "mdadm -S /dev/md/$MDBOOT"
31 echo "mdadm -S /dev/md/$MDSLASH"
32 echo "mdadm -S /dev/md/$MDDATA"
33 echo "losetup -d ${LOOPA}"
34 echo "losetup -d ${LOOPB}"
35 exit 1
36 fi
37
38 # Create root dir
39 if [ ! -d "$PWD/root" ]; then
40 mkdir "$PWD/root"
41 fi
42
43 # Device creation
44 . lib/device.sh
45
46 # Fs creation
47 . lib/mkfs.sh
48
49 # Setup root
50 . lib/root.sh
51
52 # Sync data
53 . lib/sync.sh
54
55 # Setup boot
56 . lib/boot.sh
57
58 # Free resources
59 . lib/free.sh
60
61 # Export config
62 . lib/export.sh