Annotation of /alx-src/branches/alxconf-060/bin/update-alx.sh
Parent Directory | Revision Log
Revision 543 -
(hide annotations)
(download)
(as text)
Wed Feb 4 19:51:39 2009 UTC (15 years, 7 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/alxconfig-ng/bin/update-alx.sh
File MIME type: application/x-sh
File size: 3199 byte(s)
Wed Feb 4 19:51:39 2009 UTC (15 years, 7 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/alxconfig-ng/bin/update-alx.sh
File MIME type: application/x-sh
File size: 3199 byte(s)
- created alxconf_20060908 branch for the stable-050 alx based on tag alxconf_20060908_1
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 | [ ! -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 | niro | 374 | SERVER_SHARE="${SMB_UPDATE_HOST}" |
61 | USER="${SMB_UPDATE_USER}" | ||
62 | PASS="${SMB_UPDATE_PASS}" | ||
63 | niro | 289 | |
64 | niro | 374 | # 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 | niro | 308 | if [ $(diskfree /) -le ${MIN_SPACE} ]; then |
70 | echo "Mounting server '${SERVER_SHARE}' ..." | ||
71 | niro | 289 | # 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 | niro | 308 | echo "Running update ..." |
90 | niro | 289 | # fetching new db |
91 | |||
92 | niro | 308 | echo "Fetching mage database update ..." |
93 | mage update > /dev/null || die "mage update" | ||
94 | |||
95 | niro | 289 | ### 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 | niro | 308 | mage install mage-alx || die "install mage" |
108 | niro | 289 | |
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 | niro | 308 | mageupgrade --no-calc --autoclean --autoanswer || die "system upgrade" #--debug |
117 | niro | 289 | |
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 | niro | 340 | |
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 | * |