Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall
Parent Directory | Revision Log
Revision 2181 -
(hide annotations)
(download)
Tue Jun 7 12:32:27 2011 UTC (12 years, 11 months ago) by niro
File size: 5177 byte(s)
Tue Jun 7 12:32:27 2011 UTC (12 years, 11 months ago) by niro
File size: 5177 byte(s)
-setup a trap for EXIT and reboot at exit -source environment -exclude alxconfig-ng and alxinstall-ng
1 | niro | 2081 | #!/bin/bash |
2 | # $Id$ | ||
3 | |||
4 | niro | 2181 | # 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 | niro | 2179 | MAGERC="/etc/mage.rc" |
20 | MAGEPROFILE="alx-060" | ||
21 | NEW_MAGE_DISTRIBUTION="unstable" | ||
22 | NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" | ||
23 | NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" | ||
24 | NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' | ||
25 | NEW_MAGE_UNINSTALL_TIMEOUT=0 | ||
26 | |||
27 | CONFIGRC="/etc/alxconfig-ng/config.rc" | ||
28 | NEW_ALX_NETWORKING="dhcp" | ||
29 | NEW_ALX_DHCP_PROG="/sbin/udhcpc" | ||
30 | niro | 2180 | NEW_ALX_DHCP_START="-T 10" |
31 | niro | 2179 | NEW_ALX_DHCP_STOP="" |
32 | |||
33 | niro | 2112 | 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 | niro | 2179 | updateconfig() |
47 | { | ||
48 | local variables="$@" | ||
49 | local value | ||
50 | local i | ||
51 | niro | 2081 | |
52 | niro | 2179 | if [[ -z ${CONFIG} ]] |
53 | niro | 2081 | then |
54 | niro | 2179 | echo "You must define \$CONFIG varibale first!" |
55 | return 1 | ||
56 | niro | 2081 | fi |
57 | |||
58 | niro | 2179 | 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 | niro | 2081 | # fix profile |
81 | if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] | ||
82 | then | ||
83 | echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}" | ||
84 | ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile | ||
85 | fi | ||
86 | |||
87 | # update mage3 -> mage4 | ||
88 | if [[ -z $(magequery -n mage) ]] | ||
89 | then | ||
90 | # update mage tree | ||
91 | mage update | ||
92 | |||
93 | # mage3 has problems with md5 | ||
94 | rm -rf /usr/mage/app-mage/mage/md5 | ||
95 | if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]] | ||
96 | then | ||
97 | USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage | ||
98 | elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]] | ||
99 | then | ||
100 | USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage | ||
101 | else | ||
102 | mage install mage | ||
103 | fi | ||
104 | |||
105 | # drop all virtuals | ||
106 | :> /var/db/mage/virtuals | ||
107 | |||
108 | # enable run of orphaned files check | ||
109 | touch /.orphaned | ||
110 | niro | 2112 | |
111 | # tell that we're running an dist-upgrade | ||
112 | touch /.dist-upgrade | ||
113 | niro | 2081 | fi |
114 | |||
115 | # install new toolchain if not exist | ||
116 | TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" | ||
117 | if [[ -z $(magequery -n ${TOOLCHAIN}) ]] | ||
118 | then | ||
119 | # export bootstrap to not start any services | ||
120 | export MAGE_BOOTSTRAP=true | ||
121 | mage install ${TOOLCHAIN} | ||
122 | unset MAGE_BOOTSTRAP | ||
123 | |||
124 | # enable run of orphaned files check | ||
125 | touch /.orphaned | ||
126 | niro | 2112 | |
127 | # tell that we're running an dist-upgrade | ||
128 | touch /.dist-upgrade | ||
129 | niro | 2081 | fi |
130 | |||
131 | # install new basesystem | ||
132 | BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" | ||
133 | if [[ -z $(magequery -n ${BASESYSTEM}) ]] | ||
134 | then | ||
135 | # first keep some important files | ||
136 | |||
137 | # export bootstrap to not start any services | ||
138 | export MAGE_BOOTSTRAP=true | ||
139 | mage install ${BASESYSTEM} | ||
140 | unset MAGE_BOOTSTRAP | ||
141 | |||
142 | # enable run of orphaned files check | ||
143 | touch /.orphaned | ||
144 | niro | 2112 | |
145 | # tell that we're running an dist-upgrade | ||
146 | touch /.dist-upgrade | ||
147 | niro | 2081 | fi |
148 | |||
149 | # install remserial, if the plugin was enabled | ||
150 | if [[ ! -z $(magequery -n remserial-alx) ]] | ||
151 | then | ||
152 | mage install remserial | ||
153 | |||
154 | # enable run of orphaned files check | ||
155 | touch /.orphaned | ||
156 | fi | ||
157 | |||
158 | niro | 2112 | # etc-update |
159 | #etc-update | ||
160 | |||
161 | niro | 2081 | # clean mage cache |
162 | mage clean | ||
163 | |||
164 | echo "Searching for deprecated packages ..." | ||
165 | for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') | ||
166 | do | ||
167 | # excludes | ||
168 | case ${i} in | ||
169 | niro | 2181 | alxconfig-ng) continue ;; |
170 | alxinstall-ng) continue ;; | ||
171 | niro | 2081 | kernel-alx) continue ;; |
172 | kernel26-alx) continue ;; | ||
173 | kernel-sources-alx) continue ;; | ||
174 | kernel26-sources-alx) continue ;; | ||
175 | esac | ||
176 | |||
177 | echo "Removing deprecated mage-target '${i}'" | ||
178 | mage uninstall ${i} | ||
179 | done | ||
180 | |||
181 | niro | 2112 | 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 | niro | 2117 | # 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 | niro | 2112 | fi |
218 | |||
219 | niro | 2117 | if [[ -f /.orphaned ]] |
220 | then | ||
221 | echo "Searching for orphaned files and directories ..." | ||
222 | bash /etc/mage-profile/prune-orphaned-files | ||
223 | rm -f /.orphaned | ||
224 | fi | ||
225 | |||
226 | niro | 2181 | #if [[ -f /.dist-upgrade ]] |
227 | #then | ||
228 | # rm -f /.dist-upgrade | ||
229 | # # force a reboot at this point here | ||
230 | # ( reboot -f & ); exit 0 | ||
231 | #fi |