~ubuntu-branches/ubuntu/lucid/blends/lucid

« back to all changes in this revision

Viewing changes to blend-update-menus

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2009-01-30 19:30:53 UTC
  • Revision ID: james.westby@ubuntu.com-20090130193053-d1f9jj2wpqb74hph
Tags: 0.6.1
* Add sources.list.experimental
* debian/rules: variable for package name
* Remove explicite path /usr/sbin/ from blend-update-menus in
  templates/post{inst,rm} because lintian warns about it in the
  Blend metapackages according to Debian Policy Manual section
  6.1.
* more elegant method to obtain package version from changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# $Id: blend-update-menus 1296 2009-01-04 17:08:03Z tille $
 
4
 
 
5
usage() {
 
6
   echo "Usage: `basename $0` [ -u <user> | -b <Blend> ]"
 
7
   echo "Blend: `getBlendList|tr ' ' '|'`"
 
8
   echo "user:  system user registerd to a Blend"
 
9
   echo
 
10
   echo "run as user updates only the user's menu script"
 
11
}
 
12
 
 
13
# the base dir for Blends conffiles, where script expects to find dirs named like
 
14
# each registered Blend
 
15
CONFBASE=${CONFBASE:-/etc/blends}
 
16
 
 
17
# a local per Blend conf is sourced later, after argument parsing
 
18
. ${CONFBASE}/blends.conf
 
19
 
 
20
# specific utilities for blend-update-menus
 
21
. ${SHAREDIR}/blend-update-menus
 
22
 
 
23
# Get command line arguments
 
24
GETOPT=`getopt -o b:d:u:h --long blend:,user:,help -n "$0" -- "$@"`
 
25
eval set -- "$GETOPT"
 
26
while true
 
27
do
 
28
        case $1 in
 
29
                -h|--help)
 
30
            usage
 
31
            exit 0
 
32
            ;;
 
33
                # get blend name
 
34
                # for compatibility reasons we need to handle -d option
 
35
                # here as well because postrm of previousely installed
 
36
                # CDDs are using this option
 
37
                -b|--blend|-d)
 
38
                        if ! amI root; then
 
39
                                blendLog "You must be root to specify --blend parameter"
 
40
                                blendLog ""
 
41
                                usage
 
42
                                exit 64
 
43
                        elif [ -n "${BLENDUSER}" ]; then
 
44
                                blendLog "You cannot specify --blend and --user at the same time" 
 
45
                                blendLog ""
 
46
                                usage
 
47
                                exit 0
 
48
                        else
 
49
                                BLEND=$2
 
50
                                shift 2
 
51
                        fi
 
52
                        ;;
 
53
                # get user name
 
54
                -u|--user)
 
55
                        BLENDUSER=$2
 
56
                        shift 2
 
57
 
 
58
                        if ! amI root && ! amI "${BLENDUSER}"; then
 
59
                                blendLog  "You must be root to specify --user parameter with a user that's not you"
 
60
                                usage
 
61
                                exit 64
 
62
                        elif [ "${BLENDUSER}" == 'root' ]; then
 
63
                                blendFail 64 "err: Menus for user 'root' cannot be updated"
 
64
                        elif [ -n "${BLEND}" ]; then
 
65
                                usage
 
66
                                exit 0
 
67
                        fi
 
68
                        ;;
 
69
                --)
 
70
                        shift
 
71
                        break
 
72
                        ;;
 
73
                *)
 
74
                        blendLog "$1 not recognized as option" >&2
 
75
                        exit 67 # EX_USAGE
 
76
                        ;;
 
77
        esac
 
78
done
 
79
 
 
80
 
 
81
# update menu scripts for BLENDUSER, for any Blend, if any
 
82
if [ -n "${BLENDUSER}" ]; then 
 
83
        SYSSCRIPT="${SHAREDIR}/menu/blend-menu"
 
84
        USERSCRIPT="`getUserHome ${BLENDUSER}`/.menu/blend-menu"
 
85
 
 
86
        set -e
 
87
        checkUser ${BLENDUSER} || \
 
88
                blendFail 67 "User does not exist"
 
89
        isUserRegistered ${BLENDUSER} || \
 
90
                blendFail 67 "User ${BLENDUSER} is not registered to any Blend"
 
91
        
 
92
        # there's nothing to do on per user basis criteria
 
93
        #updateUser ${BLENDUSER} "${SYSSCRIPT}" "${USERSCRIPT}"
 
94
        set +e
 
95
 
 
96
# update menu scripts for any user registered into the specified Blend
 
97
elif [ -n "${BLEND}" ]; then 
 
98
        # Now that we know the selected Blend, we can check if there is a local
 
99
        # configuration for it (ie differnt backend from the default one)
 
100
        test -n "${BLEND}" -a  -f ${CONFBASE}/${BLEND}/${BLEND}.conf &&
 
101
                . ${CONFBASE}/${BLEND}/${BLEND}.conf
 
102
                
 
103
        set -e
 
104
        checkBlend ${BLEND} || \
 
105
                blendFail $? "Debian Pure Blend ${BLEND} does not exist"
 
106
                
 
107
        # there's nothing to do on per Blend basis criteria
 
108
        #SYSSCRIPT="${SHAREDIR}/menu/blend-menu"
 
109
        #updateBlend ${BLEND} "${SYSSCRIPT}"
 
110
        set +e
 
111
else
 
112
    exec $0 --user `whoami`
 
113
fi