]>
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 | |
30 | ||
31 | ############################################################################### | |
32 | # If you really want to use outdated legacy kernel uncomment this lines. ##### | |
33 | # Not recommended!!! ########################################################## | |
34 | ###################### | |
35 | #KERN_TYPE=xen | |
36 | #KVER=2.6.32.61 | |
f1eb69d6 AF |
37 | #KERN_PACK=28 |
38 | #KRNDOWN=http://mirror0.ipfire.org/pakfire2/2.15/paks | |
cd0fc28d AF |
39 | ############################################################################### |
40 | ||
f1eb69d6 | 41 | SIZEboot=64 |
cd0fc28d | 42 | SIZEswap=512 |
f1eb69d6 AF |
43 | SIZEroot=1024 |
44 | SIZEvar=1024 | |
93d772a5 AF |
45 | # ct'server does not support ext4 so change this to ext3. |
46 | FSTYPE=ext4 | |
cd0fc28d AF |
47 | |
48 | ############################################################################## | |
49 | ||
50 | SOURCEISO=$SNAME-$VERSION.i586-full-core$CORE.iso | |
51 | HTTPDIR=http://download.ipfire.org/releases/ipfire-2.x/$VERSION-core$CORE | |
52 | ||
53 | TMPDIR=./ipfire-tmp | |
54 | ISODIR=$TMPDIR/iso | |
55 | MNThdd=$TMPDIR/harddisk | |
56 | ||
57 | IMGboot=./$SNAME-boot.img | |
58 | IMGswap=./$SNAME-swap.img | |
59 | IMGroot=./$SNAME-root.img | |
60 | IMGvar=./$SNAME-var.img | |
61 | ||
62 | KERNEL=linux-$KERN_TYPE-$KVER-$KERN_PACK.ipfire | |
63 | ||
64 | rm -rf $TMPDIR && mkdir -p $MNThdd && mkdir -p $ISODIR | |
65 | echo -------------------------------------------------------- | |
66 | echo - Download $SOURCEISO ... | |
67 | echo -------------------------------------------------------- | |
68 | wget $HTTPDIR/$SOURCEISO -O $TMPDIR/$SOURCEISO | |
69 | mount -o loop $TMPDIR/$SOURCEISO $ISODIR | |
70 | ||
71 | echo -------------------------------------------------------- | |
72 | echo - Download $KERNEL ... | |
73 | echo -------------------------------------------------------- | |
74 | wget $KRNDOWN/$KERNEL -O $TMPDIR/$KERNEL.gpg | |
75 | gpg -d $TMPDIR/$KERNEL.gpg > $TMPDIR/$KERNEL | |
76 | ||
77 | echo -------------------------------------------------------- | |
78 | echo - Create Images ... | |
79 | echo -------------------------------------------------------- | |
80 | ||
81 | #Create bootimage | |
82 | dd bs=1M if=/dev/zero of=$IMGboot count=$SIZEboot | |
83 | mkfs.ext2 -F $IMGboot | |
84 | ||
85 | #Create swapimage | |
86 | dd bs=1M if=/dev/zero of=$IMGswap count=$SIZEswap | |
87 | mkswap $IMGswap | |
88 | ||
89 | #Create rootimage | |
90 | dd bs=1M if=/dev/zero of=$IMGroot count=$SIZEroot | |
93d772a5 | 91 | mkfs.$FSTYPE -F $IMGroot |
cd0fc28d AF |
92 | |
93 | #Create varimage | |
94 | dd bs=1M if=/dev/zero of=$IMGvar count=$SIZEvar | |
93d772a5 | 95 | mkfs.$FSTYPE -F $IMGvar |
cd0fc28d AF |
96 | |
97 | echo -------------------------------------------------------- | |
98 | echo - Intall IPFire to the Images ... | |
99 | echo -------------------------------------------------------- | |
100 | ||
101 | # Mount Images | |
102 | mount -o loop $IMGroot $MNThdd | |
103 | mkdir $MNThdd/boot | |
104 | mkdir $MNThdd/var | |
105 | mkdir $MNThdd/var/log | |
106 | mount -o loop $IMGboot $MNThdd/boot | |
107 | mount -o loop $IMGvar $MNThdd/var | |
108 | ||
109 | # Install IPFire without kernel modules | |
110 | tar -C $MNThdd/ -xvf $ISODIR/$SNAME-$VERSION.tlz --lzma \ | |
111 | --exclude=lib/modules* --exclude=boot* | |
112 | ||
113 | #Install Kernel | |
114 | tar -C $MNThdd/opt/pakfire/tmp -xvf $TMPDIR/$KERNEL | |
115 | chroot $MNThdd /opt/pakfire/tmp/install.sh | |
116 | rm -rf $MNThdd/opt/pakfire/tmp/* | |
117 | ||
118 | #Create grub menuentry for pygrub | |
119 | mkdir $MNThdd/boot/grub | |
120 | echo "timeout 10" > $MNThdd/boot/grub/grub.conf | |
121 | echo "default 0" >> $MNThdd/boot/grub/grub.conf | |
122 | echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf | |
123 | echo " kernel /vmlinuz-$KVER-ipfire-xen root=/dev/xvda3 rootdelay=10 panic=10 console=xvc0 ro" \ | |
124 | >> $MNThdd/boot/grub/grub.conf | |
125 | echo " initrd /ipfirerd-$KVER-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf | |
126 | echo "# savedefault 0" >> $MNThdd/boot/grub/grub.conf | |
127 | ||
128 | ln -s grub.conf $MNThdd/boot/grub/menu.lst | |
129 | ||
130 | #create the meta-info of linux-kernel package | |
131 | echo "" > $MNThdd/opt/pakfire/db/meta/linux-$KERN_TYPE | |
132 | echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/meta/linux-$KERN_TYPE | |
133 | echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/meta/linux-$KERN_TYPE | |
134 | echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/meta/linux-$KERN_TYPE | |
135 | echo "" >> $MNThdd/opt/pakfire/db/meta/linux-$KERN_TYPE | |
136 | echo "" > $MNThdd/opt/pakfire/db/installed/linux-$KERN_TYPE | |
137 | echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/installed/linux-$KERN_TYPE | |
138 | echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/installed/linux-$KERN_TYPE | |
139 | echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/installed/linux-$KERN_TYPE | |
140 | echo "" >> $MNThdd/opt/pakfire/db/installed/linux-$KERN_TYPE | |
141 | ||
142 | #Set default configuration | |
143 | echo "LANGUAGE=en" >> $MNThdd/var/ipfire/main/settings | |
144 | echo "HOSTNAME=$SNAME" >> $MNThdd/var/ipfire/main/settings | |
145 | echo "THEME=ipfire" >> $MNThdd/var/ipfire/main/settings | |
146 | touch $MNThdd/lib/modules/$KVER-ipfire-$KERN_TYPE/modules.dep | |
147 | mkdir $MNThdd/proc | |
148 | mount --bind /proc $MNThdd/proc | |
149 | mount --bind /dev $MNThdd/dev | |
150 | mount --bind /sys $MNThdd/sys | |
151 | chroot $MNThdd /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
152 | sed -i -e "s|DEVICE1|/dev/xvda1|g" $MNThdd/etc/fstab | |
153 | sed -i -e "s|DEVICE2|/dev/xvda2|g" $MNThdd/etc/fstab | |
154 | sed -i -e "s|DEVICE3|/dev/xvda3|g" $MNThdd/etc/fstab | |
155 | sed -i -e "s|DEVICE4|/dev/xvda4|g" $MNThdd/etc/fstab | |
156 | ||
93d772a5 | 157 | sed -i -e "s|FSTYPE|$FSTYPE|g" $MNThdd/etc/fstab |
cd0fc28d AF |
158 | |
159 | #Remove root / fstab check | |
160 | rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S19checkfstab | |
161 | #Remove console init | |
162 | rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S70console | |
163 | ||
164 | #Add xvc0 to securetty | |
165 | echo xvc0 >> $MNThdd/etc/securetty | |
166 | ||
167 | #Add getty for xvc0 | |
168 | echo "#Enable login for XEN" >> $MNThdd/etc/inittab | |
21b9f5dc | 169 | echo "8:2345:respawn:/sbin/agetty xvc0 9600 -noclear" >> $MNThdd/etc/inittab |
cd0fc28d AF |
170 | |
171 | #Disable some initskripts | |
172 | echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/setclock | |
173 | echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/keymap | |
174 | ||
175 | #Remove autoload of acpi modules | |
176 | sed -i -e "s|^ac|#ac|g" $MNThdd/etc/sysconfig/modules | |
177 | sed -i -e "s|^battery|#battery|g" $MNThdd/etc/sysconfig/modules | |
178 | sed -i -e "s|^button|#button|g" $MNThdd/etc/sysconfig/modules | |
179 | sed -i -e "s|^fan|#fan|g" $MNThdd/etc/sysconfig/modules | |
180 | sed -i -e "s|^processor|#processor|g" $MNThdd/etc/sysconfig/modules | |
181 | sed -i -e "s|^thermal|#thermal|g" $MNThdd/etc/sysconfig/modules | |
182 | sed -i -e "s|^video|#video|g" $MNThdd/etc/sysconfig/modules | |
183 | ||
184 | # Unmount | |
185 | umount $MNThdd/proc | |
186 | umount $MNThdd/dev | |
187 | umount $MNThdd/sys | |
188 | umount $MNThdd/var | |
189 | umount $MNThdd/boot | |
190 | umount $MNThdd | |
191 | ||
192 | umount $ISODIR | |
193 | rm -rf ./ipfire-tmp | |
194 | echo -------------------------------------------------------- | |
195 | echo - Done. | |
196 | echo -------------------------------------------------------- |