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