3
# $Id: blend-update-menus 1296 2009-01-04 17:08:03Z tille $
6
echo "Usage: `basename $0` [ -u <user> | -b <Blend> ]"
7
echo "Blend: `getBlendList|tr ' ' '|'`"
8
echo "user: system user registerd to a Blend"
10
echo "run as user updates only the user's menu script"
13
# the base dir for Blends conffiles, where script expects to find dirs named like
14
# each registered Blend
15
CONFBASE=${CONFBASE:-/etc/blends}
17
# a local per Blend conf is sourced later, after argument parsing
18
. ${CONFBASE}/blends.conf
20
# specific utilities for blend-update-menus
21
. ${SHAREDIR}/blend-update-menus
23
# Get command line arguments
24
GETOPT=`getopt -o b:d:u:h --long blend:,user:,help -n "$0" -- "$@"`
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
39
blendLog "You must be root to specify --blend parameter"
43
elif [ -n "${BLENDUSER}" ]; then
44
blendLog "You cannot specify --blend and --user at the same time"
58
if ! amI root && ! amI "${BLENDUSER}"; then
59
blendLog "You must be root to specify --user parameter with a user that's not you"
62
elif [ "${BLENDUSER}" == 'root' ]; then
63
blendFail 64 "err: Menus for user 'root' cannot be updated"
64
elif [ -n "${BLEND}" ]; then
74
blendLog "$1 not recognized as option" >&2
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"
87
checkUser ${BLENDUSER} || \
88
blendFail 67 "User does not exist"
89
isUserRegistered ${BLENDUSER} || \
90
blendFail 67 "User ${BLENDUSER} is not registered to any Blend"
92
# there's nothing to do on per user basis criteria
93
#updateUser ${BLENDUSER} "${SYSSCRIPT}" "${USERSCRIPT}"
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
104
checkBlend ${BLEND} || \
105
blendFail $? "Debian Pure Blend ${BLEND} does not exist"
107
# there's nothing to do on per Blend basis criteria
108
#SYSSCRIPT="${SHAREDIR}/menu/blend-menu"
109
#updateBlend ${BLEND} "${SYSSCRIPT}"
112
exec $0 --user `whoami`