File: config-gfarm-update.in

package info (click to toggle)
gfarm 2.3.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,972 kB
  • ctags: 10,894
  • sloc: ansic: 84,510; sh: 13,707; java: 6,866; makefile: 2,286; python: 771; perl: 325; sql: 130; xml: 50; asm: 37; csh: 2
file content (208 lines) | stat: -rw-r--r-- 4,007 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/bin/sh
#
# $Id$

${DEBUG:="false"} && set -xu
PROGNAME=`basename $0`

# LANG may cause trouble to access database
unset LANG

# Gfarm installation directory
prefix="@prefix@"
sysconfdir="@sysconfdir@"
config_dir="@datadir@/gfarm/config"

PATH="${prefix}/bin:${prefix}/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin:$PATH"
export PATH
search_path="$PATH"

awk=awk
if [ -f /usr/bin/nawk ]; then awk=/usr/bin/nawk; fi

status=1
admin_password=/tmp/ap$$
password=/tmp/up$$
rm -f $password $admin_password
trap 'rm -f $password $admin_password; stty echo 2>/dev/null; exit $status' 0 1 2 15

getvalue()
{
	$awk '$1 == "'"$1"'" { print $2 }' $GFMD_CONF
}

ABORT()
{
	[ $# -gt 0 ] && echo >&2 "${PROGNAME}: $@"
	echo >&2 "$PROGNAME failure"
	exit 1
}

update_usage_()
{
	return 1
}

usage()
{
	echo >&2 "usage: $PROGNAME [--help] [-t] [--update]"
	echo >&2 "	[-N]			- do not restart the server processes"
	echo >&2 "	[--prefix prefix]	- directory specified in config-gfarm"
	echo >&2 "	[-P backend_prefix]	- installation prefix of the backend program"
	echo >&2 "	[-l metadata_directory]	- backend database data directory"
	echo >&2 "	[-f backend_file]"
	update_usage_$BACKEND_TYPE ||
		echo >&2 "	no option for backend=$BACKEND_TYPE"
	exit 1
}

update_sanity_()
{
	return 0
}

update_sanity()
{
	update_sanity_$BACKEND_TYPE
}

# most $BACKEND_TYPE calls the followings
# from display_backend_params_$BACKEND_TYPE, but some may not.
display_backend_data_dir_param()
{
    echo     "metadata     directory    [-l]: $BACKEND_DATA_DIR"
}

display_backend_log_dir_param()
{
    return 0
}

display_params()
{
    echo     "prefix [--prefix]: $CONFIG_PREFIX"
    echo     "metadata backend    [-b]: $BACKEND_TYPE"

    display_backend_params_$BACKEND_TYPE
    display_backend_port_params_$BACKEND_TYPE
    display_backend_optional_params_$BACKEND_TYPE

    update_sanity
    exit 0
}

#
# parse arguments
#

: ${BACKEND_OPTIONS:=}

while [ $# -gt 0 ] ; do
	case $1 in

	# set parameters
	  --prefix) shift; [ $# -ge 1 ] || usage
		CONFIG_PREFIX=$1
		;;
	  -P) shift; [ $# -ge 1 ] || usage
		BACKEND_PREFIX=$1
		;;
	  -l) shift; [ $# -ge 1 ] || usage
		BACKEND_DATA_DIR=$1
		;;
	  -f) shift; [ $# -ge 1 ] || usage
		BACKEND_OPTIONS="$BACKEND_OPTIONS -f $1"
		;;

	# control options
	  --help)
		usage
		;;
	  -N)
		START_SERVICE=false
		;;
	  -t)
		DISPLAY_PARAMS=true
		;;
	  --update|--update-symlink) 
		UPDATE=true
		;;

	# XXX postgresql backend dependent option
	  -X)
		SUPPORT_XML_TYPE=yes
		;;
	  *)
		usage
		;;
	esac
	shift
done

: ${CONFIG_PREFIX:=}
if [ X"$CONFIG_PREFIX" != X ]; then
	: ${GFARM_CONF_DIR:="$CONFIG_PREFIX/etc"}
else
	: ${GFARM_CONF_DIR:="$sysconfdir"}
fi
: ${GFMD_CONF:="$GFARM_CONF_DIR/gfmd.conf"}

# sanity check
if [ ! -f ${GFMD_CONF} ]; then
	ABORT "${PROGNAME}: cannot find ${GFMD_CONF}, --prefix option required"
fi

# determine a backend database type
if grep '^[ 	]*postgresql_server_host[ 	]' ${GFMD_CONF} >/dev/null
then
	BACKEND_TYPE=postgresql
elif grep '^[ 	]*ldap_server_host[ 	]' ${GFMD_CONF} >/dev/null
then
	BACKEND_TYPE=ldap
else
	echo >&2 "${PROGNAME}: cannot determine the backend type"
	exit 1
fi

# load backend-dependent functions
. $config_dir/config-gfarm.$BACKEND_TYPE
. $config_dir/config-gfarm-update.$BACKEND_TYPE

#
# search default $BACKEND_PREFIX
#

set_default_backend_prefix_$BACKEND_TYPE
. $config_dir/config-gfarm.sysdep

#
# default values
#

set_first_defaults_$BACKEND_TYPE
sysdep_defaults

: ${DISPLAY_PARAMS:=false}
: ${START_SERVICE:=true}
: ${UPDATE:=false}

update_first_set_param_$BACKEND_TYPE
set_last_defaults_$BACKEND_TYPE
update_last_set_param_$BACKEND_TYPE

update_sanity || ABORT "aborted"

# -t option; display parameters
$DISPLAY_PARAMS && display_params

update_postprocess_$BACKEND_TYPE || ABORT "aborted"

#
if $UPDATE; then
	update_$BACKEND_TYPE
else
	update_access_db_$BACKEND_TYPE $BACKEND_OPTIONS
fi

status=0
# trap action automatically returns this $status as exit code