Magellan Linux

Annotation of /alx-src/branches/alxconf_20060908/bin/update-alx.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1581 - (hide annotations) (download) (as text)
Tue Nov 23 12:20:59 2010 UTC (13 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 2936 byte(s)
-complain verbosely if mount_server fails
-removed comments
-fixed spelling
1 niro 289 #!/bin/bash
2 niro 374 # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/bin/update-alx.sh,v 1.4 2006-02-20 14:49:30 niro Exp $
3 niro 289
4 niro 308 die()
5     {
6     echo
7     echo "Error: $@. Update *not* successfull."
8     exit 1
9     }
10    
11 niro 289 diskfree()
12     {
13     local dev="$1"
14     df -kP "${dev}" |grep "${dev}" | xargs | cut -d' ' -f4
15     }
16    
17    
18     mount_server()
19     {
20 niro 1581 local ret
21    
22 niro 289 [ ! -d ${TEMPDIR} ] && install -d ${TEMPDIR}
23     # use cifs only if supported
24     modprobe cifs &> /dev/null
25     if [ -n "$(cat /proc/filesystems | grep cifs)" ]
26     then
27     mount -t cifs "${SERVER_SHARE}" \
28     ${TEMPDIR} \
29     -o user="${USER}",pass="${PASS}"
30 niro 1581 ret="$?"
31 niro 289 else
32     # unix extensions must be enabled on server-side !
33     mount -t smbfs "${SERVER_SHARE}" \
34     ${TEMPDIR} \
35     -o username="${USER}",password="${PASS}"
36 niro 1581 ret="$?"
37 niro 289 fi
38    
39     sleep 3
40 niro 1581
41     return "${ret}"
42 niro 289 }
43    
44     umount_server()
45     {
46     umount ${TEMPDIR}
47     sleep 3
48     [ -d ${TEMPDIR} ] && rm -rf ${TEMPDIR}
49     }
50    
51     is_mounted()
52     {
53     local dev="$1"
54     # the spaces are neccessary -> to locate " / "
55     [ -n "$(cat /proc/mounts | grep " ${dev} ")" ] && return 0
56     return 1
57     }
58    
59     [[ $(whoami) != root ]] && ( echo "you must be r00t ..."; exit 1 )
60    
61     source /etc/mage.rc
62     source /etc/alxconfig-ng/config.rc
63    
64     # in kilobytes ! min 50MB are needed !!
65     MIN_SPACE=50000
66 niro 374 SERVER_SHARE="${SMB_UPDATE_HOST}"
67     USER="${SMB_UPDATE_USER}"
68     PASS="${SMB_UPDATE_PASS}"
69 niro 289
70 niro 374 # setup mage.rc
71     sed -i -e "s@^\(MIRRORS=\).*@\1\"${MAGE_MIRRORS}\"@" \
72     -e "s@^\(RSYNC=\).*@\1\"${MAGE_RSYNC}\"@" \
73     /etc/mage.rc || die "fixing /etc/mage.rc"
74    
75 niro 308 if [ $(diskfree /) -le ${MIN_SPACE} ]; then
76     echo "Mounting server '${SERVER_SHARE}' ..."
77 niro 289 # make a secure tmp dir
78     if [ -x /bin/mktemp ]; then
79     TEMPDIR="$(/bin/mktemp -d)"
80     else
81     TEMPDIR="/tmp/tmp-$$"
82     fi
83    
84     # mount the server share to TEMPDIR
85 niro 1581 mount_server || die "netshare mount failed, updated aborted."
86 niro 289
87     # now fake a new builddir so that multiple clients
88     # can use one server share
89     install -d ${TEMPDIR}/${HOSTNAME}/{mage,packages,tmp}
90     mount -o bind ${TEMPDIR}/${HOSTNAME}/tmp ${BUILDDIR}
91     # mount -o bind ${TEMPDIR}/${HOSTNAME}/mage ${MAGEDIR}
92     mount -o bind ${TEMPDIR}/${HOSTNAME}/packages ${PKGDIR}
93     fi
94    
95 niro 308 echo "Running update ..."
96 niro 289 # fetching new db
97    
98 niro 308 echo "Fetching mage database update ..."
99     mage update > /dev/null || die "mage update"
100    
101 niro 1581 # to be safe, mount boot (kernel updates !)
102 niro 289 mount /boot &> /dev/null
103    
104     # first update mage
105 niro 308 mage install mage-alx || die "install mage"
106 niro 289
107 niro 1581 # then clean forcefully all packages that does not fit the profile
108 niro 289 if [ -f /etc/mage-profile/forced-uninstall ]
109     then
110     sh /etc/mage-profile/forced-uninstall
111     fi
112    
113 niro 1581 # update the whole system
114 niro 308 mageupgrade --no-calc --autoclean --autoanswer || die "system upgrade" #--debug
115 niro 289
116     # umount BUILDDIR
117     if is_mounted ${BUILDDIR}; then
118     umount ${BUILDDIR}
119     fi
120    
121     # umount MAGEDIR
122     if is_mounted ${MAGEDIR}; then
123     umount ${MAGEDIR}
124     fi
125    
126     if is_mounted ${PKGDIR}; then
127     umount ${PKGDIR}
128     fi
129    
130     # umount TEMPDIR
131     if is_mounted ${TEMPDIR}; then
132     umount_server
133     fi
134 niro 340
135     ### check mage version for 0.>4.x-rxx
136     #/sbin/mage version | egrep v0.[4-9].[0-9]-r??
137    

Properties

Name Value
svn:executable *