Magellan Linux

Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2180 - (hide annotations) (download)
Wed May 18 22:55:40 2011 UTC (12 years, 11 months ago) by niro
File size: 4845 byte(s)
-set default to timeout after 10 seconds, not to send 10 packets

1 niro 2081 #!/bin/bash
2     # $Id$
3    
4 niro 2179 MAGERC="/etc/mage.rc"
5     MAGEPROFILE="alx-060"
6     NEW_MAGE_DISTRIBUTION="unstable"
7     NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"
8     NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"
9     NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
10     NEW_MAGE_UNINSTALL_TIMEOUT=0
11    
12     CONFIGRC="/etc/alxconfig-ng/config.rc"
13     NEW_ALX_NETWORKING="dhcp"
14     NEW_ALX_DHCP_PROG="/sbin/udhcpc"
15 niro 2180 NEW_ALX_DHCP_START="-T 10"
16 niro 2179 NEW_ALX_DHCP_STOP=""
17    
18 niro 2112 read_value()
19     {
20     local file=$1
21     local var=$2
22     local value
23    
24     [[ ! -e ${file} ]] && return 1
25    
26     value=$(source ${file}; echo $(eval echo \${${var}}))
27     echo "${value}"
28     return 0
29     }
30    
31 niro 2179 updateconfig()
32     {
33     local variables="$@"
34     local value
35     local i
36 niro 2081
37 niro 2179 if [[ -z ${CONFIG} ]]
38 niro 2081 then
39 niro 2179 echo "You must define \$CONFIG varibale first!"
40     return 1
41 niro 2081 fi
42    
43 niro 2179 for i in ${variables}
44     do
45     value="$(eval echo \${NEW_${i}})"
46     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
47     then
48     echo "fixing ${i} -> ${value}"
49     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
50     else
51     echo "adding ${i}=${value}"
52     echo "${i}=\"${value}\"" >> ${CONFIG}
53     fi
54     done
55     }
56    
57     # fix mage.rc
58     CONFIG="${MAGERC}"
59     updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
60    
61     # fix config.rc
62     CONFIG="${CONFIGRC}"
63     updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP
64    
65 niro 2081 # fix profile
66     if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
67     then
68     echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}"
69     ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile
70     fi
71    
72     # update mage3 -> mage4
73     if [[ -z $(magequery -n mage) ]]
74     then
75     # update mage tree
76     mage update
77    
78     # mage3 has problems with md5
79     rm -rf /usr/mage/app-mage/mage/md5
80     if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]]
81     then
82     USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage
83     elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]]
84     then
85     USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage
86     else
87     mage install mage
88     fi
89    
90     # drop all virtuals
91     :> /var/db/mage/virtuals
92    
93     # enable run of orphaned files check
94     touch /.orphaned
95 niro 2112
96     # tell that we're running an dist-upgrade
97     touch /.dist-upgrade
98 niro 2081 fi
99    
100     # install new toolchain if not exist
101     TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
102     if [[ -z $(magequery -n ${TOOLCHAIN}) ]]
103     then
104     # export bootstrap to not start any services
105     export MAGE_BOOTSTRAP=true
106     mage install ${TOOLCHAIN}
107     unset MAGE_BOOTSTRAP
108    
109     # enable run of orphaned files check
110     touch /.orphaned
111 niro 2112
112     # tell that we're running an dist-upgrade
113     touch /.dist-upgrade
114 niro 2081 fi
115    
116     # install new basesystem
117     BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)"
118     if [[ -z $(magequery -n ${BASESYSTEM}) ]]
119     then
120     # first keep some important files
121    
122     # export bootstrap to not start any services
123     export MAGE_BOOTSTRAP=true
124     mage install ${BASESYSTEM}
125     unset MAGE_BOOTSTRAP
126    
127     # enable run of orphaned files check
128     touch /.orphaned
129 niro 2112
130     # tell that we're running an dist-upgrade
131     touch /.dist-upgrade
132 niro 2081 fi
133    
134     # install remserial, if the plugin was enabled
135     if [[ ! -z $(magequery -n remserial-alx) ]]
136     then
137     mage install remserial
138    
139     # enable run of orphaned files check
140     touch /.orphaned
141     fi
142    
143 niro 2112 # etc-update
144     #etc-update
145    
146 niro 2081 # clean mage cache
147     mage clean
148    
149     echo "Searching for deprecated packages ..."
150     for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:')
151     do
152     # excludes
153     case ${i} in
154     kernel-alx) continue ;;
155     kernel26-alx) continue ;;
156     kernel-sources-alx) continue ;;
157     kernel26-sources-alx) continue ;;
158     esac
159    
160     echo "Removing deprecated mage-target '${i}'"
161     mage uninstall ${i}
162     done
163    
164 niro 2112 if [[ -f /.dist-upgrade ]]
165     then
166     # array of wireless opts
167     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 )
168    
169     # fixing current dhcp network settings
170     #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*)
171     for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*)
172     do
173     case ${i} in
174     */net.sample) continue ;;
175     */net.routes) continue ;;
176     esac
177    
178     echo "fixing current dhcp network settings in '${i}'"
179     mv ${i}{,.orig}
180     onboot="$(read_value ${i}.orig ONBOOT)"
181     echo "ONBOOT=\"${onboot}\"" > ${i}
182     echo 'NETWORKING="dhcp"' >> ${i}
183     # check wireless extensions
184     for opt in ${WIRELESS_OPTS[*]}
185     do
186     value="$(read_value ${i}.orig ${opt})"
187     if [[ ! -z ${value} ]]
188     then
189     echo "${opt}=\"${value}\"" >> ${i}
190     fi
191     done
192     rm -f ${i}.orig
193     done
194 niro 2117 # search modules files
195     for i in $(find /etc/modules.d -name net.\*)
196     do
197     install -d /etc/modprobe.d
198     mv ${i} /etc/modprobe.d/${i%.conf}.conf
199     done
200 niro 2112 fi
201    
202 niro 2117 if [[ -f /.orphaned ]]
203     then
204     echo "Searching for orphaned files and directories ..."
205     bash /etc/mage-profile/prune-orphaned-files
206     rm -f /.orphaned
207     fi
208    
209 niro 2112 if [[ -f /.dist-upgrade ]]
210     then
211     rm -f /.dist-upgrade
212     # force a reboot at this point here
213     reboot -f
214     fi