]>
Commit | Line | Data |
---|---|---|
cd0fc28d AF |
1 | #/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
f1eb69d6 | 5 | # Copyright (C) 2007-2014 Arne Fitzenreiter <arne_f@ipfire.org> # |
cd0fc28d AF |
6 | # # |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | SNAME=xxxSNAMExxx | |
23 | VERSION=xxxVERSIONxxx | |
24 | CORE=xxxCORExxx | |
25 | ||
26 | KERN_TYPE=pae | |
27 | KVER=xxxKVERxxx | |
28 | KERN_PACK=xxxKERN_PACKxxx | |
29 | KRNDOWN=http://mirror0.ipfire.org/pakfire2/$VERSION/paks | |
921023a3 | 30 | CONSOLE=hvc0 |
cd0fc28d | 31 | |
f1eb69d6 | 32 | SIZEboot=64 |
cd0fc28d | 33 | SIZEswap=512 |
f1eb69d6 AF |
34 | SIZEroot=1024 |
35 | SIZEvar=1024 | |
3c4c5466 | 36 | FSTYPE=ext3 |
cd0fc28d AF |
37 | |
38 | ############################################################################## | |
39 | ||
40 | SOURCEISO=$SNAME-$VERSION.i586-full-core$CORE.iso | |
41 | HTTPDIR=http://download.ipfire.org/releases/ipfire-2.x/$VERSION-core$CORE | |
42 | ||
43 | TMPDIR=./ipfire-tmp | |
44 | ISODIR=$TMPDIR/iso | |
45 | MNThdd=$TMPDIR/harddisk | |
46 | ||
47 | IMGboot=./$SNAME-boot.img | |
48 | IMGswap=./$SNAME-swap.img | |
49 | IMGroot=./$SNAME-root.img | |
50 | IMGvar=./$SNAME-var.img | |
51 | ||
52 | KERNEL=linux-$KERN_TYPE-$KVER-$KERN_PACK.ipfire | |
53 | ||
61cf8114 AF |
54 | if [ "$XEN_IMG_TYPE" == "xva" ]; then |
55 | # download xva.py if it not exist. | |
56 | if [ ! -e xva.py ]; then | |
57 | wget http://source.ipfire.org/source-2.x/xva.py | |
58 | fi | |
59 | # XenCenter use other devicenames and | |
60 | # xvdd seems to be reserved (converter bug?). | |
61 | P1=xvda | |
62 | P2=xvdb | |
63 | P3=xvdc | |
64 | P4=xvde | |
65 | else | |
66 | # old style xen image partition names | |
67 | P1=xvda1 | |
68 | P2=xvda2 | |
69 | P3=xvda3 | |
70 | P4=xvda4 | |
71 | fi | |
72 | ||
cd0fc28d AF |
73 | rm -rf $TMPDIR && mkdir -p $MNThdd && mkdir -p $ISODIR |
74 | echo -------------------------------------------------------- | |
75 | echo - Download $SOURCEISO ... | |
76 | echo -------------------------------------------------------- | |
77 | wget $HTTPDIR/$SOURCEISO -O $TMPDIR/$SOURCEISO | |
78 | mount -o loop $TMPDIR/$SOURCEISO $ISODIR | |
79 | ||
80 | echo -------------------------------------------------------- | |
81 | echo - Download $KERNEL ... | |
82 | echo -------------------------------------------------------- | |
83 | wget $KRNDOWN/$KERNEL -O $TMPDIR/$KERNEL.gpg | |
84 | gpg -d $TMPDIR/$KERNEL.gpg > $TMPDIR/$KERNEL | |
85 | ||
86 | echo -------------------------------------------------------- | |
87 | echo - Create Images ... | |
88 | echo -------------------------------------------------------- | |
89 | ||
90 | #Create bootimage | |
91 | dd bs=1M if=/dev/zero of=$IMGboot count=$SIZEboot | |
92 | mkfs.ext2 -F $IMGboot | |
93 | ||
94 | #Create swapimage | |
95 | dd bs=1M if=/dev/zero of=$IMGswap count=$SIZEswap | |
96 | mkswap $IMGswap | |
97 | ||
98 | #Create rootimage | |
99 | dd bs=1M if=/dev/zero of=$IMGroot count=$SIZEroot | |
93d772a5 | 100 | mkfs.$FSTYPE -F $IMGroot |
cd0fc28d AF |
101 | |
102 | #Create varimage | |
103 | dd bs=1M if=/dev/zero of=$IMGvar count=$SIZEvar | |
93d772a5 | 104 | mkfs.$FSTYPE -F $IMGvar |
cd0fc28d AF |
105 | |
106 | echo -------------------------------------------------------- | |
107 | echo - Intall IPFire to the Images ... | |
108 | echo -------------------------------------------------------- | |
109 | ||
110 | # Mount Images | |
111 | mount -o loop $IMGroot $MNThdd | |
112 | mkdir $MNThdd/boot | |
113 | mkdir $MNThdd/var | |
114 | mkdir $MNThdd/var/log | |
115 | mount -o loop $IMGboot $MNThdd/boot | |
116 | mount -o loop $IMGvar $MNThdd/var | |
117 | ||
118 | # Install IPFire without kernel modules | |
741fa41c | 119 | xz -d < $ISODIR/distro.img > $TMPDIR/$SNAME-$VERSION.tar |
61cf8114 | 120 | tar -C $MNThdd/ -xvf $TMPDIR/$SNAME-$VERSION.tar \ |
921023a3 | 121 | --exclude=lib/modules* --exclude=boot* --numeric-owner |
cd0fc28d AF |
122 | |
123 | #Install Kernel | |
921023a3 | 124 | tar -C $MNThdd/opt/pakfire/tmp -xvf $TMPDIR/$KERNEL --numeric-owner |
cd0fc28d AF |
125 | chroot $MNThdd /opt/pakfire/tmp/install.sh |
126 | rm -rf $MNThdd/opt/pakfire/tmp/* | |
127 | ||
128 | #Create grub menuentry for pygrub | |
129 | mkdir $MNThdd/boot/grub | |
130 | echo "timeout 10" > $MNThdd/boot/grub/grub.conf | |
131 | echo "default 0" >> $MNThdd/boot/grub/grub.conf | |
132 | echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf | |
741fa41c | 133 | echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE" \ |
cd0fc28d | 134 | >> $MNThdd/boot/grub/grub.conf |
741fa41c | 135 | echo " initrd /initramfs-$KVER-ipfire-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf |
cd0fc28d AF |
136 | echo "# savedefault 0" >> $MNThdd/boot/grub/grub.conf |
137 | ||
138 | ln -s grub.conf $MNThdd/boot/grub/menu.lst | |
139 | ||
140 | #create the meta-info of linux-kernel package | |
9d707db0 AF |
141 | echo "" > $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE |
142 | echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE | |
143 | echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE | |
144 | echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE | |
145 | echo "" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE | |
146 | echo "" > $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE | |
147 | echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE | |
148 | echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE | |
149 | echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE | |
150 | echo "" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE | |
cd0fc28d AF |
151 | |
152 | #Set default configuration | |
153 | echo "LANGUAGE=en" >> $MNThdd/var/ipfire/main/settings | |
154 | echo "HOSTNAME=$SNAME" >> $MNThdd/var/ipfire/main/settings | |
155 | echo "THEME=ipfire" >> $MNThdd/var/ipfire/main/settings | |
156 | touch $MNThdd/lib/modules/$KVER-ipfire-$KERN_TYPE/modules.dep | |
157 | mkdir $MNThdd/proc | |
158 | mount --bind /proc $MNThdd/proc | |
159 | mount --bind /dev $MNThdd/dev | |
160 | mount --bind /sys $MNThdd/sys | |
161 | chroot $MNThdd /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
cd0fc28d | 162 | |
741fa41c AF |
163 | # create fstab |
164 | echo "/dev/$P1 /boot auto defaults 1 3" > $MNThdd/etc/fstab | |
165 | echo "/dev/$P2 swap swap defaults 0 0" >> $MNThdd/etc/fstab | |
166 | echo "/dev/$P3 / auto defaults 1 1" >> $MNThdd/etc/fstab | |
167 | echo "/dev/$P4 /var auto defaults 1 2" >> $MNThdd/etc/fstab | |
168 | ||
cd0fc28d AF |
169 | |
170 | #Remove root / fstab check | |
171 | rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S19checkfstab | |
172 | #Remove console init | |
173 | rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S70console | |
174 | ||
921023a3 AF |
175 | #Add console to securetty |
176 | echo $CONSOLE >> $MNThdd/etc/securetty | |
cd0fc28d | 177 | |
921023a3 | 178 | #Add getty for console |
cd0fc28d | 179 | echo "#Enable login for XEN" >> $MNThdd/etc/inittab |
921023a3 | 180 | echo "8:2345:respawn:/sbin/agetty $CONSOLE 9600 --noclear" >> $MNThdd/etc/inittab |
cd0fc28d AF |
181 | |
182 | #Disable some initskripts | |
183 | echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/setclock | |
184 | echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/keymap | |
185 | ||
186 | #Remove autoload of acpi modules | |
187 | sed -i -e "s|^ac|#ac|g" $MNThdd/etc/sysconfig/modules | |
188 | sed -i -e "s|^battery|#battery|g" $MNThdd/etc/sysconfig/modules | |
189 | sed -i -e "s|^button|#button|g" $MNThdd/etc/sysconfig/modules | |
190 | sed -i -e "s|^fan|#fan|g" $MNThdd/etc/sysconfig/modules | |
191 | sed -i -e "s|^processor|#processor|g" $MNThdd/etc/sysconfig/modules | |
192 | sed -i -e "s|^thermal|#thermal|g" $MNThdd/etc/sysconfig/modules | |
193 | sed -i -e "s|^video|#video|g" $MNThdd/etc/sysconfig/modules | |
194 | ||
195 | # Unmount | |
196 | umount $MNThdd/proc | |
197 | umount $MNThdd/dev | |
198 | umount $MNThdd/sys | |
199 | umount $MNThdd/var | |
200 | umount $MNThdd/boot | |
201 | umount $MNThdd | |
202 | ||
203 | umount $ISODIR | |
204 | rm -rf ./ipfire-tmp | |
61cf8114 AF |
205 | |
206 | if [ "$XEN_IMG_TYPE" == "xva" ]; then | |
207 | python xva.py --sparse -c $SNAME.cfg -f $SNAME.xva | |
208 | rm -f $SNAME*.img | |
209 | fi | |
cd0fc28d AF |
210 | echo -------------------------------------------------------- |
211 | echo - Done. | |
212 | echo -------------------------------------------------------- |