]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - config/xen-image/xen-image-maker.sh
Merge remote-tracking branch 'mfischer/slang' into next
[people/pmueller/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
921023a3 30CONSOLE=hvc0
cd0fc28d 31
f1eb69d6 32SIZEboot=64
cd0fc28d 33SIZEswap=512
f1eb69d6
AF
34SIZEroot=1024
35SIZEvar=1024
3c4c5466 36FSTYPE=ext3
cd0fc28d
AF
37
38##############################################################################
39
40SOURCEISO=$SNAME-$VERSION.i586-full-core$CORE.iso
41HTTPDIR=http://download.ipfire.org/releases/ipfire-2.x/$VERSION-core$CORE
42
43TMPDIR=./ipfire-tmp
44ISODIR=$TMPDIR/iso
45MNThdd=$TMPDIR/harddisk
46
47IMGboot=./$SNAME-boot.img
48IMGswap=./$SNAME-swap.img
49IMGroot=./$SNAME-root.img
50IMGvar=./$SNAME-var.img
51
52KERNEL=linux-$KERN_TYPE-$KVER-$KERN_PACK.ipfire
53
61cf8114
AF
54if [ "$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
65else
66 # old style xen image partition names
67 P1=xvda1
68 P2=xvda2
69 P3=xvda3
70 P4=xvda4
71fi
72
cd0fc28d
AF
73rm -rf $TMPDIR && mkdir -p $MNThdd && mkdir -p $ISODIR
74echo --------------------------------------------------------
75echo - Download $SOURCEISO ...
76echo --------------------------------------------------------
77wget $HTTPDIR/$SOURCEISO -O $TMPDIR/$SOURCEISO
78mount -o loop $TMPDIR/$SOURCEISO $ISODIR
79
80echo --------------------------------------------------------
81echo - Download $KERNEL ...
82echo --------------------------------------------------------
83wget $KRNDOWN/$KERNEL -O $TMPDIR/$KERNEL.gpg
84gpg -d $TMPDIR/$KERNEL.gpg > $TMPDIR/$KERNEL
85
86echo --------------------------------------------------------
87echo - Create Images ...
88echo --------------------------------------------------------
89
90#Create bootimage
91dd bs=1M if=/dev/zero of=$IMGboot count=$SIZEboot
92mkfs.ext2 -F $IMGboot
93
94#Create swapimage
95dd bs=1M if=/dev/zero of=$IMGswap count=$SIZEswap
96mkswap $IMGswap
97
98#Create rootimage
99dd bs=1M if=/dev/zero of=$IMGroot count=$SIZEroot
93d772a5 100mkfs.$FSTYPE -F $IMGroot
cd0fc28d
AF
101
102#Create varimage
103dd bs=1M if=/dev/zero of=$IMGvar count=$SIZEvar
93d772a5 104mkfs.$FSTYPE -F $IMGvar
cd0fc28d
AF
105
106echo --------------------------------------------------------
107echo - Intall IPFire to the Images ...
108echo --------------------------------------------------------
109
110# Mount Images
111mount -o loop $IMGroot $MNThdd
112mkdir $MNThdd/boot
113mkdir $MNThdd/var
114mkdir $MNThdd/var/log
115mount -o loop $IMGboot $MNThdd/boot
116mount -o loop $IMGvar $MNThdd/var
117
118# Install IPFire without kernel modules
741fa41c 119xz -d < $ISODIR/distro.img > $TMPDIR/$SNAME-$VERSION.tar
61cf8114 120tar -C $MNThdd/ -xvf $TMPDIR/$SNAME-$VERSION.tar \
921023a3 121 --exclude=lib/modules* --exclude=boot* --numeric-owner
cd0fc28d
AF
122
123#Install Kernel
921023a3 124tar -C $MNThdd/opt/pakfire/tmp -xvf $TMPDIR/$KERNEL --numeric-owner
cd0fc28d
AF
125chroot $MNThdd /opt/pakfire/tmp/install.sh
126rm -rf $MNThdd/opt/pakfire/tmp/*
127
128#Create grub menuentry for pygrub
129mkdir $MNThdd/boot/grub
130echo "timeout 10" > $MNThdd/boot/grub/grub.conf
131echo "default 0" >> $MNThdd/boot/grub/grub.conf
132echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf
741fa41c 133echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE" \
cd0fc28d 134 >> $MNThdd/boot/grub/grub.conf
741fa41c 135echo " initrd /initramfs-$KVER-ipfire-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf
cd0fc28d
AF
136echo "# savedefault 0" >> $MNThdd/boot/grub/grub.conf
137
138ln -s grub.conf $MNThdd/boot/grub/menu.lst
139
140#create the meta-info of linux-kernel package
9d707db0
AF
141echo "" > $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE
142echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE
143echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE
144echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE
145echo "" >> $MNThdd/opt/pakfire/db/meta/meta-linux-$KERN_TYPE
146echo "" > $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE
147echo "Name: linux-$KERN_TYPE" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE
148echo "ProgVersion: $KVER" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE
149echo "Release: $KERN_PACK" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE
150echo "" >> $MNThdd/opt/pakfire/db/installed/meta-linux-$KERN_TYPE
cd0fc28d
AF
151
152#Set default configuration
153echo "LANGUAGE=en" >> $MNThdd/var/ipfire/main/settings
154echo "HOSTNAME=$SNAME" >> $MNThdd/var/ipfire/main/settings
155echo "THEME=ipfire" >> $MNThdd/var/ipfire/main/settings
156touch $MNThdd/lib/modules/$KVER-ipfire-$KERN_TYPE/modules.dep
157mkdir $MNThdd/proc
158mount --bind /proc $MNThdd/proc
159mount --bind /dev $MNThdd/dev
160mount --bind /sys $MNThdd/sys
161chroot $MNThdd /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
cd0fc28d 162
741fa41c
AF
163# create fstab
164echo "/dev/$P1 /boot auto defaults 1 3" > $MNThdd/etc/fstab
165echo "/dev/$P2 swap swap defaults 0 0" >> $MNThdd/etc/fstab
166echo "/dev/$P3 / auto defaults 1 1" >> $MNThdd/etc/fstab
167echo "/dev/$P4 /var auto defaults 1 2" >> $MNThdd/etc/fstab
168
cd0fc28d
AF
169
170#Remove root / fstab check
171rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S19checkfstab
172#Remove console init
173rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S70console
174
921023a3
AF
175#Add console to securetty
176echo $CONSOLE >> $MNThdd/etc/securetty
cd0fc28d 177
921023a3 178#Add getty for console
cd0fc28d 179echo "#Enable login for XEN" >> $MNThdd/etc/inittab
921023a3 180echo "8:2345:respawn:/sbin/agetty $CONSOLE 9600 --noclear" >> $MNThdd/etc/inittab
cd0fc28d
AF
181
182#Disable some initskripts
183echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/setclock
184echo "#!/bin/sh" > $MNThdd/etc/rc.d/init.d/keymap
185
186#Remove autoload of acpi modules
187sed -i -e "s|^ac|#ac|g" $MNThdd/etc/sysconfig/modules
188sed -i -e "s|^battery|#battery|g" $MNThdd/etc/sysconfig/modules
189sed -i -e "s|^button|#button|g" $MNThdd/etc/sysconfig/modules
190sed -i -e "s|^fan|#fan|g" $MNThdd/etc/sysconfig/modules
191sed -i -e "s|^processor|#processor|g" $MNThdd/etc/sysconfig/modules
192sed -i -e "s|^thermal|#thermal|g" $MNThdd/etc/sysconfig/modules
193sed -i -e "s|^video|#video|g" $MNThdd/etc/sysconfig/modules
194
195# Unmount
196umount $MNThdd/proc
197umount $MNThdd/dev
198umount $MNThdd/sys
199umount $MNThdd/var
200umount $MNThdd/boot
201umount $MNThdd
202
203umount $ISODIR
204rm -rf ./ipfire-tmp
61cf8114
AF
205
206if [ "$XEN_IMG_TYPE" == "xva" ]; then
207 python xva.py --sparse -c $SNAME.cfg -f $SNAME.xva
208 rm -f $SNAME*.img
209fi
cd0fc28d
AF
210echo --------------------------------------------------------
211echo - Done.
212echo --------------------------------------------------------