Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2572 by niro, Mon Jul 4 21:21:17 2011 UTC revision 8048 by niro, Wed Dec 30 09:15:29 2015 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Id$  # $Id$
3    
 # setup exit trap for reboot  
 trap_exit()  
 {  
  if [[ -f /.dist-upgrade ]]  
  then  
  rm -f /.dist-upgrade  
  # force a reboot at this point here  
  ( sleep 3 && reboot -f & ); exit 0  
  fi  
 }  
 trap "trap_exit" EXIT  
   
4  # get a suitable environment  # get a suitable environment
5  source /etc/profile  source /etc/profile
6    
7    PATH="/etc/mage-profile:${PATH}"
8    
9  MAGERC="/etc/mage.rc"  MAGERC="/etc/mage.rc"
10  MAGEPROFILE="alx-060"  MAGEPROFILE="alx-060"
11  NEW_MAGE_DISTRIBUTION="unstable"  NEW_MAGE_DISTRIBUTION="unstable"
12  NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"  #NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"
13  NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"  #NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"
14    NEW_RSYNC="rsync://128.20.41.110/mage-alx-060"
15    NEW_MIRRORS="http://128.20.41.110/magellan/alx-060"
16  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
17  NEW_MAGE_UNINSTALL_TIMEOUT=0  NEW_MAGE_UNINSTALL_TIMEOUT=0
18    
19  CONFIGRC="/etc/alxconfig-ng/config.rc"  CONFIGRC="/etc/alxconfig-ng/config.rc"
20  NEW_ALX_NETWORKING="dhcp"  NEW_ALX_NETWORKING="dhcp"
21  NEW_ALX_DHCP_PROG="/sbin/udhcpc"  NEW_ALX_DHCP_PROG="/sbin/dhcpc"
22  NEW_ALX_DHCP_START="-T 10 -t 5 -n -i"  NEW_ALX_DHCP_START="-t 10"
23  NEW_ALX_DHCP_STOP=""  NEW_ALX_DHCP_STOP="-k"
24  NEW_MIN_DISK_SPACE="85000"  NEW_MIN_DISK_SPACE="85000"
25    NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins"
26    NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions"
27    
28    # fake mage upgrade to prevent annoying error messages
29    if [[ ! -x /usr/sbin/mageupgrade ]]
30    then
31     mageupgrade() { true; }; export -f mageupgrade
32    fi
33    
34  read_value()  read_value()
35  {  {
# Line 70  updateconfig() Line 70  updateconfig()
70   done   done
71  }  }
72    
73    updategrub2()
74    {
75     # create a device.map
76     if [[ ! -f /boot/grub/device.map ]]
77     then
78     grub-mkdevicemap
79     fi
80    
81     # needed by grub-mkconfig on the first run
82     if [[ ! -f /boot/grub/video.lst ]]
83     then
84     install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst
85     fi
86    
87     # update grub.cfg
88     grub-mkconfig -o /boot/grub/grub.cfg
89    
90     # install bootloader to disk
91     local bootdisk
92     bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
93    
94     # Generate core.img, but don't let it be installed in boot sector
95     grub-install --no-floppy "${bootdisk}"
96    }
97    
98    # checks size of the mbr, if we are able to install grub2
99    check_mbr_size()
100    {
101     local hdd="$1"
102     local geometry_sectors
103     local partition_start_sector
104     local retval
105    
106     hdd="$(mount | grep '/dev/' | grep ' / ' | cut -d' ' -f1 | sed 's:\(.*\)[0-9].*:\1:')"
107    
108     if [[ -z ${hdd} ]]
109     then
110     echo "check_mbr_size(): No hdd given, aborting"
111     return 1
112     fi
113    
114     # fix permissions
115     chmod +x /etc/mage-profile/sfdisk > /dev/null
116    
117     # default retval is 0
118     retval=0
119    
120     # check only if disk size is below 256mb
121     if [[ $(sfdisk -s ${hdd}) -lt 257000 ]]
122     then
123     geometry_sectors=$(sfdisk -g ${hdd} | sed 's:.*,\ \([0-9].*\)\ sectors.*:\1:')
124     partition_start_sector=$(sfdisk -d /dev/hda | grep /dev/hda1 | sed -e 's:.*start=\(.*\), size.*:\1:' -e 's:\ ::g')
125    
126     # check start_sector / geomtry > 1 then everything is fine, else abort setup as grub may not install!
127     if [[ $(expr ${partition_start_sector} / ${geometry_sectors}) -gt 1 ]]
128     then
129     echo "Current partition setup is big enough, to install grub2 mbr to this disk."
130     retval=0
131     else
132     echo "Warning: Current partition setup to small, cannot install grub2 boot-sector to this disk."
133     echo "Maybe this is a *RANGEE* with a flash-disk =<256MB. Please re-install this client."
134     echo "Upgrade *not* supported!"
135     retval=1
136     killall mage &> /dev/null
137     killall update-alx &> /dev/null
138     fi
139     else
140     echo "Current disk is big enough, to install grub2 mbr to this disk."
141     retval=0
142     fi
143    
144     return "${retval}"
145    }
146    
147  # fix mage.rc  # fix mage.rc
148  CONFIG="${MAGERC}"  CONFIG="${MAGERC}"
149  updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT  updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
150    
151  # fix config.rc  # fix config.rc
152  CONFIG="${CONFIGRC}"  CONFIG="${CONFIGRC}"
153  updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE  updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS
154    
155    # fix eth0 config too
156    CONFIG="/etc/conf.d/net.eth0"
157    eval "NEW_DHCP_PROG=\"${NEW_ALX_DHCP_PROG}\"" # eval this twice
158    eval "NEW_DHCP_PROG=\"${NEW_DHCP_PROG}\"" # to remove the \\ escapes
159    #
160    eval "NEW_DHCP_START=\"${NEW_ALX_DHCP_START}\"" # eval this twice
161    eval "NEW_DHCP_START=\"${NEW_DHCP_START}\"" # to remove the \\ escapes
162    #
163    eval "NEW_DHCP_STOP=\"${NEW_ALX_DHCP_STOP}\"" # eval this twice
164    eval "NEW_DHCP_STOP=\"${NEW_DHCP_STOP}\"" # to remove the \\ escapes
165    updateconfig DHCP_PROG DHCP_START DHCP_STOP
166    
167  # fix profile  # fix profile
168  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
# Line 85  then Line 171  then
171   ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile   ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile
172  fi  fi
173    
174    # fix missing /dev/root device
175    if [[ ! -e /dev/root ]]
176    then
177     echo "fixing missing /dev/root symlink ..."
178     rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1))
179     [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root
180    fi
181    
182    check_mbr_size || exit 1
183    
184  # update mage3 -> mage4  # update mage3 -> mage4
185  if [[ -z $(magequery -n mage) ]]  if [[ -z $(magequery -n mage) ]]
186  then  then
# Line 113  then Line 209  then
209   touch /.dist-upgrade   touch /.dist-upgrade
210  fi  fi
211    
212  # check for -f option  # only run this if X11R6 is a directory and not a symlink
213  if [[ -n $(magequery -h | grep -- -f) ]]  if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]]
214  then  then
215   # uninstall all /usr/X11R6 packages first   # check for -f option
216   for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')   if [[ -n $(magequery -h | grep -- -f) ]]
217   do   then
218   mage uninstall ${i}   # uninstall all /usr/X11R6 packages first
219   done   for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')
220     do
221     mage uninstall ${i}
222     done
223     fi
224    
225     # if there are any files after uninstall, simply delete them
226     [ -d /usr/X11R6 ] && rm -rf /usr/X11R6
227  fi  fi
 # if /usr/X11R6 is a directoy, simply delete it with the content  
 [ -d /usr/X11R6 ] && rm -rf /usr/X11R6  
228    
229  # install new toolchain if not exist  # install new toolchain if not exist
230  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
# Line 146  BASESYSTEM="$(< /etc/mage-profile/basesy Line 247  BASESYSTEM="$(< /etc/mage-profile/basesy
247  if [[ -z $(magequery -n ${BASESYSTEM}) ]]  if [[ -z $(magequery -n ${BASESYSTEM}) ]]
248  then  then
249   # first keep some important files   # first keep some important files
250    
251   # export bootstrap to not start any services   # export bootstrap to not start any services
252   export MAGE_BOOTSTRAP=true   export MAGE_BOOTSTRAP=true
253   mage install ${BASESYSTEM}   mage install ${BASESYSTEM}
254   unset MAGE_BOOTSTRAP   unset MAGE_BOOTSTRAP
255    
256    # # fix locale
257    # echo "LANG=\"de_DE\"" > /etc/conf.d/locale
258    
259   # enable run of orphaned files check   # enable run of orphaned files check
260   touch /.orphaned   touch /.orphaned
261    
# Line 168  then Line 272  then
272   touch /.orphaned   touch /.orphaned
273  fi  fi
274    
 # etc-update  
 #etc-update  
   
275  # clean mage cache  # clean mage cache
276  mage clean  mage clean
277    
# Line 191  do Line 292  do
292   mage uninstall ${i}   mage uninstall ${i}
293  done  done
294    
295    if [[ -f /.orphaned ]]
296    then
297     echo "Searching for orphaned files and directories ..."
298     bash /etc/mage-profile/prune-orphaned-files
299     rm -f /.orphaned
300    fi
301    
302  if [[ -f /.dist-upgrade ]]  if [[ -f /.dist-upgrade ]]
303  then  then
304     # busybox gets installed before the new busybox initscripts
305     # and the syslog daemon gets started at the wrong runlevels (rc3.d instead of rc.sysinit)
306     # these runlevel symlinks will be deleted by the prune-orphaned-files script
307     # and syslogd will be left never started. so add syslogd here
308     rc-config add syslogd
309    
310   # array of wireless opts   # array of wireless opts
311   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 )   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 )
312    
# Line 227  then Line 341  then
341   install -d /etc/modprobe.d   install -d /etc/modprobe.d
342   mv ${i} /etc/modprobe.d/${i%.conf}.conf   mv ${i} /etc/modprobe.d/${i%.conf}.conf
343   done   done
344    
345     mount /boot &> /dev/null
346     # install an appropriate uvesafb.conf
347     install -d /etc/modprobe.d || die
348     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die
349     # install an appropriate viafb.conf
350     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > /etc/modprobe.d/viafb.conf || die
351     # install an appropriate i810fb.conf
352     echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"  > /etc/modprobe.d/i810fb.conf || die
353     # create an updated initrd
354     DISKMODS="sd_mod"
355     OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
356     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
357     SATAMODS="sata_via sata_sis sata_nv"
358     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
359     if [ -x /usr/sbin/alx-hwdetection ]
360     then
361     case $(/usr/sbin/alx-hwdetection system) in
362     zotac) FBMODS="" ;;
363     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
364     maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb framebuffer
365     standard) FBMODS="uvesafb" ;;
366     # unknown, use nothing to be safe
367     *) FBMODS="" ;;
368     esac
369     else
370     # unknown, use nothing to be safe
371     FBMODS=""
372     fi
373     echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
374     kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::')
375     # run depmod before
376     depmod -aF /boot/System.map-${kernelver}
377     mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver}
378     # update grub bootloader
379     updategrub2
380  fi  fi
381    
382  if [[ -f /.orphaned ]]  if [[ -f /.dist-upgrade ]]
383  then  then
384   echo "Searching for orphaned files and directories ..."   if [[ ${NOREBOOT} != 1 ]]
385   bash /etc/mage-profile/prune-orphaned-files   then
386   rm -f /.orphaned   echo "preparing for a reboot in 60 seconds ..."
387     # reboot via cronjob
388     [[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs
389     # setup a proper cronjob
390     tmp=$(mktemp)
391     :> ${tmp}
392     # fake mageupgrade to fix annoying error messages
393     if [[ ! -x /sbin/mageupgrade ]]
394     then
395     echo '#!/bin/sh' > /sbin/mageupgrade
396     echo 'exit 0'  >> /sbin/mageupgrade
397     chmod +x /sbin/mageupgrade
398     echo "* * * * * rm /sbin/mageupgrade" >> ${tmp}
399     fi
400     echo "* * * * * crontab -r && reboot -f" >> ${tmp}
401     crontab ${tmp}
402     [[ -f ${tmp} ]] && rm -f ${tmp}
403     # start cron daemon in background
404     crond -b -S
405     fi
406    
407     rm -f /.dist-upgrade
408  fi  fi
409    
410  #if [[ -f /.dist-upgrade ]]  exit 0
 #then  
 # rm -f /.dist-upgrade  
 # # force a reboot at this point here  
 # ( reboot -f & ); exit 0  
 #fi  

Legend:
Removed from v.2572  
changed lines
  Added in v.8048