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