Contents of /alx-src/branches/alxconf_20060908/bin/update-alx.sh
Parent Directory | Revision Log
Revision 308 -
(show annotations)
(download)
(as text)
Sun Aug 28 19:31:34 2005 UTC (19 years, 1 month ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/bin/update-alx.sh
File MIME type: application/x-sh
File size: 2941 byte(s)
Sun Aug 28 19:31:34 2005 UTC (19 years, 1 month ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/bin/update-alx.sh
File MIME type: application/x-sh
File size: 2941 byte(s)
- better messages - added a die functions and use it at critical points
1 | #!/bin/bash |
2 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/bin/update-alx.sh,v 1.2 2005-08-28 19:31:34 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="//${SQL_HOST}/magetmp" |
61 | USER="${SQL_USER}" |
62 | PASS="${SQL_PASS}" |
63 | |
64 | if [ $(diskfree /) -le ${MIN_SPACE} ]; then |
65 | echo "Mounting server '${SERVER_SHARE}' ..." |
66 | # make a secure tmp dir |
67 | if [ -x /bin/mktemp ]; then |
68 | TEMPDIR="$(/bin/mktemp -d)" |
69 | else |
70 | TEMPDIR="/tmp/tmp-$$" |
71 | fi |
72 | |
73 | # mount the server share to TEMPDIR |
74 | mount_server |
75 | |
76 | # now fake a new builddir so that multiple clients |
77 | # can use one server share |
78 | install -d ${TEMPDIR}/${HOSTNAME}/{mage,packages,tmp} |
79 | mount -o bind ${TEMPDIR}/${HOSTNAME}/tmp ${BUILDDIR} |
80 | # mount -o bind ${TEMPDIR}/${HOSTNAME}/mage ${MAGEDIR} |
81 | mount -o bind ${TEMPDIR}/${HOSTNAME}/packages ${PKGDIR} |
82 | fi |
83 | |
84 | echo "Running update ..." |
85 | # fetching new db |
86 | |
87 | echo "Fetching mage database update ..." |
88 | mage update > /dev/null || die "mage update" |
89 | |
90 | ### demo hotfix### |
91 | #cp /usr/mage/profiles/alx-041/* /etc/mage-profile |
92 | #cp /usr/mage/fake/basesystem041-alx/basesystem041-alx-0.3-r1.mage \ |
93 | # /usr/mage/fake/basesystem-alx/basesystem-alx-0.3-r1.mage |
94 | #sed -i 's:PKGNAME="basesystem041-alx-0.3-${ARCH}-r1":PKGNAME="basesystem-alx-0.3-${ARCH}-r1":g' \ |
95 | # /usr/mage/fake/basesystem-alx/basesystem-alx-0.3-r1.mage |
96 | |
97 | |
98 | # an to be sure mount boot (kernel updates !) |
99 | mount /boot &> /dev/null |
100 | |
101 | # first update mage |
102 | mage install mage-alx || die "install mage" |
103 | |
104 | # than clean forcefully all packages that does not fit the profile |
105 | if [ -f /etc/mage-profile/forced-uninstall ] |
106 | then |
107 | sh /etc/mage-profile/forced-uninstall |
108 | fi |
109 | |
110 | # than update the whole system |
111 | mageupgrade --no-calc --autoclean --autoanswer || die "system upgrade" #--debug |
112 | |
113 | # umount BUILDDIR |
114 | if is_mounted ${BUILDDIR}; then |
115 | umount ${BUILDDIR} |
116 | fi |
117 | |
118 | # umount MAGEDIR |
119 | if is_mounted ${MAGEDIR}; then |
120 | umount ${MAGEDIR} |
121 | fi |
122 | |
123 | if is_mounted ${PKGDIR}; then |
124 | umount ${PKGDIR} |
125 | fi |
126 | |
127 | # umount TEMPDIR |
128 | if is_mounted ${TEMPDIR}; then |
129 | umount_server |
130 | fi |
Properties
Name | Value |
---|---|
svn:executable | * |