1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
|
|
# set an empty root password |
|
|
chroot ${CDCHROOTDIR} passwd -d root |
|
|
|
|
|
# install a custom boot-duration matching this livecd |
|
|
install -d ${CDCHROOTDIR}/var/lib/plymouth || die |
|
|
install -m 0644 $(get_profile boot-duration.livecd) ${CDCHROOTDIR}/var/lib/plymouth/boot-duration || die |
|
|
|
|
|
# install mnt-cdrom mount service, should be provided by alxinstall-ng |
|
|
install -m 0644 $(get_profile mnt-cdrom.mount) ${CDCHROOTDIR}/usr/lib/systemd/system/mnt-cdrom.mount || die |
|
|
ln -snf ../mnt-cdrom.mount ${CDCHROOTDIR}/usr/lib/systemd/system/local-fs.target.wants/mnt-cdrom.mount || die |
|
|
|
|
|
# disable splash X11 vt change and set splash to be always verbose |
|
|
#if [[ -f ${CDCHROOTDIR}/etc/splash/splash.conf ]] |
|
|
#then |
|
|
# sed -i -e 's:^\(SPLASH_X11_TTY=.*\):#\1:' \ |
|
|
# -e 's:^\(SPLASH_MODE=\).*:\1\"verbose\":' \ |
|
|
# ${CDCHROOTDIR}/etc/splash/splash.conf |
|
|
#fi |
|
|
|
|
|
# stop here if the user don't want to create the install tarball |
|
|
[[ ! -z ${SKIP_CREATE_INSTALL_TARBALL} ]] && exit 0 |
|
|
|
|
|
|
|
|
## |
|
|
# create the install tarball |
|
|
## |
|
|
|
|
|
install -d ${LIVECDROOT}/install-temp |
|
|
install -d ${CDISOROOT}/system |
|
|
|
|
|
# use all settings from the global config, but the basesystem |
|
|
# has to be the normal install basesystem not for livecds |
|
|
mage-bootstrap \ |
|
|
--root ${LIVECDROOT}/install-temp \ |
|
|
--profile ${MAGE_PROFILE} \ |
|
|
--magerc ${MAGERC} \ |
|
|
--toolchain ${TOOLCHAIN} \ |
|
|
--update-tarball \ |
|
|
--basesystem basesystem || die "bootstrapping target system failed!" |
|
|
|
|
|
# set an empty root password for the install system too |
|
|
chroot ${LIVECDROOT}/install-temp passwd -d root |
|
|
|
|
|
# add user station with empty password |
|
|
chroot ${LIVECDROOT}/install-temp adduser -G users -h /home/station -s /bin/bash -D station |
|
|
|
|
|
# install xinitrc |
|
|
echo 'exec startfluxbox' > ${LIVECDROOT}/install-temp/home/station/.xinitrc |
|
|
|
|
|
# fix hostname and hosts file |
|
|
echo "alx-i486" > ${LIVECDROOT}/install-temp/etc/hostname |
|
|
echo "127.0.0.1 localhost alx-i486.magellan-linux.de alx-i486" > ${LIVECDROOT}/install-temp/etc/hosts |
|
|
cat >> ${LIVECDROOT}/install-temp/etc/hosts << EOF |
|
|
::1 ip6-localhost ip6-loopback |
|
|
fe00::0 ip6-localnet |
|
|
ff00::0 ip6-mcastprefix |
|
|
ff02::1 ip6-allnodes |
|
|
ff02::2 ip6-allrouters |
|
|
ff02::3 ip6-allhosts |
|
|
EOF |
|
|
|
|
|
# create a default network interface config file |
|
|
cat > ${LIVECDROOT}/install-temp/etc/conf.d/net.eth0 << EOF |
|
|
ONBOOT="yes" |
|
|
NETWORKING="dhcp" |
|
|
EOF |
|
|
|
|
|
# fix mage.rc and config.rc |
|
3 |
updateconfig() |
updateconfig() |
4 |
{ |
{ |
5 |
local variables="$@" |
local variables="$@" |
25 |
fi |
fi |
26 |
done |
done |
27 |
} |
} |
|
NEW_SQL_USER="alx_install" |
|
|
NEW_SQL_PASS="@lx" |
|
|
NEW_SQL_HOST="128.20.41.110" |
|
|
NEW_SQL_DB="alx_web" |
|
|
NEW_SMB_UPDATE_HOST="//${NEW_SQL_HOST}/magetmp" |
|
|
NEW_SMB_UPDATE_USER="${NEW_SQL_USER}" |
|
|
NEW_SMB_UPDATE_PASS="${NEW_SQL_PASS}" |
|
|
NEW_MAGE_MIRRORS="http://${NEW_SQL_HOST}/magellan/alx-070" |
|
|
NEW_MAGE_RSYNC="rsync://${NEW_SQL_HOST}/mage-alx-070" |
|
|
NEW_RSYNC="${NEW_MAGE_RSYNC}" |
|
|
NEW_SMAGE2RSYNC="rsync://${NEW_SQL_HOST}/smage-alx-070" |
|
|
NEW_MIRRORS="${NEW_MAGE_MIRRORS}" |
|
|
NEW_MAGE_UNINSTALL_TIMEOUT="0" |
|
|
CONFIG="${LIVECDROOT}/install-temp/etc/mage.rc" |
|
|
updateconfig RSYNC SMAGE2RSYNC MIRRORS MAGE_UNINSTALL_TIMEOUT |
|
|
CONFIG="${LIVECDROOT}/install-temp/etc/alxconfig-ng/config.rc" |
|
|
updateconfig SQL_USER SQL_PASS SQL_HOST SQL_DB SMB_UPDATE_HOST SMB_UPDATE_USER SMB_UPDATE_PASS MAGE_MIRRORS MAGE_RSYNC |
|
|
|
|
|
# create tarball |
|
|
[[ -f ${CDISOROOT}/system/alx-i486.tar.bz2 ]] && rm ${CDISOROOT}/system/alx-i486.tar.bz2 |
|
|
( cd ${LIVECDROOT}/install-temp; tar cvjpf ${CDISOROOT}/system/alx-i486.tar.bz2 ./ | tee log) |
|
|
|
|
|
# create images.conf |
|
|
echo "CDIMAGENAME=alx-i486.tar.bz2" > ${CDISOROOT}/system/images.conf |
|
|
echo "TOTALLINES=$(wc -l ${LIVECDROOT}/install-temp/log | cut -d' ' -f1)" >> ${CDISOROOT}/system/images.conf |
|
28 |
|
|
29 |
# clean up |
## |
30 |
if [[ -d ${LIVECDROOT}/install-temp ]] |
# 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 |
|
# copy kernel, bootloader and create initramfs to isoroot/netboot |
155 |
|
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 |
|
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 |
|
# install dracut-dev package to have all modules |
164 |
|
custom_packages install "dracut-dev curl curl-dev" || die |
165 |
|
## mlivecdbuild function |
166 |
|
generate_initrd |
167 |
|
mv ${CDISOROOT}/isolinux/initrd.gz ${CDISOROOT}/netboot/ || die |
168 |
|
custom_packages uninstall "dracut-dev curl curl-dev" || die |
169 |
|
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 |
|
# 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 |
|
|
184 |
|
# final cleanup |
185 |
|
if [[ -d ${LIVECDROOT}/network-temp ]] |
186 |
|
then |
187 |
|
rm -r ${LIVECDROOT}/network-temp || die |
188 |
|
fi |
189 |
|
} |
190 |
|
|
191 |
|
# 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 |
|
# install mnt-cdrom mount service, should be provided by alxinstall-ng |
199 |
|
#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 |
|
|
202 |
|
# 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 |
|
# setup de keymap and locales |
211 |
|
if [ -f ${CDCHROOTDIR}/etc/vconsole.conf ] |
212 |
|
then |
213 |
|
cat > ${CDCHROOTDIR}/etc/vconsole.conf << EOF || die |
214 |
|
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 |
then |
223 |
rm -rf ${LIVECDROOT}/install-temp |
sed -i "s:^\(LANG=\).*:\1\"de_DE.utf8\":" ${CDCHROOTDIR}/etc/locale.conf || die |
224 |
fi |
fi |
225 |
|
|
226 |
|
# stop here if the user don't want to create the install tarball |
227 |
|
[[ -n ${SKIP_CREATE_INSTALL_TARBALL} ]] || create_install_tarball |
228 |
|
|
229 |
# install usb-install script |
# install usb-install script |
230 |
[ ! -d ${CDISOROOT}/usb-install ] && mkdir ${CDISOROOT}/usb-install |
[ ! -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 |
[ -f $(get_profile usb-install/usb-install.cmd) ] && cp $(get_profile usb-install)/usb-install.cmd ${CDISOROOT}/usb-install |