1 | #!/bin/sh |
---|
2 | # $Id: local-menus.sh,v 1.5 2005-11-04 17:27:10 ghudson Exp $ |
---|
3 | |
---|
4 | # Tar file containing menus (a symlink into the AFS system config area). |
---|
5 | menutar=/usr/athena/share/gnome/athena/menus.tar |
---|
6 | |
---|
7 | # Menu directory; used as a fallback if we can't make a local copy of |
---|
8 | # the menus. |
---|
9 | menudir=/usr/athena/share/gnome/athena/menus |
---|
10 | |
---|
11 | # Local copy of the menu tar file. |
---|
12 | localtar=/var/athena/menus.tar |
---|
13 | |
---|
14 | # Record of the release version of the last menu update |
---|
15 | versionfile=/var/athena/menus.version |
---|
16 | |
---|
17 | # Local copy of the menu directory (made from the tar file, not from |
---|
18 | # $menudir). |
---|
19 | localdir=/var/athena/menus.copy |
---|
20 | |
---|
21 | # What panel refers to; will be a symlink to either $localdir or |
---|
22 | # $menudir. |
---|
23 | menus=/var/athena/menus |
---|
24 | |
---|
25 | fail() { |
---|
26 | rm -f $menus $localtar # Removing $localtar ensures we will try again. |
---|
27 | ln -s $menudir $menus |
---|
28 | exit 1 |
---|
29 | } |
---|
30 | |
---|
31 | # Fail quietly if the menu tar file doesn't exist. |
---|
32 | if [ ! -s $menutar ]; then |
---|
33 | fail |
---|
34 | fi |
---|
35 | |
---|
36 | oldversion=none |
---|
37 | newversion=`/bin/athena/machtype -A` |
---|
38 | if [ -s $versionfile ]; then |
---|
39 | oldversion=`cat $versionfile` |
---|
40 | fi |
---|
41 | |
---|
42 | # Nothing to do if $localtar is up to date. (Check the $menutar |
---|
43 | # symlink as well as what it points to; after a full release, the |
---|
44 | # target of the symlink might not be newer than the last time we |
---|
45 | # updated, but the symlink itself will be newer.) |
---|
46 | if [ "x$oldversion" = "x$newversion" ] && \ |
---|
47 | [ -s $localtar ] && \ |
---|
48 | [ "`find $menutar -newer $localtar`" != $menutar ] && \ |
---|
49 | [ "`find $menutar -follow -newer $localtar`" != $menutar ]; then |
---|
50 | exit 0 |
---|
51 | fi |
---|
52 | |
---|
53 | # Update the local menus area. |
---|
54 | cp $menutar $localtar || fail |
---|
55 | rm -rf $localdir |
---|
56 | mkdir $localdir || fail |
---|
57 | (cd $localdir && tar xof $localtar) || fail |
---|
58 | chmod -R a+rX $localdir || fail |
---|
59 | rm -rf $menus |
---|
60 | ln -s $localdir $menus |
---|
61 | echo "$newversion" > $versionfile |
---|