1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Id$ |
# $Id$ |
3 |
|
|
4 |
|
# get a suitable environment |
5 |
|
source /etc/profile |
6 |
|
|
7 |
|
MAGERC="/etc/mage.rc" |
8 |
|
MAGEPROFILE="alx-060" |
9 |
|
NEW_MAGE_DISTRIBUTION="unstable" |
10 |
|
NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" |
11 |
|
NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" |
12 |
|
NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
13 |
|
NEW_MAGE_UNINSTALL_TIMEOUT=0 |
14 |
|
|
15 |
|
CONFIGRC="/etc/alxconfig-ng/config.rc" |
16 |
|
NEW_ALX_NETWORKING="dhcp" |
17 |
|
NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
18 |
|
NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" |
19 |
|
NEW_ALX_DHCP_STOP="" |
20 |
|
NEW_MIN_DISK_SPACE="85000" |
21 |
|
NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins" |
22 |
|
NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions" |
23 |
|
|
24 |
|
# fake mage upgrade to prevent annoying error messages |
25 |
|
if [[ ! -x /usr/sbin/mageupgrade ]] |
26 |
|
then |
27 |
|
mageupgrade() { true; }; export -f mageupgrade |
28 |
|
fi |
29 |
|
|
30 |
read_value() |
read_value() |
31 |
{ |
{ |
32 |
local file=$1 |
local file=$1 |
40 |
return 0 |
return 0 |
41 |
} |
} |
42 |
|
|
43 |
MAGERC="/etc/mage.rc" |
updateconfig() |
44 |
MAGEPROFILE="alx-060" |
{ |
45 |
NEW_MAGE_DISTRIBUTION="unstable" |
local variables="$@" |
46 |
NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" |
local value |
47 |
NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" |
local i |
|
NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
|
|
NEW_MAGE_UNINSTALL_TIMEOUT=0 |
|
48 |
|
|
49 |
# fix mage.rc |
if [[ -z ${CONFIG} ]] |
|
for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
|
|
do |
|
|
value="$(eval echo \${NEW_${i}})" |
|
|
if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]] |
|
50 |
then |
then |
51 |
echo "fixing $i -> ${value}" |
echo "You must define \$CONFIG varibale first!" |
52 |
sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC} |
return 1 |
|
else |
|
|
echo "adding $i=${value}" |
|
|
echo "${i}=\"${value}\"" >> ${MAGERC} |
|
53 |
fi |
fi |
54 |
done |
|
55 |
|
for i in ${variables} |
56 |
|
do |
57 |
|
value="$(eval echo \${NEW_${i}})" |
58 |
|
if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]] |
59 |
|
then |
60 |
|
echo "fixing ${i} -> ${value}" |
61 |
|
sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG} |
62 |
|
else |
63 |
|
echo "adding ${i}=${value}" |
64 |
|
echo "${i}=\"${value}\"" >> ${CONFIG} |
65 |
|
fi |
66 |
|
done |
67 |
|
} |
68 |
|
|
69 |
|
updategrub2() |
70 |
|
{ |
71 |
|
# create a device.map |
72 |
|
if [[ ! -f /boot/grub/device.map ]] |
73 |
|
then |
74 |
|
grub-mkdevicemap |
75 |
|
fi |
76 |
|
|
77 |
|
# needed by grub-mkconfig on the first run |
78 |
|
if [[ ! -f /boot/grub/video.lst ]] |
79 |
|
then |
80 |
|
install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst |
81 |
|
fi |
82 |
|
|
83 |
|
# update grub.cfg |
84 |
|
grub-mkconfig -o /boot/grub/grub.cfg |
85 |
|
|
86 |
|
# install bootloader to disk |
87 |
|
local bootdisk |
88 |
|
bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" |
89 |
|
|
90 |
|
# Generate core.img, but don't let it be installed in boot sector |
91 |
|
grub-install --no-floppy "${bootdisk}" |
92 |
|
} |
93 |
|
|
94 |
|
# fix mage.rc |
95 |
|
CONFIG="${MAGERC}" |
96 |
|
updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
97 |
|
|
98 |
|
# fix config.rc |
99 |
|
CONFIG="${CONFIGRC}" |
100 |
|
updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS |
101 |
|
|
102 |
# fix profile |
# fix profile |
103 |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
106 |
ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile |
ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile |
107 |
fi |
fi |
108 |
|
|
109 |
|
# fix missing /dev/root device |
110 |
|
if [[ ! -e /dev/root ]] |
111 |
|
then |
112 |
|
echo "fixing missing /dev/root symlink ..." |
113 |
|
rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1)) |
114 |
|
[[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root |
115 |
|
fi |
116 |
|
|
117 |
# update mage3 -> mage4 |
# update mage3 -> mage4 |
118 |
if [[ -z $(magequery -n mage) ]] |
if [[ -z $(magequery -n mage) ]] |
119 |
then |
then |
142 |
touch /.dist-upgrade |
touch /.dist-upgrade |
143 |
fi |
fi |
144 |
|
|
145 |
|
# only run this if X11R6 is a directory and not a symlink |
146 |
|
if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] |
147 |
|
then |
148 |
|
# check for -f option |
149 |
|
if [[ -n $(magequery -h | grep -- -f) ]] |
150 |
|
then |
151 |
|
# uninstall all /usr/X11R6 packages first |
152 |
|
for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') |
153 |
|
do |
154 |
|
mage uninstall ${i} |
155 |
|
done |
156 |
|
fi |
157 |
|
|
158 |
|
# if there are any files after uninstall, simply delete them |
159 |
|
[ -d /usr/X11R6 ] && rm -rf /usr/X11R6 |
160 |
|
fi |
161 |
|
|
162 |
# install new toolchain if not exist |
# install new toolchain if not exist |
163 |
TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
164 |
if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
180 |
if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
181 |
then |
then |
182 |
# first keep some important files |
# first keep some important files |
183 |
|
|
184 |
# export bootstrap to not start any services |
# export bootstrap to not start any services |
185 |
export MAGE_BOOTSTRAP=true |
export MAGE_BOOTSTRAP=true |
186 |
mage install ${BASESYSTEM} |
mage install ${BASESYSTEM} |
187 |
unset MAGE_BOOTSTRAP |
unset MAGE_BOOTSTRAP |
188 |
|
|
189 |
|
# # fix locale |
190 |
|
# echo "LANG=\"de_DE\"" > /etc/conf.d/locale |
191 |
|
|
192 |
# enable run of orphaned files check |
# enable run of orphaned files check |
193 |
touch /.orphaned |
touch /.orphaned |
194 |
|
|
205 |
touch /.orphaned |
touch /.orphaned |
206 |
fi |
fi |
207 |
|
|
|
# etc-update |
|
|
#etc-update |
|
|
|
|
208 |
# clean mage cache |
# clean mage cache |
209 |
mage clean |
mage clean |
210 |
|
|
213 |
do |
do |
214 |
# excludes |
# excludes |
215 |
case ${i} in |
case ${i} in |
216 |
|
alxconfig-ng) continue ;; |
217 |
|
alxinstall-ng) continue ;; |
218 |
kernel-alx) continue ;; |
kernel-alx) continue ;; |
219 |
kernel26-alx) continue ;; |
kernel26-alx) continue ;; |
220 |
kernel-sources-alx) continue ;; |
kernel-sources-alx) continue ;; |
262 |
done |
done |
263 |
rm -f ${i}.orig |
rm -f ${i}.orig |
264 |
done |
done |
265 |
|
# search modules files |
266 |
|
for i in $(find /etc/modules.d -name net.\*) |
267 |
|
do |
268 |
|
install -d /etc/modprobe.d |
269 |
|
mv ${i} /etc/modprobe.d/${i%.conf}.conf |
270 |
|
done |
271 |
|
|
272 |
|
mount /boot &> /dev/null |
273 |
|
# install an appropriate uvesafb.conf |
274 |
|
install -d /etc/modprobe.d || die |
275 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die |
276 |
|
# create an updated initrd |
277 |
|
DISKMODS="sd_mod" |
278 |
|
OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
279 |
|
PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
280 |
|
SATAMODS="sata_via sata_sis sata_nv" |
281 |
|
DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
282 |
|
FBMODS="uvesafb" |
283 |
|
echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd |
284 |
|
kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') |
285 |
|
mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} |
286 |
|
# update grub bootloader |
287 |
|
updategrub2 |
288 |
fi |
fi |
289 |
|
|
290 |
if [[ -f /.dist-upgrade ]] |
if [[ -f /.dist-upgrade ]] |
291 |
then |
then |
292 |
|
echo "preparing a reboot in 60 seconds ..." |
293 |
|
# reboot via cronjob |
294 |
|
[[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs |
295 |
|
# setup a proper cronjob |
296 |
|
tmp=$(mktemp) |
297 |
|
echo "* * * * * crontab -r && reboot -f" > ${tmp} |
298 |
|
crontab ${tmp} |
299 |
|
[[ -f ${tmp} ]] && rm -f ${tmp} |
300 |
|
# start cron daemon in background |
301 |
|
crond -b -S |
302 |
|
|
303 |
rm -f /.dist-upgrade |
rm -f /.dist-upgrade |
|
# force a reboot at this point here |
|
|
reboot -f |
|
304 |
fi |
fi |
305 |
|
|
306 |
|
exit 0 |