Magellan Linux

Contents of /alx-src/trunk/alxconfig-ng/bin/update-alx.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (show annotations) (download) (as text)
Mon Feb 20 14:49:30 2006 UTC (18 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 3199 byte(s)
variable update servers

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

Properties

Name Value
svn:executable *