]> Raphaƫl G. Git Repositories - distgen/blob - genimg
Compute correctly mask based on ip
[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/$MDDATA"
32 echo "losetup -d ${LOOPA}"
33 echo "losetup -d ${LOOPB}"
34 exit 1
35 fi
36
37 # Create root dir
38 if [ ! -d "$PWD/root" ]; then
39 mkdir "$PWD/root"
40 fi
41
42 # Device creation
43 . lib/device.sh
44
45 # Fs creation
46 . lib/mkfs.sh
47
48 # Setup root
49 . lib/root.sh
50
51 # Sync data
52 . lib/sync.sh
53
54 # Setup boot
55 . lib/boot.sh
56
57 # Free resources
58 . lib/free.sh
59
60 # Export config
61 . lib/export.sh