1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Id$ |
# $Id$ |
3 |
|
|
4 |
|
# setup exit trap for reboot |
5 |
|
trap_exit() |
6 |
|
{ |
7 |
|
if [[ -f /.dist-upgrade ]] |
8 |
|
then |
9 |
|
rm -f /.dist-upgrade |
10 |
|
# force a reboot at this point here |
11 |
|
( sleep 3 && reboot -f & ); exit 0 |
12 |
|
fi |
13 |
|
} |
14 |
|
trap "trap_exit" EXIT |
15 |
|
|
16 |
|
# get a suitable environment |
17 |
|
source /etc/profile |
18 |
|
|
19 |
MAGERC="/etc/mage.rc" |
MAGERC="/etc/mage.rc" |
20 |
MAGEPROFILE="alx-060" |
MAGEPROFILE="alx-060" |
21 |
NEW_MAGE_DISTRIBUTION="unstable" |
NEW_MAGE_DISTRIBUTION="unstable" |
24 |
NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
25 |
NEW_MAGE_UNINSTALL_TIMEOUT=0 |
NEW_MAGE_UNINSTALL_TIMEOUT=0 |
26 |
|
|
27 |
# fix mage.rc |
CONFIGRC="/etc/alxconfig-ng/config.rc" |
28 |
for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
NEW_ALX_NETWORKING="dhcp" |
29 |
do |
NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
30 |
value="$(eval echo \${NEW_${i}})" |
NEW_ALX_DHCP_START="-T 10" |
31 |
if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]] |
NEW_ALX_DHCP_STOP="" |
32 |
|
|
33 |
|
read_value() |
34 |
|
{ |
35 |
|
local file=$1 |
36 |
|
local var=$2 |
37 |
|
local value |
38 |
|
|
39 |
|
[[ ! -e ${file} ]] && return 1 |
40 |
|
|
41 |
|
value=$(source ${file}; echo $(eval echo \${${var}})) |
42 |
|
echo "${value}" |
43 |
|
return 0 |
44 |
|
} |
45 |
|
|
46 |
|
updateconfig() |
47 |
|
{ |
48 |
|
local variables="$@" |
49 |
|
local value |
50 |
|
local i |
51 |
|
|
52 |
|
if [[ -z ${CONFIG} ]] |
53 |
then |
then |
54 |
echo "fixing $i -> ${value}" |
echo "You must define \$CONFIG varibale first!" |
55 |
sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC} |
return 1 |
|
else |
|
|
echo "adding $i=${value}" |
|
|
echo "${i}=\"${value}\"" >> ${MAGERC} |
|
56 |
fi |
fi |
57 |
done |
|
58 |
|
for i in ${variables} |
59 |
|
do |
60 |
|
value="$(eval echo \${NEW_${i}})" |
61 |
|
if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]] |
62 |
|
then |
63 |
|
echo "fixing ${i} -> ${value}" |
64 |
|
sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG} |
65 |
|
else |
66 |
|
echo "adding ${i}=${value}" |
67 |
|
echo "${i}=\"${value}\"" >> ${CONFIG} |
68 |
|
fi |
69 |
|
done |
70 |
|
} |
71 |
|
|
72 |
|
# fix mage.rc |
73 |
|
CONFIG="${MAGERC}" |
74 |
|
updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
75 |
|
|
76 |
|
# fix config.rc |
77 |
|
CONFIG="${CONFIGRC}" |
78 |
|
updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP |
79 |
|
|
80 |
# fix profile |
# fix profile |
81 |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
107 |
|
|
108 |
# enable run of orphaned files check |
# enable run of orphaned files check |
109 |
touch /.orphaned |
touch /.orphaned |
110 |
|
|
111 |
|
# tell that we're running an dist-upgrade |
112 |
|
touch /.dist-upgrade |
113 |
fi |
fi |
114 |
|
|
115 |
# install new toolchain if not exist |
# install new toolchain if not exist |
123 |
|
|
124 |
# enable run of orphaned files check |
# enable run of orphaned files check |
125 |
touch /.orphaned |
touch /.orphaned |
126 |
|
|
127 |
|
# tell that we're running an dist-upgrade |
128 |
|
touch /.dist-upgrade |
129 |
fi |
fi |
130 |
|
|
131 |
# install new basesystem |
# install new basesystem |
141 |
|
|
142 |
# enable run of orphaned files check |
# enable run of orphaned files check |
143 |
touch /.orphaned |
touch /.orphaned |
144 |
|
|
145 |
|
# tell that we're running an dist-upgrade |
146 |
|
touch /.dist-upgrade |
147 |
fi |
fi |
148 |
|
|
149 |
# install remserial, if the plugin was enabled |
# install remserial, if the plugin was enabled |
155 |
touch /.orphaned |
touch /.orphaned |
156 |
fi |
fi |
157 |
|
|
158 |
|
# etc-update |
159 |
|
#etc-update |
160 |
|
|
161 |
# clean mage cache |
# clean mage cache |
162 |
mage clean |
mage clean |
163 |
|
|
|
# # uninstall all other deprecated -alx packages |
|
|
# DEPRECATED="bzip2 |
|
|
# gzip |
|
|
# perl |
|
|
# glib1 |
|
|
# openssl |
|
|
# popt |
|
|
# libungif |
|
|
# samba |
|
|
# dhcpcd |
|
|
# openssh |
|
|
# wget |
|
|
# cups |
|
|
# ddcxinfo-knoppix |
|
|
# debianutils |
|
|
# grep |
|
|
# inetutils |
|
|
# kbd |
|
|
# less |
|
|
# net-tools |
|
|
# pciutils |
|
|
# procps |
|
|
# psmisc |
|
|
# sed |
|
|
# shadow |
|
|
# sysvinit |
|
|
# tar |
|
|
# which |
|
|
# gtk1+ |
|
|
# ttmkfdir |
|
|
# xdialog" |
|
|
# |
|
|
# echo "Searching for deprecated packages ..." |
|
|
# for i in ${DEPRECATED} |
|
|
# do |
|
|
# if [[ ! -z $(magequery -n ${i}-alx) ]] |
|
|
# then |
|
|
# echo "Removing deprecated mage-target '${i}-alx'" |
|
|
# mage uninstall ${i}-alx |
|
|
# fi |
|
|
# done |
|
|
|
|
164 |
echo "Searching for deprecated packages ..." |
echo "Searching for deprecated packages ..." |
165 |
for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') |
for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') |
166 |
do |
do |
167 |
# excludes |
# excludes |
168 |
case ${i} in |
case ${i} in |
169 |
|
alxconfig-ng) continue ;; |
170 |
|
alxinstall-ng) continue ;; |
171 |
kernel-alx) continue ;; |
kernel-alx) continue ;; |
172 |
kernel26-alx) continue ;; |
kernel26-alx) continue ;; |
173 |
kernel-sources-alx) continue ;; |
kernel-sources-alx) continue ;; |
178 |
mage uninstall ${i} |
mage uninstall ${i} |
179 |
done |
done |
180 |
|
|
181 |
|
if [[ -f /.dist-upgrade ]] |
182 |
|
then |
183 |
|
# array of wireless opts |
184 |
|
WIRELESS_OPTS=( WIRELESS_BITRATE WIRELESS_CHANNEL WIRELESS_ESSID WIRELESS_FREQUENCY WIRELESS_MODE WIRELESS_NICK WIRELESS_AUTH_MODE WIRELESS_KEY_LENGTH WIRELESS_KEY WIRELESS_KEY_ASCII WIRELESS_WPA_DRIVER ) |
185 |
|
|
186 |
|
# fixing current dhcp network settings |
187 |
|
#for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*) |
188 |
|
for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*) |
189 |
|
do |
190 |
|
case ${i} in |
191 |
|
*/net.sample) continue ;; |
192 |
|
*/net.routes) continue ;; |
193 |
|
esac |
194 |
|
|
195 |
|
echo "fixing current dhcp network settings in '${i}'" |
196 |
|
mv ${i}{,.orig} |
197 |
|
onboot="$(read_value ${i}.orig ONBOOT)" |
198 |
|
echo "ONBOOT=\"${onboot}\"" > ${i} |
199 |
|
echo 'NETWORKING="dhcp"' >> ${i} |
200 |
|
# check wireless extensions |
201 |
|
for opt in ${WIRELESS_OPTS[*]} |
202 |
|
do |
203 |
|
value="$(read_value ${i}.orig ${opt})" |
204 |
|
if [[ ! -z ${value} ]] |
205 |
|
then |
206 |
|
echo "${opt}=\"${value}\"" >> ${i} |
207 |
|
fi |
208 |
|
done |
209 |
|
rm -f ${i}.orig |
210 |
|
done |
211 |
|
# search modules files |
212 |
|
for i in $(find /etc/modules.d -name net.\*) |
213 |
|
do |
214 |
|
install -d /etc/modprobe.d |
215 |
|
mv ${i} /etc/modprobe.d/${i%.conf}.conf |
216 |
|
done |
217 |
|
fi |
218 |
|
|
219 |
if [[ -f /.orphaned ]] |
if [[ -f /.orphaned ]] |
220 |
then |
then |
221 |
echo "Searching for orphaned files and directories ..." |
echo "Searching for orphaned files and directories ..." |
223 |
rm -f /.orphaned |
rm -f /.orphaned |
224 |
fi |
fi |
225 |
|
|
226 |
# force a reboot at this point here |
#if [[ -f /.dist-upgrade ]] |
227 |
reboot -f |
#then |
228 |
|
# rm -f /.dist-upgrade |
229 |
|
# # force a reboot at this point here |
230 |
|
# ( reboot -f & ); exit 0 |
231 |
|
#fi |