Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 289 - (hide annotations) (download) (as text)
Thu Aug 18 02:50:17 2005 UTC (18 years, 9 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/bin/update-alx.sh
File MIME type: application/x-sh
File size: 2724 byte(s)
auto-update an alx wheehaaa ;)

1 niro 289 #!/bin/bash
2     # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/bin/update-alx.sh,v 1.1 2005-08-18 02:50:17 niro Exp $
3    
4     diskfree()
5     {
6     local dev="$1"
7     df -kP "${dev}" |grep "${dev}" | xargs | cut -d' ' -f4
8     }
9    
10    
11     mount_server()
12     {
13     [ ! -d ${TEMPDIR} ] && install -d ${TEMPDIR}
14     # use cifs only if supported
15     modprobe cifs &> /dev/null
16     if [ -n "$(cat /proc/filesystems | grep cifs)" ]
17     then
18     mount -t cifs "${SERVER_SHARE}" \
19     ${TEMPDIR} \
20     -o user="${USER}",pass="${PASS}"
21     else
22     # unix extensions must be enabled on server-side !
23     mount -t smbfs "${SERVER_SHARE}" \
24     ${TEMPDIR} \
25     -o username="${USER}",password="${PASS}"
26     fi
27    
28     sleep 3
29     }
30    
31     umount_server()
32     {
33     umount ${TEMPDIR}
34     sleep 3
35     [ -d ${TEMPDIR} ] && rm -rf ${TEMPDIR}
36     }
37    
38     is_mounted()
39     {
40     local dev="$1"
41     # the spaces are neccessary -> to locate " / "
42     [ -n "$(cat /proc/mounts | grep " ${dev} ")" ] && return 0
43     return 1
44     }
45    
46     [[ $(whoami) != root ]] && ( echo "you must be r00t ..."; exit 1 )
47    
48     source /etc/mage.rc
49     source /etc/alxconfig-ng/config.rc
50    
51     # in kilobytes ! min 50MB are needed !!
52     MIN_SPACE=50000
53     SERVER_SHARE="//${SQL_HOST}/magetmp"
54     USER="${SQL_USER}"
55     PASS="${SQL_PASS}"
56    
57     if [[ $(diskfree /) < ${MIN_SPACE} ]]; then
58     echo "mounting server"
59     # make a secure tmp dir
60     if [ -x /bin/mktemp ]; then
61     TEMPDIR="$(/bin/mktemp -d)"
62     else
63     TEMPDIR="/tmp/tmp-$$"
64     fi
65    
66     # mount the server share to TEMPDIR
67     mount_server
68    
69     # now fake a new builddir so that multiple clients
70     # can use one server share
71     install -d ${TEMPDIR}/${HOSTNAME}/{mage,packages,tmp}
72     mount -o bind ${TEMPDIR}/${HOSTNAME}/tmp ${BUILDDIR}
73     # mount -o bind ${TEMPDIR}/${HOSTNAME}/mage ${MAGEDIR}
74     mount -o bind ${TEMPDIR}/${HOSTNAME}/packages ${PKGDIR}
75     fi
76    
77     echo "running update"
78     # fetching new db
79     mage update
80    
81     ### demo hotfix###
82     #cp /usr/mage/profiles/alx-041/* /etc/mage-profile
83     #cp /usr/mage/fake/basesystem041-alx/basesystem041-alx-0.3-r1.mage \
84     # /usr/mage/fake/basesystem-alx/basesystem-alx-0.3-r1.mage
85     #sed -i 's:PKGNAME="basesystem041-alx-0.3-${ARCH}-r1":PKGNAME="basesystem-alx-0.3-${ARCH}-r1":g' \
86     # /usr/mage/fake/basesystem-alx/basesystem-alx-0.3-r1.mage
87    
88    
89     # an to be sure mount boot (kernel updates !)
90     mount /boot &> /dev/null
91    
92     # first update mage
93     mage install mage-alx
94    
95     # than clean forcefully all packages that does not fit the profile
96     if [ -f /etc/mage-profile/forced-uninstall ]
97     then
98     sh /etc/mage-profile/forced-uninstall
99     fi
100    
101     # than update the whole system
102     mageupgrade --no-calc --autoclean --autoanswer #--debug
103    
104     # umount BUILDDIR
105     if is_mounted ${BUILDDIR}; then
106     umount ${BUILDDIR}
107     fi
108    
109     # umount MAGEDIR
110     if is_mounted ${MAGEDIR}; then
111     umount ${MAGEDIR}
112     fi
113    
114     if is_mounted ${PKGDIR}; then
115     umount ${PKGDIR}
116     fi
117    
118     # umount TEMPDIR
119     if is_mounted ${TEMPDIR}; then
120     umount_server
121     fi

Properties

Name Value
svn:executable *