1 | #!/bin/sh |
---|
2 | # |
---|
3 | # |
---|
4 | # OpenPBS (Portable Batch System) v2.3 Software License |
---|
5 | # |
---|
6 | # Copyright (c) 1999-2000 Veridian Information Solutions, Inc. |
---|
7 | # All rights reserved. |
---|
8 | # |
---|
9 | # --------------------------------------------------------------------------- |
---|
10 | # For a license to use or redistribute the OpenPBS software under conditions |
---|
11 | # other than those described below, or to purchase support for this software, |
---|
12 | # please contact Veridian Systems, PBS Products Department ("Licensor") at: |
---|
13 | # |
---|
14 | # www.OpenPBS.org +1 650 967-4675 sales@OpenPBS.org |
---|
15 | # 877 902-4PBS (US toll-free) |
---|
16 | # --------------------------------------------------------------------------- |
---|
17 | # |
---|
18 | # This license covers use of the OpenPBS v2.3 software (the "Software") at |
---|
19 | # your site or location, and, for certain users, redistribution of the |
---|
20 | # Software to other sites and locations. Use and redistribution of |
---|
21 | # OpenPBS v2.3 in source and binary forms, with or without modification, |
---|
22 | # are permitted provided that all of the following conditions are met. |
---|
23 | # After December 31, 2001, only conditions 3-6 must be met: |
---|
24 | # |
---|
25 | # 1. Commercial and/or non-commercial use of the Software is permitted |
---|
26 | # provided a current software registration is on file at www.OpenPBS.org. |
---|
27 | # If use of this software contributes to a publication, product, or |
---|
28 | # service, proper attribution must be given; see www.OpenPBS.org/credit.html |
---|
29 | # |
---|
30 | # 2. Redistribution in any form is only permitted for non-commercial, |
---|
31 | # non-profit purposes. There can be no charge for the Software or any |
---|
32 | # software incorporating the Software. Further, there can be no |
---|
33 | # expectation of revenue generated as a consequence of redistributing |
---|
34 | # the Software. |
---|
35 | # |
---|
36 | # 3. Any Redistribution of source code must retain the above copyright notice |
---|
37 | # and the acknowledgment contained in paragraph 6, this list of conditions |
---|
38 | # and the disclaimer contained in paragraph 7. |
---|
39 | # |
---|
40 | # 4. Any Redistribution in binary form must reproduce the above copyright |
---|
41 | # notice and the acknowledgment contained in paragraph 6, this list of |
---|
42 | # conditions and the disclaimer contained in paragraph 7 in the |
---|
43 | # documentation and/or other materials provided with the distribution. |
---|
44 | # |
---|
45 | # 5. Redistributions in any form must be accompanied by information on how to |
---|
46 | # obtain complete source code for the OpenPBS software and any |
---|
47 | # modifications and/or additions to the OpenPBS software. The source code |
---|
48 | # must either be included in the distribution or be available for no more |
---|
49 | # than the cost of distribution plus a nominal fee, and all modifications |
---|
50 | # and additions to the Software must be freely redistributable by any party |
---|
51 | # (including Licensor) without restriction. |
---|
52 | # |
---|
53 | # 6. All advertising materials mentioning features or use of the Software must |
---|
54 | # display the following acknowledgment: |
---|
55 | # |
---|
56 | # "This product includes software developed by NASA Ames Research Center, |
---|
57 | # Lawrence Livermore National Laboratory, and Veridian Information |
---|
58 | # Solutions, Inc. |
---|
59 | # Visit www.OpenPBS.org for OpenPBS software support, |
---|
60 | # products, and information." |
---|
61 | # |
---|
62 | # 7. DISCLAIMER OF WARRANTY |
---|
63 | # |
---|
64 | # THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ANY EXPRESS |
---|
65 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
66 | # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT |
---|
67 | # ARE EXPRESSLY DISCLAIMED. |
---|
68 | # |
---|
69 | # IN NO EVENT SHALL VERIDIAN CORPORATION, ITS AFFILIATED COMPANIES, OR THE |
---|
70 | # U.S. GOVERNMENT OR ANY OF ITS AGENCIES BE LIABLE FOR ANY DIRECT OR INDIRECT, |
---|
71 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
72 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
---|
73 | # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
74 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
75 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
---|
76 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
77 | # |
---|
78 | # This license will be governed by the laws of the Commonwealth of Virginia, |
---|
79 | # without reference to its choice of law rules. |
---|
80 | # pbs_mkdirs: |
---|
81 | # |
---|
82 | # This will make the various directories that are needed for PBS |
---|
83 | # housekeeping. |
---|
84 | # |
---|
85 | # Usage: |
---|
86 | # pbs_mkdirs [-v] [-c] [-C chk_tree_location] what |
---|
87 | # -v be verbose |
---|
88 | # -c allow usage of chk_tree (do not use this within a make install) |
---|
89 | # -C Specify where the location of the chk_tree binary |
---|
90 | # what select from the following list |
---|
91 | # server -- dirs needed by pbs_server |
---|
92 | # mom -- dirs needed by pbs_mom |
---|
93 | # aux -- the aux directory |
---|
94 | # default -- the default file |
---|
95 | # common -- make common directory to all daemons |
---|
96 | # check -- run chk_tree (turns on -c automatically) |
---|
97 | # all -- do all of the above |
---|
98 | # |
---|
99 | # SVN INFO: |
---|
100 | # $Id: pbs_mkdirs.in 2044 2006-04-19 11:43:12Z bas $ |
---|
101 | # |
---|
102 | # |
---|
103 | |
---|
104 | # |
---|
105 | # check tree should not be called until it is installed since |
---|
106 | # only relative paths are used by autoconf. |
---|
107 | # |
---|
108 | prefix=@prefix@ |
---|
109 | exec_prefix=@exec_prefix@ |
---|
110 | CHK_TREE=${DESTDIR}@bindir@/chk_tree |
---|
111 | |
---|
112 | PBS_DEFAULT_SERVER=@PBS_DEFAULT_SERVER@ |
---|
113 | |
---|
114 | # PBS_SERVER_HOME is defined without DESTDIR so that DEFAULT_FILE and EVIRON |
---|
115 | # can be based on SERVER_HOME. SERVER_HOME is defined a second time to pick |
---|
116 | # up DESTDIR |
---|
117 | test -n "$PBS_SERVER_HOME" || PBS_SERVER_HOME=@PBS_SERVER_HOME@ |
---|
118 | test -n "$PBS_DEFAULT_FILE" || PBS_DEFAULT_FILE=${DESTDIR}@PBS_DEFAULT_FILE@ |
---|
119 | test -n "$PBS_ENVIRON" || PBS_ENVIRON=${DESTDIR}@PBS_ENVIRON@ |
---|
120 | |
---|
121 | PBS_SERVER_HOME=${DESTDIR}$PBS_SERVER_HOME |
---|
122 | |
---|
123 | verbose="" |
---|
124 | |
---|
125 | display_flags() |
---|
126 | { |
---|
127 | cat << EOF |
---|
128 | Usage: |
---|
129 | pbs_mkdirs [-v] [-c] [-C chk_tree_location] what |
---|
130 | -v be verbose |
---|
131 | -c allow usage of chk_tree (do not use this within a make install) |
---|
132 | -C Specify where the location of the chk_tree binary |
---|
133 | what select from the following list |
---|
134 | server -- dirs needed by pbs_server |
---|
135 | mom -- dirs needed by pbs_mom |
---|
136 | aux -- the aux directory |
---|
137 | default -- the default file |
---|
138 | common -- make common directory to all daemons |
---|
139 | check -- run chk_tree (turns on -c automatically) |
---|
140 | all -- do all of the above |
---|
141 | EOF |
---|
142 | exit 0 |
---|
143 | } |
---|
144 | |
---|
145 | |
---|
146 | # |
---|
147 | # this will create a directory and any chain of parent directories |
---|
148 | # that might be needed |
---|
149 | # All of this is somewhat lame because install-sh is used |
---|
150 | # along with install_dir in various places. |
---|
151 | # |
---|
152 | install_dir() |
---|
153 | { |
---|
154 | # use the id_ for namespace disambiguation |
---|
155 | id_dname="$1" |
---|
156 | id_mode=`test -n "$2" && echo "$2" || echo 755` |
---|
157 | |
---|
158 | # dlist will contain a list of directory names to make |
---|
159 | id_dlist="" |
---|
160 | |
---|
161 | while [ ! \( -z "$id_dname" -o "$id_dname" = / -o \ |
---|
162 | "$id_dname" = "." \) ]; do |
---|
163 | |
---|
164 | test -f $id_dname && return 1 |
---|
165 | test -d $id_dname && break |
---|
166 | |
---|
167 | id_dlist="`basename $id_dname` $id_dlist" |
---|
168 | id_dname=`dirname "$id_dname"` |
---|
169 | done |
---|
170 | |
---|
171 | id_dir="$id_dname" |
---|
172 | for id_d in $id_dlist ""; do |
---|
173 | id_dir="$id_dir/$id_d" |
---|
174 | test -z "$id_d" && return 0 |
---|
175 | mkdir $id_dir && chmod $id_mode $id_dir || return 1 |
---|
176 | done |
---|
177 | return 0 |
---|
178 | } |
---|
179 | |
---|
180 | # |
---|
181 | # This will take the name of the variable (not value) and |
---|
182 | # make a directory. This is just to stick with the original |
---|
183 | # way things were done in the top-level make file in PBS |
---|
184 | # |
---|
185 | install_dir_by_varname() |
---|
186 | { |
---|
187 | idv_dvarname="$1" |
---|
188 | idv_dname=`eval 'echo $'$idv_dvarname` |
---|
189 | |
---|
190 | idv_mode=`test -n "$2" && echo "$2" || echo 755` |
---|
191 | |
---|
192 | if [ X$idv_dname = X ] ; then |
---|
193 | echo $idv_dvarname is not defined 1>&2 |
---|
194 | return 1 |
---|
195 | elif [ -f $idv_dname ] ; then |
---|
196 | echo $idv_dvarname exists and is not a directory 1>&2 |
---|
197 | return 1 |
---|
198 | elif [ -d $idv_dname ] ; then |
---|
199 | chmod $idv_mode $idv_dname || return 1 |
---|
200 | return 0 |
---|
201 | elif [ ! -d $idv_dname ] ; then |
---|
202 | test -n "$verbose" && echo Creating $idv_dname |
---|
203 | install_dir `dirname $idv_dname` 755 && \ |
---|
204 | mkdir $idv_dname && chmod $idv_mode $idv_dname || return 1 |
---|
205 | fi |
---|
206 | |
---|
207 | return 0 |
---|
208 | } |
---|
209 | |
---|
210 | check_env() |
---|
211 | { |
---|
212 | test -n "$verbose" && echo Making environment file |
---|
213 | if [ ! -f $PBS_ENVIRON ] ; then |
---|
214 | install_dir `dirname $PBS_ENVIRON` || return 1 |
---|
215 | echo "PATH=/bin:/usr/bin" > $PBS_ENVIRON || return 1 |
---|
216 | if [ X$TZ != X ] ; then |
---|
217 | echo "TZ=$TZ" >> $PBS_ENVIRON || return 1 |
---|
218 | fi |
---|
219 | if [ X$LANG != X ] ; then |
---|
220 | echo "LANG=$LANG" >> $PBS_ENVIRON || return 1 |
---|
221 | fi |
---|
222 | if [ X$LC_ALL != X ] ; then |
---|
223 | echo "LC_ALL=$LC_ALL" >> $PBS_ENVIRON || return 1 |
---|
224 | fi |
---|
225 | if [ X$LC_COLLATE != X ] ; then |
---|
226 | echo "LC_COLLATE=$LC_COLLATE" >> $PBS_ENVIRON || return 1 |
---|
227 | fi |
---|
228 | if [ X$LC_CTYPE != X ] ; then |
---|
229 | echo "LC_CTYPE=$LC_CTYPE" >> $PBS_ENVIRON || return 1 |
---|
230 | fi |
---|
231 | if [ X$LC_MONETARY != X ] ; then |
---|
232 | echo "LC_MONETARY=$LC_MONETARY" >> $PBS_ENVIRON || return 1 |
---|
233 | fi |
---|
234 | if [ X$LC_NUMERIC != X ] ; then |
---|
235 | echo "LC_NUMERIC=$LC_NUMERIC" >> $PBS_ENVIRON || return 1 |
---|
236 | fi |
---|
237 | if [ X$LC_TIME != X ] ; then |
---|
238 | echo "LC_TIME=$LC_TIME" >> $PBS_ENVIRON || return 1 |
---|
239 | fi |
---|
240 | chmod 644 $PBS_ENVIRON || return 1 |
---|
241 | fi |
---|
242 | } |
---|
243 | |
---|
244 | chk_tree_wrap() |
---|
245 | { |
---|
246 | if test -n "$chktree";then |
---|
247 | $CHK_TREE $* || return 1 |
---|
248 | fi |
---|
249 | } |
---|
250 | |
---|
251 | mk_server_dirs() |
---|
252 | { |
---|
253 | test -n "$verbose" && echo Creating Directories required for the Server |
---|
254 | install_dir_by_varname PBS_SERVER_HOME 755 || return 1 |
---|
255 | |
---|
256 | install_dir $PBS_SERVER_HOME/spool 1777 || return 1 |
---|
257 | install_dir $PBS_SERVER_HOME/server_priv 750 || return 1 |
---|
258 | install_dir $PBS_SERVER_HOME/server_priv/jobs 750 || return 1 |
---|
259 | install_dir $PBS_SERVER_HOME/server_priv/hostlist 750 || return 1 |
---|
260 | install_dir $PBS_SERVER_HOME/server_priv/queues 750 || return 1 |
---|
261 | install_dir $PBS_SERVER_HOME/server_priv/acl_svr 750 || return 1 |
---|
262 | install_dir $PBS_SERVER_HOME/server_priv/acl_hosts 750 || return 1 |
---|
263 | install_dir $PBS_SERVER_HOME/server_priv/acl_users 750 || return 1 |
---|
264 | install_dir $PBS_SERVER_HOME/server_priv/acl_groups 750 || return 1 |
---|
265 | install_dir $PBS_SERVER_HOME/server_priv/disallowed_types 750 || return 1 |
---|
266 | install_dir $PBS_SERVER_HOME/server_priv/accounting 755 || return 1 |
---|
267 | install_dir $PBS_SERVER_HOME/server_logs 755 || return 1 |
---|
268 | install_dir $PBS_SERVER_HOME/sched_priv 750 || return 1 |
---|
269 | install_dir $PBS_SERVER_HOME/sched_priv/accounting 755 || return 1 |
---|
270 | install_dir $PBS_SERVER_HOME/sched_logs 755 || return 1 |
---|
271 | install_dir $PBS_SERVER_HOME/server_priv/arrays 750 || return 1 |
---|
272 | |
---|
273 | test -f $PBS_ENVIRON || check_env || return 1 |
---|
274 | |
---|
275 | chk_tree_wrap -d -n $PBS_SERVER_HOME/server_priv/jobs \ |
---|
276 | $PBS_SERVER_HOME/server_priv/hostlist \ |
---|
277 | $PBS_SERVER_HOME/server_priv/queues \ |
---|
278 | $PBS_SERVER_HOME/server_priv/acl_svr \ |
---|
279 | $PBS_SERVER_HOME/server_priv/acl_hosts \ |
---|
280 | $PBS_SERVER_HOME/server_priv/acl_users \ |
---|
281 | $PBS_SERVER_HOME/server_priv/acl_groups \ |
---|
282 | $PBS_SERVER_HOME/server_priv/accounting \ |
---|
283 | $PBS_SERVER_HOME/server_logs \ |
---|
284 | $PBS_SERVER_HOME/server_priv/arrays || return 1 |
---|
285 | chk_tree_wrap -d -n -s $PBS_SERVER_HOME/spool || return 1 |
---|
286 | chk_tree_wrap -n $PBS_ENVIRON || return 1 |
---|
287 | } |
---|
288 | |
---|
289 | |
---|
290 | mk_mom_dirs() |
---|
291 | { |
---|
292 | test -n "$verbose" && echo Creating Directories required for MOM |
---|
293 | |
---|
294 | install_dir_by_varname PBS_SERVER_HOME 755 || return 1 |
---|
295 | |
---|
296 | test -d $PBS_SERVER_HOME/spool || \ |
---|
297 | install_dir $PBS_SERVER_HOME/spool 1777 || return 1 |
---|
298 | |
---|
299 | install_dir $PBS_SERVER_HOME/checkpoint 770 || return 1 |
---|
300 | install_dir $PBS_SERVER_HOME/undelivered 1777 || return 1 |
---|
301 | install_dir $PBS_SERVER_HOME/mom_priv 751 || return 1 |
---|
302 | install_dir $PBS_SERVER_HOME/mom_priv/jobs 751 || return 1 |
---|
303 | install_dir $PBS_SERVER_HOME/mom_logs 755 || return 1 |
---|
304 | |
---|
305 | mk_default_file || return 1 |
---|
306 | |
---|
307 | test -f $PBS_ENVIRON || check_env || return 1 |
---|
308 | |
---|
309 | chk_tree_wrap -d -n $PBS_SERVER_HOME/checkpoint \ |
---|
310 | $PBS_SERVER_HOME/mom_priv/jobs \ |
---|
311 | $PBS_SERVER_HOME/mom_logs || return 1 |
---|
312 | chk_tree_wrap -d -n -s $PBS_SERVER_HOME/spool \ |
---|
313 | $PBS_SERVER_HOME/undelivered || return 1 |
---|
314 | chk_tree_wrap -n $PBS_ENVIRON || return 1 |
---|
315 | } |
---|
316 | |
---|
317 | mk_default_file() |
---|
318 | { |
---|
319 | test -n "$verbose" && echo Making default server file |
---|
320 | |
---|
321 | install_dir `dirname $PBS_DEFAULT_FILE` || return 1 |
---|
322 | |
---|
323 | # I think I know better than pbs. --pw |
---|
324 | if [ ! -e $PBS_DEFAULT_FILE ]; then |
---|
325 | rm -f $PBS_DEFAULT_FILE > /dev/null 2>&1 |
---|
326 | echo $PBS_DEFAULT_SERVER > $PBS_DEFAULT_FILE && \ |
---|
327 | chmod 644 $PBS_DEFAULT_FILE || return 1 |
---|
328 | fi |
---|
329 | |
---|
330 | chk_tree_wrap -n $PBS_DEFAULT_FILE || return 1 |
---|
331 | } |
---|
332 | |
---|
333 | mk_common() |
---|
334 | { |
---|
335 | mk_default_file || return 1 |
---|
336 | mk_aux_dir || return 1 |
---|
337 | install_dir $PBS_SERVER_HOME/spool 1777 || return 1 |
---|
338 | check_env || return 1 |
---|
339 | } |
---|
340 | |
---|
341 | mk_aux_dir() |
---|
342 | { |
---|
343 | install_dir $PBS_SERVER_HOME/aux 755 || return 1 |
---|
344 | chk_tree_wrap -d -n $PBS_SERVER_HOME/aux || return 1 |
---|
345 | } |
---|
346 | |
---|
347 | do_check_tree() |
---|
348 | { |
---|
349 | chk_tree_wrap -d $PBS_SERVER_HOME/server_priv/jobs \ |
---|
350 | $PBS_SERVER_HOME/server_priv/queues \ |
---|
351 | $PBS_SERVER_HOME/server_priv/acl_svr \ |
---|
352 | $PBS_SERVER_HOME/server_priv/acl_hosts \ |
---|
353 | $PBS_SERVER_HOME/server_priv/acl_users \ |
---|
354 | $PBS_SERVER_HOME/server_priv/acl_groups \ |
---|
355 | $PBS_SERVER_HOME/server_priv/accounting \ |
---|
356 | $PBS_SERVER_HOME/server_logs || return 1 |
---|
357 | chk_tree_wrap -d $PBS_SERVER_HOME/checkpoint \ |
---|
358 | $PBS_SERVER_HOME/mom_priv/jobs \ |
---|
359 | $PBS_SERVER_HOME/mom_logs || return 1 |
---|
360 | chk_tree_wrap -d -s $PBS_SERVER_HOME/spool \ |
---|
361 | $PBS_SERVER_HOME/undelivered || return 1 |
---|
362 | chk_tree_wrap -d $PBS_SERVER_HOME/aux || return 1 |
---|
363 | chk_tree_wrap $PBS_DEFAULT_FILE || return 1 |
---|
364 | } |
---|
365 | |
---|
366 | |
---|
367 | # mk_dirs() will generate the set of directories needed |
---|
368 | # for server and mom execution. |
---|
369 | |
---|
370 | mk_dirs() |
---|
371 | { |
---|
372 | chktree=yes |
---|
373 | mk_server_dirs || return 1 |
---|
374 | mk_mom_dirs || return 1 |
---|
375 | mk_default_file || return 1 |
---|
376 | mk_aux_dir || return 1 |
---|
377 | } |
---|
378 | |
---|
379 | |
---|
380 | getopt vcd:C:h "$@" > /dev/null || display_flags |
---|
381 | set -- `getopt vcd:C:h "$@"` |
---|
382 | while true |
---|
383 | do |
---|
384 | case "$1" in |
---|
385 | -v) |
---|
386 | verbose=yes |
---|
387 | shift |
---|
388 | ;; |
---|
389 | -d) |
---|
390 | PBS_SERVER_HOME=$2 |
---|
391 | shift 2 |
---|
392 | ;; |
---|
393 | -h) |
---|
394 | display_flags |
---|
395 | ;; |
---|
396 | -c) |
---|
397 | chktree=yes |
---|
398 | shift |
---|
399 | ;; |
---|
400 | -C) |
---|
401 | CHK_TREE=$2 |
---|
402 | shift 2 |
---|
403 | ;; |
---|
404 | --) |
---|
405 | shift; break |
---|
406 | ;; |
---|
407 | |
---|
408 | esac |
---|
409 | done |
---|
410 | |
---|
411 | while [ $# -gt 0 ] |
---|
412 | do |
---|
413 | case "$1" in |
---|
414 | serv*) |
---|
415 | mk_server_dirs || exit 1 |
---|
416 | break |
---|
417 | ;; |
---|
418 | mom*) |
---|
419 | mk_mom_dirs || exit 1 |
---|
420 | break |
---|
421 | ;; |
---|
422 | aux*) |
---|
423 | mk_aux_dir || exit 1 |
---|
424 | break |
---|
425 | ;; |
---|
426 | default*) |
---|
427 | mk_default_file || exit 1 |
---|
428 | break |
---|
429 | ;; |
---|
430 | common*) |
---|
431 | mk_common || exit 1 |
---|
432 | break |
---|
433 | ;; |
---|
434 | check*) |
---|
435 | chktree=yes |
---|
436 | do_check_tree || exit 1 |
---|
437 | break |
---|
438 | ;; |
---|
439 | all*) |
---|
440 | mk_dirs || exit 1 |
---|
441 | break |
---|
442 | ;; |
---|
443 | *) |
---|
444 | echo "$1 is unknown flag" |
---|
445 | display_flags |
---|
446 | break |
---|
447 | ;; |
---|
448 | esac |
---|
449 | shift |
---|
450 | done |
---|