1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Id$ |
# $Id$ |
3 |
|
|
4 |
|
# get a suitable environment |
5 |
|
source /etc/profile |
6 |
|
|
7 |
MAGERC="/etc/mage.rc" |
MAGERC="/etc/mage.rc" |
8 |
MAGEPROFILE="alx-060" |
MAGEPROFILE="alx-060" |
9 |
NEW_MAGE_DISTRIBUTION="unstable" |
NEW_MAGE_DISTRIBUTION="unstable" |
15 |
CONFIGRC="/etc/alxconfig-ng/config.rc" |
CONFIGRC="/etc/alxconfig-ng/config.rc" |
16 |
NEW_ALX_NETWORKING="dhcp" |
NEW_ALX_NETWORKING="dhcp" |
17 |
NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
18 |
NEW_ALX_DHCP_START="-T 10" |
NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" |
19 |
NEW_ALX_DHCP_STOP="" |
NEW_ALX_DHCP_STOP="" |
20 |
|
NEW_MIN_DISK_SPACE="85000" |
21 |
|
NEW_ALX_PLUGINS="/etc/alxconfig-ng/plugins" |
22 |
|
|
23 |
read_value() |
read_value() |
24 |
{ |
{ |
59 |
done |
done |
60 |
} |
} |
61 |
|
|
62 |
|
updategrub2() |
63 |
|
{ |
64 |
|
# create a device.map |
65 |
|
if [[ ! -f /boot/grub/device.map ]] |
66 |
|
then |
67 |
|
grub-mkdevicemap |
68 |
|
fi |
69 |
|
|
70 |
|
# needed by grub-mkconfig on the first run |
71 |
|
if [[ ! -f /boot/grub/video.lst ]] |
72 |
|
then |
73 |
|
install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst |
74 |
|
fi |
75 |
|
|
76 |
|
# update grub.cfg |
77 |
|
grub-mkconfig -o /boot/grub/grub.cfg |
78 |
|
|
79 |
|
# install bootloader to disk |
80 |
|
local bootdisk |
81 |
|
bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" |
82 |
|
|
83 |
|
# Generate core.img, but don't let it be installed in boot sector |
84 |
|
grub-install --no-floppy "${bootdisk}" |
85 |
|
} |
86 |
|
|
87 |
# fix mage.rc |
# fix mage.rc |
88 |
CONFIG="${MAGERC}" |
CONFIG="${MAGERC}" |
89 |
updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
90 |
|
|
91 |
# fix config.rc |
# fix config.rc |
92 |
CONFIG="${CONFIGRC}" |
CONFIG="${CONFIGRC}" |
93 |
updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP |
updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS |
94 |
|
|
95 |
# fix profile |
# fix profile |
96 |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
127 |
touch /.dist-upgrade |
touch /.dist-upgrade |
128 |
fi |
fi |
129 |
|
|
130 |
|
# only run this if X11R6 is a directory and not a symlink |
131 |
|
if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] |
132 |
|
then |
133 |
|
# check for -f option |
134 |
|
if [[ -n $(magequery -h | grep -- -f) ]] |
135 |
|
then |
136 |
|
# uninstall all /usr/X11R6 packages first |
137 |
|
for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') |
138 |
|
do |
139 |
|
mage uninstall ${i} |
140 |
|
done |
141 |
|
fi |
142 |
|
|
143 |
|
# if there are any files after uninstall, simply delete them |
144 |
|
[ -d /usr/X11R6 ] && rm -rf /usr/X11R6 |
145 |
|
fi |
146 |
|
|
147 |
# install new toolchain if not exist |
# install new toolchain if not exist |
148 |
TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
149 |
if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
165 |
if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
166 |
then |
then |
167 |
# first keep some important files |
# first keep some important files |
168 |
|
|
169 |
|
# fix missing /dev/root device |
170 |
|
if [[ ! -e /dev/root ]] |
171 |
|
then |
172 |
|
rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1)) |
173 |
|
[[ ! -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root |
174 |
|
fi |
175 |
|
|
176 |
# export bootstrap to not start any services |
# export bootstrap to not start any services |
177 |
export MAGE_BOOTSTRAP=true |
export MAGE_BOOTSTRAP=true |
178 |
mage install ${BASESYSTEM} |
mage install ${BASESYSTEM} |
179 |
unset MAGE_BOOTSTRAP |
unset MAGE_BOOTSTRAP |
180 |
|
|
181 |
|
# # fix locale |
182 |
|
# echo "LANG=\"de_DE\"" > /etc/conf.d/locale |
183 |
|
|
184 |
# enable run of orphaned files check |
# enable run of orphaned files check |
185 |
touch /.orphaned |
touch /.orphaned |
186 |
|
|
197 |
touch /.orphaned |
touch /.orphaned |
198 |
fi |
fi |
199 |
|
|
|
# etc-update |
|
|
#etc-update |
|
|
|
|
200 |
# clean mage cache |
# clean mage cache |
201 |
mage clean |
mage clean |
202 |
|
|
205 |
do |
do |
206 |
# excludes |
# excludes |
207 |
case ${i} in |
case ${i} in |
208 |
|
alxconfig-ng) continue ;; |
209 |
|
alxinstall-ng) continue ;; |
210 |
kernel-alx) continue ;; |
kernel-alx) continue ;; |
211 |
kernel26-alx) continue ;; |
kernel26-alx) continue ;; |
212 |
kernel-sources-alx) continue ;; |
kernel-sources-alx) continue ;; |
217 |
mage uninstall ${i} |
mage uninstall ${i} |
218 |
done |
done |
219 |
|
|
220 |
|
if [[ -f /.orphaned ]] |
221 |
|
then |
222 |
|
echo "Searching for orphaned files and directories ..." |
223 |
|
bash /etc/mage-profile/prune-orphaned-files |
224 |
|
rm -f /.orphaned |
225 |
|
fi |
226 |
|
|
227 |
if [[ -f /.dist-upgrade ]] |
if [[ -f /.dist-upgrade ]] |
228 |
then |
then |
229 |
# array of wireless opts |
# array of wireless opts |
260 |
install -d /etc/modprobe.d |
install -d /etc/modprobe.d |
261 |
mv ${i} /etc/modprobe.d/${i%.conf}.conf |
mv ${i} /etc/modprobe.d/${i%.conf}.conf |
262 |
done |
done |
|
fi |
|
263 |
|
|
264 |
if [[ -f /.orphaned ]] |
mount /boot &> /dev/null |
265 |
then |
# install an appropriate uvesafb.conf |
266 |
echo "Searching for orphaned files and directories ..." |
install -d /etc/modprobe.d || die |
267 |
bash /etc/mage-profile/prune-orphaned-files |
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die |
268 |
rm -f /.orphaned |
# create an updated initrd |
269 |
|
DISKMODS="sd_mod" |
270 |
|
OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
271 |
|
PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
272 |
|
SATAMODS="sata_via sata_sis sata_nv" |
273 |
|
DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
274 |
|
FBMODS="uvesafb" |
275 |
|
echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd |
276 |
|
kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') |
277 |
|
mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} |
278 |
|
# update grub bootloader |
279 |
|
updategrub2 |
280 |
fi |
fi |
281 |
|
|
282 |
if [[ -f /.dist-upgrade ]] |
if [[ -f /.dist-upgrade ]] |
283 |
then |
then |
284 |
rm -f /.dist-upgrade |
echo "preparing a reboot in 60 seconds ..." |
285 |
# force a reboot at this point here |
# reboot via cronjob |
286 |
reboot -f |
[[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs |
287 |
|
# setup a proper cronjob |
288 |
|
tmp=$(mktemp) |
289 |
|
echo "* * * * * crontab -r && reboot -f" > ${tmp} |
290 |
|
crontab ${tmp} |
291 |
|
[[ -f ${tmp} ]] && rm -f ${tmp} |
292 |
|
# start cron daemon in background |
293 |
|
crond -b -S |
294 |
fi |
fi |
295 |
|
|
296 |
|
exit 0 |