Magellan Linux

Annotation of /trunk/mlivecdbuild/profiles/alx-0_7_branch/prepare_custom

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2873 - (hide annotations) (download)
Fri Jul 17 11:43:55 2015 UTC (8 years, 10 months ago) by niro
File size: 8703 byte(s)
-fixed whitespaces
1 niro 2119 #!/bin/bash
2    
3 niro 2664 updateconfig()
4     {
5     local variables="$@"
6     local value
7     local i
8    
9     if [[ -z ${CONFIG} ]]
10     then
11     echo "You must define \$CONFIG varibale first!"
12     return 1
13     fi
14    
15     for i in ${variables}
16     do
17     value="$(eval echo \${NEW_${i}})"
18     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
19     then
20     echo "fixing ${i} -> ${value}"
21     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
22     else
23     echo "adding ${i}=${value}"
24     echo "${i}=\"${value}\"" >> ${CONFIG}
25     fi
26     done
27     }
28    
29     ##
30     # create the install tarball
31     ##
32     create_install_tarball()
33     {
34     install -d ${LIVECDROOT}/install-temp
35     install -d ${CDISOROOT}/system
36    
37     # use all settings from the global config, but the basesystem
38     # has to be the normal install basesystem not for livecds
39     mage-bootstrap \
40     --root ${LIVECDROOT}/install-temp \
41     --profile ${MAGE_PROFILE} \
42     --magerc ${MAGERC} \
43     --toolchain ${TOOLCHAIN} \
44     --update-tarball \
45     --basesystem basesystem || die "bootstrapping target system failed!"
46    
47     # set an empty root password for the install system too
48     chroot ${LIVECDROOT}/install-temp passwd -d root
49    
50     # add user station with empty password
51     chroot ${LIVECDROOT}/install-temp adduser -G users -h /home/station -s /bin/bash -D station
52    
53     # install xinitrc
54     echo 'exec startfluxbox' > ${LIVECDROOT}/install-temp/home/station/.xinitrc
55    
56     # fix hostname and hosts file
57     echo "alx-i486" > ${LIVECDROOT}/install-temp/etc/hostname
58     echo "127.0.0.1 localhost alx-i486.magellan-linux.de alx-i486" > ${LIVECDROOT}/install-temp/etc/hosts
59     cat >> ${LIVECDROOT}/install-temp/etc/hosts << EOF
60     ::1 ip6-localhost ip6-loopback
61     fe00::0 ip6-localnet
62     ff00::0 ip6-mcastprefix
63     ff02::1 ip6-allnodes
64     ff02::2 ip6-allrouters
65     ff02::3 ip6-allhosts
66     EOF
67    
68     # create a default network interface config file
69     cat > ${LIVECDROOT}/install-temp/etc/conf.d/net.eth0 << EOF
70     ONBOOT="yes"
71     NETWORKING="dhcp"
72     EOF
73    
74     # fix mage.rc and config.rc
75     NEW_SQL_USER="alx_install"
76     NEW_SQL_PASS="@lx"
77     NEW_SQL_HOST="128.20.41.110"
78     NEW_SQL_DB="alx_web"
79     NEW_SMB_UPDATE_HOST="//${NEW_SQL_HOST}/magetmp"
80     NEW_SMB_UPDATE_USER="${NEW_SQL_USER}"
81     NEW_SMB_UPDATE_PASS="${NEW_SQL_PASS}"
82     NEW_MAGE_MIRRORS="http://${NEW_SQL_HOST}/magellan/alx-070"
83     NEW_MAGE_RSYNC="rsync://${NEW_SQL_HOST}/mage-alx-070"
84     NEW_RSYNC="${NEW_MAGE_RSYNC}"
85     NEW_SMAGE2RSYNC="rsync://${NEW_SQL_HOST}/smage-alx-070"
86     NEW_MIRRORS="${NEW_MAGE_MIRRORS}"
87     NEW_MAGE_UNINSTALL_TIMEOUT="0"
88     CONFIG="${LIVECDROOT}/install-temp/etc/mage.rc"
89     updateconfig RSYNC SMAGE2RSYNC MIRRORS MAGE_UNINSTALL_TIMEOUT
90     CONFIG="${LIVECDROOT}/install-temp/etc/alxconfig-ng/config.rc"
91     updateconfig SQL_USER SQL_PASS SQL_HOST SQL_DB SMB_UPDATE_HOST SMB_UPDATE_USER SMB_UPDATE_PASS MAGE_MIRRORS MAGE_RSYNC
92    
93     # create tarball
94     [[ -f ${CDISOROOT}/system/alx-i486.tar.bz2 ]] && rm ${CDISOROOT}/system/alx-i486.tar.bz2
95     ( cd ${LIVECDROOT}/install-temp; tar cvjpf ${CDISOROOT}/system/alx-i486.tar.bz2 ./ | tee log)
96    
97     # create images.conf
98     echo "CDIMAGENAME=alx-i486.tar.bz2" > ${CDISOROOT}/system/images.conf
99     echo "TOTALLINES=$(wc -l ${LIVECDROOT}/install-temp/log | cut -d' ' -f1)" >> ${CDISOROOT}/system/images.conf
100    
101     create_netboot_image
102    
103     # clean up
104     if [[ -d ${LIVECDROOT}/install-temp ]]
105     then
106     rm -rf ${LIVECDROOT}/install-temp
107     fi
108     }
109    
110     ##
111     # create the network image
112     ##
113     create_netboot_image()
114     {
115     install -d ${CDISOROOT}/netboot
116     install -d ${LIVECDROOT}/network-temp
117    
118     install -d ${LIVECDROOT}/network-temp/{LiveOS,mnt} || die
119    
120     # get the actual size of the chroot
121     size=$(du -s ${LIVECDROOT}/install-temp | sed 's:^\(.*\)[[:space:]].*:\1:')
122    
123     # generate a ext3fs file for devicemapper
124     dd if=/dev/zero of=${LIVECDROOT}/network-temp/LiveOS/ext3fs.img bs=1024 count=$(( ${size} + 10 )) || die
125     # create a filesystem
126     mkfs.ext3 -L "_${CDID}_EXT3" -m 1 -b 1024 -F ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die
127     # set mount_counts and check_intervals to 0
128     # set dir_index top, to speed up thing with hashed b-trees
129     # allow acls too
130     tune2fs -c0 -i0 -Odir_index -ouser_xattr,acl ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die
131    
132     # losetup the device
133     loopdev=$(losetup -f)
134     [[ -z ${loopdev} ]] && die "No unused loopdev found. Maybe you want 'modprobe loop'?"
135    
136     # mount the image
137     losetup ${loopdev} ${LIVECDROOT}/network-temp/LiveOS/ext3fs.img || die
138     mount ${loopdev} ${LIVECDROOT}/network-temp/mnt || die
139    
140     # copy everything to the image file and preserve permissions
141     ( cd ${LIVECDROOT}/install-temp && tar cpf - . ) | ( cd ${LIVECDROOT}/network-temp/mnt && tar xvpf - )
142     sleep 3
143    
144     # now umount everything and create the squashfs image
145     umount ${LIVECDROOT}/network-temp/mnt || die
146     losetup -d ${loopdev} || die
147     # remove mount to not ending up in the squashfs image
148     if [[ -d ${LIVECDROOT}/network-temp/mnt ]]
149     then
150     rm -r ${LIVECDROOT}/network-temp/mnt || die
151     fi
152     mksquashfs ${LIVECDROOT}/network-temp ${CDISOROOT}/netboot/squashfs.img || die
153    
154 niro 2872 # copy kernel, bootloader and create initramfs to isoroot/netboot
155 niro 2664 install -d ${CDISOROOT}/netboot || die
156     # kernel
157     kimg="$(find ${CDCHROOTDIR}/boot -name kernel-\* -printf '%f\n')"
158     install ${CDCHROOTDIR}/boot/${kimg} ${CDISOROOT}/netboot/${CDKERNELNAME} || die
159     # initrd
160     install -d ${CDCHROOTDIR}/etc/dracut.conf.d || die
161 niro 2873 echo 'add_dracutmodules+=" livenet busybox "' > ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die
162     echo 'omit_dracutmodules+=" systemd plymouth mcored "' >> ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf || die
163 niro 2664 # install dracut-dev package to have all modules
164 niro 2872 custom_packages install "dracut-dev curl curl-dev" || die
165 niro 2664 ## mlivecdbuild function
166     generate_initrd
167     mv ${CDISOROOT}/isolinux/initrd.gz ${CDISOROOT}/netboot/ || die
168 niro 2872 custom_packages uninstall "dracut-dev curl curl-dev" || die
169 niro 2664 if [ -e ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf ]
170     then
171     rm ${CDCHROOTDIR}/etc/dracut.conf.d/03-netboot.conf
172     fi
173 niro 2872 # bootloader
174     install -d ${CDISOROOT}/netboot/pxelinux.cfg
175     [ -f $(get_profile netboot/pxelinux.0) ] && install -m0644 $(get_profile netboot/pxelinux.0) ${CDISOROOT}/netboot
176     [ -f $(get_profile netboot/pxelinux.cfg/default) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/default) ${CDISOROOT}/netboot/pxelinux.cfg
177     [ -f $(get_profile netboot/pxelinux.cfg/boot.cat) ] && install -m0644 $(get_profile netboot/pxelinux.cfg/boot.cat) ${CDISOROOT}/netboot/pxelinux.cfg
178     [ -f $(get_profile boot.lss) ] && install -m0644 $(get_profile boot.lss) ${CDISOROOT}/netboot/pxelinux.cfg
179     [ -f $(get_profile boot.msg) ] && install -m0644 $(get_profile boot.msg) ${CDISOROOT}/netboot/pxelinux.cfg
180     [ -f $(get_profile debug.msg) ] && install -m0644 $(get_profile debug.msg) ${CDISOROOT}/netboot/pxelinux.cfg
181     [ -f $(get_profile help.msg) ] && install -m0644 $(get_profile help.msg) ${CDISOROOT}/netboot/pxelinux.cfg
182     [ -f $(get_profile index.msg) ] && install -m0644 $(get_profile index.msg) ${CDISOROOT}/netboot/pxelinux.cfg
183 niro 2664
184     # final cleanup
185     if [[ -d ${LIVECDROOT}/network-temp ]]
186     then
187     rm -r ${LIVECDROOT}/network-temp || die
188     fi
189     }
190    
191 niro 2119 # set an empty root password
192     chroot ${CDCHROOTDIR} passwd -d root
193    
194     # install a custom boot-duration matching this livecd
195     install -d ${CDCHROOTDIR}/var/lib/plymouth || die
196     install -m 0644 $(get_profile boot-duration.livecd) ${CDCHROOTDIR}/var/lib/plymouth/boot-duration || die
197    
198 niro 2121 # install mnt-cdrom mount service, should be provided by alxinstall-ng
199 niro 2661 #install -m 0644 $(get_profile mnt-cdrom.mount) ${CDCHROOTDIR}/usr/lib/systemd/system/mnt-cdrom.mount || die
200     #ln -snf ../mnt-cdrom.mount ${CDCHROOTDIR}/usr/lib/systemd/system/local-fs.target.wants/mnt-cdrom.mount || die
201 niro 2121
202 niro 2119 # disable splash X11 vt change and set splash to be always verbose
203     #if [[ -f ${CDCHROOTDIR}/etc/splash/splash.conf ]]
204     #then
205     # sed -i -e 's:^\(SPLASH_X11_TTY=.*\):#\1:' \
206     # -e 's:^\(SPLASH_MODE=\).*:\1\"verbose\":' \
207     # ${CDCHROOTDIR}/etc/splash/splash.conf
208     #fi
209    
210 niro 2661 # setup de keymap and locales
211     if [ -f ${CDCHROOTDIR}/etc/vconsole.conf ]
212     then
213 niro 2663 cat > ${CDCHROOTDIR}/etc/vconsole.conf << EOF || die
214 niro 2661 KEYMAP=de
215     KEYMAP_TOGGLE=
216     FONT=lat9w-16
217     FONT_MAP=8859-1_to_uni
218     FONT_UNIMAP=
219     EOF
220     fi
221     if [ -f ${CDCHROOTDIR}/etc/locale.conf ]
222     then
223 niro 2662 sed -i "s:^\(LANG=\).*:\1\"de_DE.utf8\":" ${CDCHROOTDIR}/etc/locale.conf || die
224 niro 2661 fi
225    
226 niro 2119 # stop here if the user don't want to create the install tarball
227 niro 2664 [[ -n ${SKIP_CREATE_INSTALL_TARBALL} ]] || create_install_tarball
228 niro 2119
229     # install usb-install script
230     [ ! -d ${CDISOROOT}/usb-install ] && mkdir ${CDISOROOT}/usb-install
231     [ -f $(get_profile usb-install/usb-install.cmd) ] && cp $(get_profile usb-install)/usb-install.cmd ${CDISOROOT}/usb-install
232     [ -f $(get_profile usb-install/syslinux.exe) ] && cp $(get_profile usb-install)/syslinux.exe ${CDISOROOT}/usb-install
233     [ -f $(get_profile usb-install/syslinux.cfg) ] && cp $(get_profile usb-install)/syslinux.cfg ${CDISOROOT}/usb-install