Merge lp:~jontai/openvista-gtm-integration/bug336166 into lp:openvista-gtm-integration

Proposed by Jon Tai
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jontai/openvista-gtm-integration/bug336166
Merge into: lp:openvista-gtm-integration
Diff against target: 1800 lines (+801/-257)
33 files modified
docs/man1/ovbackup.1 (+13/-3)
docs/man1/ovcheckperms.1 (+4/-4)
docs/man1/ovgetvar.1 (+51/-0)
docs/man1/ovimport.1 (+42/-18)
docs/man8/ovrestore.8 (+17/-7)
mumps/ZCD.m (+26/-13)
mumps/ZTMGRSET.m (+7/-5)
packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/changelog (+9/-0)
packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.dirs (+1/-0)
packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.manpages (+2/-0)
packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/rules (+12/-12)
packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/changelog (+9/-0)
packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.dirs (+1/-0)
packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.manpages (+2/-0)
packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/rules (+12/-12)
packages/rpm/CentOS/5/openvista-gtm-integration.spec (+7/-1)
scripts/etc/bash_completion.d/openvista (+60/-13)
scripts/etc/cron.daily/openvista (+4/-4)
scripts/etc/init.d/openvista (+2/-9)
scripts/etc/init.d/openvista-databases (+3/-9)
scripts/usr/bin/ovbackup (+22/-7)
scripts/usr/bin/ovcheckperms (+5/-1)
scripts/usr/bin/ovgetvar (+104/-0)
scripts/usr/bin/ovimport (+78/-28)
scripts/usr/lib/openvista/functions (+77/-16)
scripts/usr/sbin/ovinstanceadd (+5/-60)
scripts/usr/sbin/ovrestore (+75/-8)
scripts/usr/share/munin/plugins/openvista_databases_ (+2/-9)
scripts/usr/share/munin/plugins/openvista_locks_ (+2/-9)
scripts/usr/share/munin/plugins/openvista_processes_ (+2/-9)
scripts/usr/share/openvista/backups.conf (+26/-0)
scripts/usr/share/openvista/env (+96/-0)
scripts/usr/share/openvista/journals.conf (+23/-0)
To merge this branch: bzr merge lp:~jontai/openvista-gtm-integration/bug336166
Reviewer Review Type Date Requested Status
jeff.apple Approve
Review via email: mp+16359@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jon Tai (jontai) wrote :

This branch makes a large number of changes, so I'm putting it up for review early while I finish testing it. I don't anticipate any more big changes, but I might have to fix a thing or two if I find problems.

Revision history for this message
jeff.apple (jeff-apple) wrote :

Nice changes. I saw no problems.

review: Approve
145. By Jon Tai

add a warning in the sample env file

146. By Jon Tai

older versions of rsync (like the version that ships with RHEL5, 2.6.8) don't support the --out-format argument, so work around it by passing -v and greping for .m files ourselves

147. By Jon Tai

improve performance of ovimport by having mumps read the compile list file directly; this saves thousands of process invocations and about 3 minutes when importing OpenVista Server

148. By Jon Tai

Fix a bug where $user would be undefined in /etc/cron.daily/openvista. This occurs because list_openvista_instances is executed in a subshell, so variables set during its invocation aren't set in the parent shell.

Revision history for this message
Jon Tai (jontai) wrote :

OK I'm done with my testing. I tested KIDS builds on a routine-tiered installation and it worked fine. I also found a few OV utility regressions and fixed them.

In my testing, I noticed that the current version of VPE is unable to handle routine tiers (errors occur when saving routines), but I think this branch is large enough -- there are other people in the community working on VPE anyway, so it's likely that we will be able to just grab a new version of VPE and things will just work.

Jeff, can I get one more ACK before I merge?

149. By Jon Tai

look for FROM routine in the right directory

150. By Jon Tai

Separate TO/FROM (which are passed in as names of routines, e.g., %ZTM0) and SRC/DST which are full paths. This way, the call to ZLINK is given an argument like _ZTM0 instead of /path/to/_ZTM0.m. When called with the latter, ZLINK puts the .o file in /pat/to/ instead of the configured routines directory, which isn't what we want.

Revision history for this message
Jon Tai (jontai) wrote :

Oops, forgot to test ZTMGRSET. I did, and found that it's not pulling routines from the correct source directory when it's doing copies. Fixed that, plus an old bug (never filed) that caused .o files to be placed in the routines directory.

Revision history for this message
jeff.apple (jeff-apple) wrote :

If this tests out OK, then I see no problems.

As for VPE, they should be using kernel routines, right? If there's something that varies between implementations that isn't addressed in the kernel, then perhaps the kernel needs some addintions. That's way, way, way beyond the scope of this bug, though.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/man1/ovbackup.1'
2--- docs/man1/ovbackup.1 2009-12-01 21:55:02 +0000
3+++ docs/man1/ovbackup.1 2009-12-21 19:35:21 +0000
4@@ -1,6 +1,6 @@
5-.TH ovbackup 1 "1 Dec 2009" Linux "User Manuals"
6+.TH ovbackup 1 "10 Dec 2009" Linux "User Manuals"
7 .SH NAME
8-ovbackup \- backs up routines and globals of an OpenVista instance
9+ovbackup \- back up routines and globals of an OpenVista instance
10 .SH SYNOPSIS
11 .B ovbackup [-h] [-V] [-q]
12 .I instance_name
13@@ -8,7 +8,17 @@
14 Each invocation of
15 .B ovbackup
16 creates a consistent snapshot of the routines and globals of an OpenVista
17-instance. Backups are compressed with tar/bz2 and stored in the
18+instance. The
19+.I mumps.gld
20+global directory file in the
21+.I globals
22+directory of the instance is also included in the backup, as is the
23+.I env
24+file in the
25+.I etc
26+directory of the instance, if it exists. If any of these files or directories
27+are symlinks, the symlink targets are backed up instead of the symlinks
28+themselves. Backups are compressed with tar/bzip2 and stored in the
29 .I backups
30 directory of an OpenVista instance. The md5 checksum of the compressed backup
31 file is computed and stored in a separate file.
32
33=== modified file 'docs/man1/ovcheckperms.1'
34--- docs/man1/ovcheckperms.1 2009-12-01 21:58:29 +0000
35+++ docs/man1/ovcheckperms.1 2009-12-21 19:35:21 +0000
36@@ -1,4 +1,4 @@
37-.TH ovcheckperms 1 "1 Dec 2009" Linux "User Manuals"
38+.TH ovcheckperms 1 "11 Dec 2009" Linux "User Manuals"
39 .SH NAME
40 ovcheckperms \- verify permissions
41 .SH SYNOPSIS
42@@ -6,9 +6,9 @@
43 .I instance_name
44 .SH DESCRIPTION
45 .B ovcheckperms
46-script verifies that all files and directories in an OpenVista instance have
47-the correct permissions. Incorrect permissions are written to stdout and
48-logged to syslog.
49+verifies that all files and directories in an OpenVista instance have the
50+correct permissions. Incorrect permissions are written to stdout and logged to
51+syslog.
52 .PP
53 The
54 .I /etc/cron.daily/openvista
55
56=== added file 'docs/man1/ovgetvar.1'
57--- docs/man1/ovgetvar.1 1970-01-01 00:00:00 +0000
58+++ docs/man1/ovgetvar.1 2009-12-21 19:35:21 +0000
59@@ -0,0 +1,51 @@
60+.TH ovgetvar 1 "11 Dec 2009" Linux "User Manuals"
61+.SH NAME
62+ovgetvar \- get GT.M environment variable
63+.SH SYNOPSIS
64+.B ovgetvar [-h] [-V]
65+.I instance_name
66+.I gtm_dist|gtm_path|gtmroutines|gtmgbldir
67+.SH DESCRIPTION
68+.B ovgetvar
69+prints the effective values of
70+.I $gtm_dist
71+,
72+.I $gtmroutines
73+, and
74+.I $gtmgbldir
75+for the specified OpenVista instance. It works by calling set_gtm_env, the
76+function that all of the OpenVista utilities use to set their environment, then
77+printing out the value of the requested variable.
78+.PP
79+If
80+.I gtm_path
81+is requested and
82+.I $gtm_dist
83+is a symlink,
84+.B ovgetvar
85+tries to follow the symlink and prints out the real path to GT.M.
86+.PP
87+The ZCD routine in OpenVista Server is the main user of this utility, although
88+it can be used by an administrator to inspect an OpenVista instance's
89+configuration.
90+.PP
91+.SH OPTIONS
92+.IP -h
93+display help text and exit
94+.IP -V
95+display version information and exit
96+.SH "EXIT VALUES"
97+.IP 0
98+Success
99+.IP 1
100+Permission denied or other error
101+.IP 2
102+Invalid command syntax
103+.IP 3
104+Invalid argument to option
105+.SH "REPORTING BUGS"
106+Please report any bugs you encounter at
107+.PP
108+https://bugs.launchpad.net/openvista-gtm-integration
109+.SH AUTHOR
110+Jonathan Tai <jon.tai@medsphere.com>
111
112=== modified file 'docs/man1/ovimport.1'
113--- docs/man1/ovimport.1 2009-12-01 21:55:02 +0000
114+++ docs/man1/ovimport.1 2009-12-21 19:35:21 +0000
115@@ -1,8 +1,10 @@
116-.TH ovimport 1 "1 Dec 2009" Linux "User Manuals"
117+.TH ovimport 1 "10 Dec 2009" Linux "User Manuals"
118 .SH NAME
119-ovimport \- imports routines and globals into a new OpenVista instance
120+ovimport \- import routines and globals into an OpenVista instance
121 .SH SYNOPSIS
122-.B ovimport [-h] [-V] [-q] [-f] [-c
123+.B ovimport [-h] [-V] [-q] [-f] [-t
124+.I target
125+.B ] [-c
126 .I imported|all|none
127 .B ] [-r
128 .I routines
129@@ -12,18 +14,34 @@
130 .I instance_name
131 .SH DESCRIPTION
132 .B ovimport
133-imports routines and globals into a new OpenVista instance. Routines can be in
134-a %RO-format file, or loose .m files in a directory. In the latter case,
135-specify the directory containing the .m files after the -r flag; do not specify
136-the .m files themselves. Globals can be in a %GO-format file or a ZWR-format
137-file. Files with DOS-style line endings are converted to UNIX-style line
138-endings automagically; GT.M does not handle DOS-style line endings natively.
139-Line ending conversion requires enough free space in the target instance's
140+imports routines and globals into an OpenVista instance.
141+.PP
142+Routines can be in a %RO-format file or loose .m files in a directory. In the
143+latter case, specify the directory containing the .m files after the -r flag;
144+do not specify the .m files themselves. By default, routines are imported into
145+the
146+.I routines
147+subdirectory of the OpenVista instance. Use the -t flag to specify an
148+alternate directory if $gtmroutines has been overridden in the instance's
149+.I env
150+file. The -t flag was added in
151+.B ovimport
152+0.8.7.
153+.PP
154+Globals can be in a %GO-format file or a ZWR-format file.
155+.PP
156+Files with DOS-style line endings are converted to UNIX-style line endings by
157+.B ovimport
158+automagically; GT.M does not handle DOS-style line endings natively. Line
159+ending conversion requires enough free space in the target instance's
160 .I tmp
161 directory to hold a copy of the files to be imported. Support for compressed
162-files is planned in a future version.
163+files is planned for a future version.
164 .PP
165-.B ovimport
166+.B ovimport
167+is primarily used to import routines and globals into a new OpenVista instance.
168+By default,
169+.B ovimport
170 checks to see if the target instance has any routines or database transactions.
171 If either are found, the instance is assumed to not be new and
172 .B ovimport
173@@ -36,15 +54,19 @@
174 flag is given, although imported routines and globals will overwrite any
175 routines or globals with the same name.
176 .PP
177-Routines are compiled after the routines are imported. By default, only
178-imported routines are compiled. You should use
179+Routines are compiled after they are imported. By default, only imported
180+routines are compiled. Use
181 .B -c all
182-if you want to recompile all routines or
183+to recompile all routines or
184 .B -c none
185-if you do not want to compile any routines. Journaling is temporarily disabled
186-during the global import to improve performance, unless the
187+to skip routine compilation. The -c flag was added in
188+.B ovimport
189+0.8.7.
190+.PP
191+Journaling is temporarily disabled during the global import to improve
192+performance, unless the
193 .B -f
194-flag was given. This is safe to do because the database is guaranteed to be
195+flag is given. This is safe to do because the database is guaranteed to be
196 empty before the import, so even if the system crashes and the database is
197 destroyed, the database can be recreated and
198 .B ovimport
199@@ -70,6 +92,8 @@
200 quiet; suppress status messages
201 .IP -f
202 force; import routines and globals even if target instance is not empty
203+.IP -t
204+target; directory to import routines into (defaults to routines subdirectory of instance)
205 .IP -c
206 compile imported routines only (the default), all routines, or no routines
207 .IP -r
208
209=== modified file 'docs/man8/ovrestore.8'
210--- docs/man8/ovrestore.8 2009-12-01 21:55:02 +0000
211+++ docs/man8/ovrestore.8 2009-12-21 19:35:21 +0000
212@@ -1,4 +1,4 @@
213-.TH ovrestore 8 "1 Dec 2009" Linux "User Manuals"
214+.TH ovrestore 8 "10 Dec 2009" Linux "User Manuals"
215 .SH NAME
216 ovrestore \- restores a backup file into an OpenVista instance
217 .SH SYNOPSIS
218@@ -28,12 +28,22 @@
219 for each process currently using the database before attempting to acquire
220 exclusive access to the database.
221 .PP
222-Routines are compiled after the routines are restored. The mumps.gld global
223-directory file is restored from the backup file, but the paths to database
224-files and journal files are updated to reflect the name of the target instance.
225-The database file is also restored from the backup file; the path to the
226-journal file is updated when journaling is re-enabled at the end of the restore
227-process.
228+If the backup file contains an
229+.I env
230+configuration file, it is checked for validity and restored. Routines are
231+restored from the backup file, then compiled. The
232+.I mumps.gld
233+global directory file is restored from the backup file, and the paths to
234+database files and journal files are updated to reflect the name of the target
235+instance. If the
236+.I env
237+file sets $gtmgbldir to point to a different
238+.I mumps.gld
239+file, the foreign global directory file is checked to make sure it exists, but
240+no attempt is made to update the paths in the foreign global directory file.
241+The database file is also restored from the backup file, and the embedded path
242+to the journal file is updated when journaling is re-enabled at the end of the
243+restore process.
244 .PP
245 If the
246 .B -j
247
248=== modified file 'mumps/ZCD.m'
249--- mumps/ZCD.m 2009-11-24 22:57:02 +0000
250+++ mumps/ZCD.m 2009-12-21 19:35:21 +0000
251@@ -1,4 +1,4 @@
252-ZCD ; MSC/JKT,JDS ; "Namespace" utilities for GT.M/Unix ; 17JUL2009
253+ZCD ; MSC/JKT,JDS ; "Namespace" utilities for GT.M/Unix ; 5DEC2009
254 ;;8.0;KERNEL;**MSC**;April 21 2009
255 ; This routine assumes that your global directory file exists one
256 ; directory below the root of the instance, e.g.,
257@@ -40,12 +40,18 @@
258 Q $$ROOT()_"/"_INSTANCE
259 ;
260 GTMPATH(INSTANCE) ; return the path to the version of GT.M this instance uses
261- N %PIPE,%I S %PIPE="readlink",%I=$I
262+ N %PATH,%PIPE,%I
263+ S %I=$I
264+ S %PIPE="ovgetvar"
265+ O %PIPE:(COMMAND="ovgetvar "_INSTANCE_" gtm_path 2> /dev/null":READONLY)::"PIPE" U %PIPE
266+ R %PATH
267+ C %PIPE
268+ I %PATH'="" U %I Q %PATH
269+ S %PIPE="readlink"
270 O %PIPE:(COMMAND="readlink "_$$PATH(INSTANCE)_"/gtm":READONLY)::"PIPE" U %PIPE
271- N %PATH R %PATH
272- U %I
273+ R %PATH
274 C %PIPE
275- Q %PATH
276+ U %I Q %PATH
277 ;
278 LIST ; return an array (Y) of OpenVista instances on this system
279 N %PIPE,%I S %PIPE="ls",%I=$I
280@@ -59,21 +65,16 @@
281 SWITCH(INSTANCE) ; switch to another OpenVista instance
282 N %ZG,%ZRO D NEWZGZRO(INSTANCE) I %ZG="",%ZRO="" Q 0
283 ;
284- ; FIXME: set gtm_dist="$root/$instance/gtm"
285 N %TEMPDIR S %TEMPDIR=$$MKTEMP() S $ZG=%ZG,$ZRO=%ZRO_" "_%TEMPDIR
286 N X,Y S X=INSTANCE X ^%ZOSF("UPPERCASE") S $ZPROMPT=Y_">"
287- ; FIXME: set GTMXC_openvista="$root/$instance/gtm/openvista.xc"
288- ; FIXME: set PATH="$PATH:$root/$instance/gtm"
289 ;
290 ; re-ZLINK routines that have been loaded in our current image
291 X "Q" ; equivalent to ZGOTO so that you can recompile a routine you are using
292 N %ROUTINE,%FILENAME S %ROUTINE=""
293 NEXT F S %ROUTINE=$VIEW("rtnnext",%ROUTINE) Q:%ROUTINE="" D
294- . Q:%ROUTINE="GTM$DMOD"
295- . Q:%ROUTINE="ZCD"
296- . I "^MSCXUS3A^XQ1^XUP^%MSCXUCI^%ZMSCXUCI^"[("^"_%ROUTINE_"^") Q ;switch UCI option
297+ . I "^GTM$DMOD^ZCD^MSCXUS3A^XQ1^XUP^%MSCXUCI^%ZMSCXUCI^"[("^"_%ROUTINE_"^") Q ;do not try to recompile these
298 . ;
299- . ; The only % routines that we ship start with %Z other % routines are allocated to the
300+ . ; The only % routines that we ship start with %Z; other % routines are allocated to the
301 . ; vendor (GTM) and do not need to be recompiled (and may only have object code)
302 . Q:$E(%ROUTINE)="%"&($E(%ROUTINE,2)'="Z")
303 . ;
304@@ -106,7 +107,19 @@
305 SWITCHENV(INSTANCE) ; private entry point
306 ; set new $ZG and $ZRO by parsing env file in target instance
307 ;
308- ; FIXME: implement this
309+ N %PIPE,%I
310+ S %I=$I
311+ S %PIPE="ovgetvar_gtmgbldir"
312+ O %PIPE:(COMMAND="ovgetvar "_INSTANCE_" gtmgbldir 2> /dev/null":READONLY)::"PIPE" U %PIPE
313+ R %ZG
314+ C %PIPE
315+ S %PIPE="ovgetvar_gtmroutines"
316+ O %PIPE:(COMMAND="ovgetvar "_INSTANCE_" gtmroutines 2> /dev/null":READONLY)::"PIPE" U %PIPE
317+ R %ZRO
318+ C %PIPE
319+ U %I
320+ ;
321+ ; FIXME: check that %ZG actually exists and that all pieces of %ZRO exist
322 Q
323 ;
324 SWITCHCAT(INSTANCE) ; private entry point
325
326=== modified file 'mumps/ZTMGRSET.m'
327--- mumps/ZTMGRSET.m 2009-08-31 18:49:27 +0000
328+++ mumps/ZTMGRSET.m 2009-12-21 19:35:21 +0000
329@@ -1,4 +1,4 @@
330-ZTMGRSET ;SF/RWF,PUG/TOAD,MSC/JDA/JDS/JKT - SET UP THE MGR ACCOUNT FOR THE SYSTEM ;11JUN2009
331+ZTMGRSET ;SF/RWF,PUG/TOAD,MSC/JDA/JDS/JKT - SET UP THE MGR ACCOUNT FOR THE SYSTEM ;21DEC2009
332 ;;8.0;KERNEL;**34,36,69,94,121,127,136,191,275,MSC**;JUL 10, 1995;
333 ;
334 N %D,%S,I,OSMAX,U,X,X1,X2,Y,Z1,Z2,ZTOS,ZTMODE,SCR
335@@ -160,11 +160,13 @@
336 COPY(FROM,TO) ;
337 I ZTOS'=7,ZTOS'=8 X "ZL @FROM ZS @TO" Q
338 ;For GT.M below
339- N PATH,COPY S PATH=$$R
340- D SILENT^%RSEL(FROM) S FROM=PATH_FROM_".m"
341- S TO=PATH_$TR(TO,"%","_")_".m"
342+ S TO=$TR(TO,"%","_")
343+ N PATH,SRC,DST,COPY
344+ S PATH=$$R
345+ N %ZR D SILENT^%RSEL(FROM) S SRC=%ZR(FROM)_FROM_".m"
346+ S DST=PATH_TO_".m"
347 S COPY=$S(ZTOS=7:"COPY",1:"cp")
348- ZSYSTEM COPY_" "_FROM_" "_TO
349+ ZSYSTEM COPY_" "_SRC_" "_DST
350 ZLINK TO
351 Q
352 ;
353
354=== modified file 'packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/changelog'
355--- packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/changelog 2009-11-22 08:04:35 +0000
356+++ packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/changelog 2009-12-21 19:35:21 +0000
357@@ -1,3 +1,12 @@
358+openvista-gtm-integration (0.8.6-0ubuntu2~msc3~jaunty1) jaunty; urgency=low
359+
360+ * Update utils to honor env config file if it exists (Closes: #336166)
361+ * Add man pages for new ovcheckperms and ovgetvar utilities
362+ * Add config file templates in /usr/share/openvista
363+ * Remove executable bit on munin plugin configuration file
364+
365+ -- Jonathan Tai <jon.tai@medsphere.com> Thu, 17 Dec 2009 10:11:25 -0800
366+
367 openvista-gtm-integration (0.8.6-0ubuntu2~msc2~jaunty1) jaunty; urgency=low
368
369 * Re-order dependencies so preferred packages come first.
370
371=== modified file 'packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.dirs'
372--- packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.dirs 2009-10-20 02:23:22 +0000
373+++ packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.dirs 2009-12-21 19:35:21 +0000
374@@ -4,6 +4,7 @@
375 sbin
376 usr/bin
377 usr/lib/openvista
378+usr/share/openvista
379 usr/sbin
380 usr/share/doc/openvista-utils
381 var/www/webdav
382
383=== modified file 'packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.manpages'
384--- packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.manpages 2009-10-20 02:23:22 +0000
385+++ packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/openvista-utils.manpages 2009-12-21 19:35:21 +0000
386@@ -10,3 +10,5 @@
387 docs/man1/ovpurgejournals.1
388 docs/man1/ovswitchjournals.1
389 docs/man1/ovimport.1
390+docs/man1/ovcheckperms.1
391+docs/man1/ovgetvar.1
392
393=== modified file 'packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/rules'
394--- packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/rules 2009-10-21 23:27:51 +0000
395+++ packages/deb/Ubuntu/9.04/openvista-gtm-integration/debian/rules 2009-12-21 19:35:21 +0000
396@@ -86,7 +86,7 @@
397 dh_prep -i
398 dh_installdirs -i
399
400- install scripts/etc/munin/plugin-conf.d/openvista debian/openvista-munin-plugins/etc/munin/plugin-conf.d/
401+ install -m 644 scripts/etc/munin/plugin-conf.d/openvista debian/openvista-munin-plugins/etc/munin/plugin-conf.d/
402 install scripts/usr/share/munin/plugins/openvista_databases_ debian/openvista-munin-plugins/usr/share/munin/plugins/
403 install scripts/usr/share/munin/plugins/openvista_locks_ debian/openvista-munin-plugins/usr/share/munin/plugins/
404 install scripts/usr/share/munin/plugins/openvista_processes_ debian/openvista-munin-plugins/usr/share/munin/plugins/
405@@ -110,17 +110,17 @@
406
407 install -m 644 scripts/usr/lib/openvista/functions debian/openvista-utils/usr/lib/openvista/
408
409- install scripts/usr/sbin/ovinstanceadd debian/openvista-utils/usr/sbin/
410- install scripts/usr/sbin/ovinstancedel debian/openvista-utils/usr/sbin/
411- install scripts/usr/sbin/ovrestore debian/openvista-utils/usr/sbin/
412-
413- install scripts/usr/bin/openvista debian/openvista-utils/usr/bin/
414- install scripts/usr/bin/ovtied debian/openvista-utils/usr/bin/
415- install scripts/usr/bin/ovcc debian/openvista-utils/usr/bin/
416- install scripts/usr/bin/ovbackup debian/openvista-utils/usr/bin/
417- install scripts/usr/bin/ovpurgejournals debian/openvista-utils/usr/bin/
418- install scripts/usr/bin/ovswitchjournals debian/openvista-utils/usr/bin/
419- install scripts/usr/bin/ovimport debian/openvista-utils/usr/bin/
420+ for config in scripts/usr/share/openvista/*; do \
421+ install -m 644 $$config debian/openvista-utils/usr/share/openvista/ ;\
422+ done
423+
424+ for script in scripts/usr/sbin/*; do \
425+ install $$script debian/openvista-utils/usr/sbin/ ;\
426+ done
427+
428+ for script in scripts/usr/bin/*; do \
429+ install $$script debian/openvista-utils/usr/bin/ ;\
430+ done
431
432 install scripts/etc/init.d/openvista-databases debian/openvista-utils.openvista-databases.init
433 install scripts/etc/init.d/openvista debian/openvista-utils.openvista.init
434
435=== modified file 'packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/changelog'
436--- packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/changelog 2009-11-22 08:04:35 +0000
437+++ packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/changelog 2009-12-21 19:35:21 +0000
438@@ -1,3 +1,12 @@
439+openvista-gtm-integration (0.8.6-0ubuntu2~msc3~karmic1) karmic; urgency=low
440+
441+ * Update utils to honor env config file if it exists (Closes: #336166)
442+ * Add man pages for new ovcheckperms and ovgetvar utilities
443+ * Add config file templates in /usr/share/openvista
444+ * Remove executable bit on munin plugin configuration file
445+
446+ -- Jonathan Tai <jon.tai@medsphere.com> Thu, 17 Dec 2009 10:11:25 -0800
447+
448 openvista-gtm-integration (0.8.6-0ubuntu2~msc2~karmic1) karmic; urgency=low
449
450 * Re-order dependencies so preferred packages come first.
451
452=== modified file 'packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.dirs'
453--- packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.dirs 2009-11-19 21:19:51 +0000
454+++ packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.dirs 2009-12-21 19:35:21 +0000
455@@ -4,6 +4,7 @@
456 sbin
457 usr/bin
458 usr/lib/openvista
459+usr/share/openvista
460 usr/sbin
461 usr/share/doc/openvista-utils
462 var/www/webdav
463
464=== modified file 'packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.manpages'
465--- packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.manpages 2009-11-19 21:19:51 +0000
466+++ packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/openvista-utils.manpages 2009-12-21 19:35:21 +0000
467@@ -10,3 +10,5 @@
468 docs/man1/ovpurgejournals.1
469 docs/man1/ovswitchjournals.1
470 docs/man1/ovimport.1
471+docs/man1/ovcheckperms.1
472+docs/man1/ovgetvar.1
473
474=== modified file 'packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/rules'
475--- packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/rules 2009-11-19 21:19:51 +0000
476+++ packages/deb/Ubuntu/9.10/openvista-gtm-integration/debian/rules 2009-12-21 19:35:21 +0000
477@@ -86,7 +86,7 @@
478 dh_prep -i
479 dh_installdirs -i
480
481- install scripts/etc/munin/plugin-conf.d/openvista debian/openvista-munin-plugins/etc/munin/plugin-conf.d/
482+ install -m 644 scripts/etc/munin/plugin-conf.d/openvista debian/openvista-munin-plugins/etc/munin/plugin-conf.d/
483 install scripts/usr/share/munin/plugins/openvista_databases_ debian/openvista-munin-plugins/usr/share/munin/plugins/
484 install scripts/usr/share/munin/plugins/openvista_locks_ debian/openvista-munin-plugins/usr/share/munin/plugins/
485 install scripts/usr/share/munin/plugins/openvista_processes_ debian/openvista-munin-plugins/usr/share/munin/plugins/
486@@ -110,17 +110,17 @@
487
488 install -m 644 scripts/usr/lib/openvista/functions debian/openvista-utils/usr/lib/openvista/
489
490- install scripts/usr/sbin/ovinstanceadd debian/openvista-utils/usr/sbin/
491- install scripts/usr/sbin/ovinstancedel debian/openvista-utils/usr/sbin/
492- install scripts/usr/sbin/ovrestore debian/openvista-utils/usr/sbin/
493-
494- install scripts/usr/bin/openvista debian/openvista-utils/usr/bin/
495- install scripts/usr/bin/ovtied debian/openvista-utils/usr/bin/
496- install scripts/usr/bin/ovcc debian/openvista-utils/usr/bin/
497- install scripts/usr/bin/ovbackup debian/openvista-utils/usr/bin/
498- install scripts/usr/bin/ovpurgejournals debian/openvista-utils/usr/bin/
499- install scripts/usr/bin/ovswitchjournals debian/openvista-utils/usr/bin/
500- install scripts/usr/bin/ovimport debian/openvista-utils/usr/bin/
501+ for config in scripts/usr/share/openvista/*; do \
502+ install -m 644 $$config debian/openvista-utils/usr/share/openvista/ ;\
503+ done
504+
505+ for script in scripts/usr/sbin/*; do \
506+ install $$script debian/openvista-utils/usr/sbin/ ;\
507+ done
508+
509+ for script in scripts/usr/bin/*; do \
510+ install $$script debian/openvista-utils/usr/bin/ ;\
511+ done
512
513 install scripts/etc/init.d/openvista-databases debian/openvista-utils.openvista-databases.init
514 install scripts/etc/init.d/openvista debian/openvista-utils.openvista.init
515
516=== modified file 'packages/rpm/CentOS/5/openvista-gtm-integration.spec'
517--- packages/rpm/CentOS/5/openvista-gtm-integration.spec 2009-11-23 21:23:06 +0000
518+++ packages/rpm/CentOS/5/openvista-gtm-integration.spec 2009-12-21 19:35:21 +0000
519@@ -63,6 +63,11 @@
520 install -d %{buildroot}/usr/lib/openvista
521 install scripts/usr/lib/openvista/functions %{buildroot}/usr/lib/openvista
522
523+install -d %{buildroot}%{_datadir}/openvista
524+for config in scripts/usr/share/openvista/*; do
525+ install -m 644 $config %{buildroot}%{_datadir}/openvista/
526+done
527+
528 install -d %{buildroot}%{_sbindir}/
529 for script in scripts/usr/sbin/*; do
530 install $script %{buildroot}%{_sbindir}/
531@@ -301,7 +306,7 @@
532
533
534 %package -n openvista-utils
535-Release: 1
536+Release: 2
537 Summary: Utilities for configuring and managing OpenVista
538 Group: Applications/System
539
540@@ -335,6 +340,7 @@
541 %doc COPYING.AGPL
542 %doc NEWS
543 /usr/lib/openvista/functions
544+%{_datadir}/openvista/*
545 %{_sbindir}/*
546 %{_bindir}/*
547 %{_mandir}/man8/*
548
549=== modified file 'scripts/etc/bash_completion.d/openvista'
550--- scripts/etc/bash_completion.d/openvista 2009-12-01 22:03:11 +0000
551+++ scripts/etc/bash_completion.d/openvista 2009-12-21 19:35:21 +0000
552@@ -19,14 +19,8 @@
553 # Oaks Way, Suite 200, Carlsbad, CA 92008 or at legal@medsphere.com.
554
555
556-_ovinstances()
557-{
558- for instance in `ls /opt/openvista 2> /dev/null`; do
559- if [ -L "/opt/openvista/$instance/gtm" ]; then
560- echo $instance
561- fi
562- done
563-}
564+# common functions
565+. /usr/lib/openvista/functions
566
567 _ov()
568 {
569@@ -64,7 +58,7 @@
570 ;;
571 *)
572 if [ $allowed_nonopt_words -eq 0 ]; then
573- COMPREPLY=( $(compgen -W "$(_ovinstances)" -- $cur) )
574+ COMPREPLY=( $(compgen -W "$(list_openvista_instances)" -- $cur) )
575 else
576 _filedir
577 fi
578@@ -135,10 +129,10 @@
579
580 complete -F _ovinstanceadd ovinstanceadd
581
582-# ovimport [-h] [-V] [-q] [-f] [-c imported|all|none] [-r] ROUTINES [-g] GLOBALS INSTANCE_NAME
583+# ovimport [-h] [-V] [-q] [-f] [-t target] [-c imported|all|none] [-r] ROUTINES [-g] GLOBALS INSTANCE_NAME
584 _ovimport()
585 {
586- opts='-h -V -q -f -c -r -g'
587+ opts='-h -V -q -f -t -c -r -g'
588 allowed_nonopt_words=1
589
590 COMPREPLY=()
591@@ -158,7 +152,7 @@
592 # afterward; use a hack to exit on the next iteration of
593 # the loop
594 allowed_nonopt_words=0
595- elif [ x"${COMP_WORDS[i]}" = x"-c" ] || [ x"${COMP_WORDS[i]}" = x"-r" ] || [ x"${COMP_WORDS[i]}" = x"-g" ]; then
596+ elif [ x"${COMP_WORDS[i]}" = x"-t" ] || [ x"${COMP_WORDS[i]}" = x"-c" ] || [ x"${COMP_WORDS[i]}" = x"-r" ] || [ x"${COMP_WORDS[i]}" = x"-g" ]; then
597 allowed_nonopt_words=`expr $allowed_nonopt_words + 1`
598 fi
599 ;;
600@@ -178,7 +172,11 @@
601 ;;
602 *)
603 if [ $allowed_nonopt_words -eq 0 ]; then
604- COMPREPLY=( $(compgen -W "$(_ovinstances)" -- $cur) )
605+ COMPREPLY=( $(compgen -W "$(list_openvista_instances)" -- $cur) )
606+ elif [ x"$prev" = x"-t" ]; then
607+ _filedir -d
608+ elif [ x"$prev" = x"-c" ]; then
609+ COMPREPLY=( $(compgen -W "imported all none" -- $cur) )
610 elif [ x"$prev" = x"-r" ] || [ x"$prev" = x"-g" ]; then
611 _filedir
612 fi
613@@ -188,3 +186,52 @@
614
615 complete -F _ovimport $filenames ovimport
616
617+# ovgetvar [-h] [-V] INSTANCE_NAME gtm_dist|gtm_path|gtmroutines|gtmgbldir
618+_ovgetvar()
619+{
620+ opts='-h -V'
621+ allowed_nonopt_words=2
622+
623+ COMPREPLY=()
624+
625+ for i in `seq $COMP_CWORD`; do
626+ # we've run out of the allowed number of non-option arguments; perform
627+ # no further completion
628+ if [ $allowed_nonopt_words -eq 0 ]; then
629+ return
630+ fi
631+
632+ case ${COMP_WORDS[i]} in
633+ -*)
634+ # if one of the arguments so far is -h or -V, perform no further completion
635+ if [ x"${COMP_WORDS[i]}" = x"-h" ] || [ x"${COMP_WORDS[i]}" = x"-V" ]; then
636+ # if we just return here, -h won't complete the space
637+ # afterward; use a hack to exit on the next iteration of
638+ # the loop
639+ allowed_nonopt_words=0
640+ fi
641+ ;;
642+
643+ *)
644+ allowed_nonopt_words=`expr $allowed_nonopt_words - 1`
645+ ;;
646+ esac
647+ done
648+
649+ cur=${COMP_WORDS[COMP_CWORD]}
650+
651+ case $cur in
652+ -*)
653+ COMPREPLY=( $(compgen -W "$opts" -- $cur) )
654+ ;;
655+ *)
656+ if [ $allowed_nonopt_words -eq 0 ]; then
657+ COMPREPLY=( $(compgen -W "gtm_dist gtm_path gtmroutines gtmgbldir" -- $cur) )
658+ else
659+ COMPREPLY=( $(compgen -W "$(list_openvista_instances)" -- $cur) )
660+ fi
661+ ;;
662+ esac
663+}
664+
665+complete -F _ovgetvar ovgetvar
666
667=== modified file 'scripts/etc/cron.daily/openvista'
668--- scripts/etc/cron.daily/openvista 2009-12-01 22:02:20 +0000
669+++ scripts/etc/cron.daily/openvista 2009-12-21 19:35:21 +0000
670@@ -34,11 +34,11 @@
671 # Oaks Way, Suite 200, Carlsbad, CA 92008 or at legal@medsphere.com.
672
673
674-root="/opt/openvista"
675-user="openvista"
676+# common functions
677+. /usr/lib/openvista/functions
678
679-for instance in `ls $root`; do
680- [ -L "$root/$instance/gtm" ] || continue
681+for instance in `list_openvista_instances`; do
682+ set_gtm_env "$instance"
683
684 # the default is "yes" unless the etc/backups.conf file exists and it has
685 # backup_daily set to "no"... in other words, an instance has to "opt out"
686
687=== modified file 'scripts/etc/init.d/openvista'
688--- scripts/etc/init.d/openvista 2009-08-31 19:42:33 +0000
689+++ scripts/etc/init.d/openvista 2009-12-21 19:35:21 +0000
690@@ -62,9 +62,6 @@
691 [ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions
692 . /usr/lib/openvista/functions
693
694-root="/opt/openvista"
695-user="openvista"
696-
697 run_hook()
698 {
699 set_gtm_env "$1" || return 1
700@@ -124,10 +121,8 @@
701 elif function_exists "log_daemon_msg"; then
702 log_daemon_msg "Running startup hooks for OpenVista databases"
703 fi
704-
705- for instance in `ls $root`; do
706- [ -L "$root/$instance/gtm" ] || continue
707
708+ for instance in `list_openvista_instances`; do
709 if function_exists "action"; then
710 action $" Running startup hooks for $instance: " run_hook "$instance" ZSTART
711 elif function_exists "log_daemon_msg"; then
712@@ -161,9 +156,7 @@
713 log_daemon_msg "Running shutdown hooks for OpenVista databases"
714 fi
715
716- for instance in `ls $root`; do
717- [ -L "$root/$instance/gtm" ] || continue
718-
719+ for instance in `list_openvista_instances`; do
720 if function_exists "action"; then
721 action $" Running shutdown hooks for $instance: " run_hook "$instance" ZSTOP
722 elif function_exists "log_daemon_msg"; then
723
724=== modified file 'scripts/etc/init.d/openvista-databases'
725--- scripts/etc/init.d/openvista-databases 2009-10-22 19:48:28 +0000
726+++ scripts/etc/init.d/openvista-databases 2009-12-21 19:35:21 +0000
727@@ -69,8 +69,6 @@
728 [ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions
729 . /usr/lib/openvista/functions
730
731-root="/opt/openvista"
732-
733 recover_backward()
734 {
735 set_gtm_env "$1" || return 1
736@@ -158,7 +156,7 @@
737 if [ `id -u` -ne 0 ]; then
738 echo "openvista-databases: Must be run as root" >&2
739 exit 4 # LSB: user had insufficient privilege
740-fi
741+fi
742
743 # check for for valid arguments (requires correct permissions to do; must happen after permission checks)
744 if [ -n "$2" ]; then
745@@ -177,9 +175,7 @@
746 log_daemon_msg "Performing backward journal recovery on OpenVista databases"
747 fi
748
749- for instance in `ls $root`; do
750- [ -L "$root/$instance/gtm" ] || continue
751-
752+ for instance in `list_openvista_instances`; do
753 if function_exists "action"; then
754 action $" Performing recovery on $instance database: " recover_backward "$instance"
755 elif function_exists "log_daemon_msg"; then
756@@ -212,10 +208,8 @@
757 elif function_exists "log_daemon_msg"; then
758 log_daemon_msg "Terminating remaining mumps processes"
759 fi
760-
761- for instance in `ls $root`; do
762- [ -L "$root/$instance/gtm" ] || continue
763
764+ for instance in `list_openvista_instances`; do
765 if function_exists "action"; then
766 action $" Terminating mumps processes in $instance: " terminate_processes "$instance"
767 elif function_exists "log_daemon_msg"; then
768
769=== modified file 'scripts/usr/bin/ovbackup'
770--- scripts/usr/bin/ovbackup 2009-10-31 06:23:59 +0000
771+++ scripts/usr/bin/ovbackup 2009-12-21 19:35:21 +0000
772@@ -80,7 +80,7 @@
773 }
774
775 if [ -e "$root/$instance/etc/backups.conf" ]; then
776- . "$root/$instance/etc/backups.conf"
777+ . "$root/$instance/etc/backups.conf"
778 fi
779
780 case $num_backups in
781@@ -88,7 +88,7 @@
782 # num_backups was not set, blank, 0, or not an integer; set to default of 3
783 num_backups=3
784 ;;
785-esac
786+esac
787
788 print_status "ovbackup" "Starting backup of $instance" "$skip_status"
789
790@@ -98,7 +98,7 @@
791 # the EXIT handler may or may not run if we're interrupted or killed depending
792 # on the shell used (from what I've read, it does run on bash, but not on
793 # dash); use $exit to exit with the correct status in both cases
794-trap '[ -z "$exit" ] && rm -rf "$tempdir"; exit ${exit:-0}' EXIT
795+trap 'rm -rf "$tempdir"; exit ${exit:-0}' EXIT
796
797 trap 'print_status "ovbackup" "Caught SIGINT, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=130}' INT
798 trap 'print_status "ovbackup" "Caught SIGTERM, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=143}' TERM
799@@ -109,16 +109,31 @@
800 # store the version of GT.M the current instance is using in the backup file per bug404177
801 echo -e 'W $ZVERSION\nH\n' | mumps -dir 2>&1 | grep -v '^$' | grep -v '>$' > "$tempdir/gtm_version"
802
803+print_status "ovbackup" "Copying configuration files" "$skip_status"
804+
805+install -m 2750 -d "$tempdir/etc" ||
806+exit_with_error "ovbackup" "Unable to copy configuration files"
807+
808+# copy env file if it exists
809+if [ -f "$root/$instance/etc/env" ]; then
810+ cp -p "$root/$instance/etc/env" "$tempdir/etc/" ||
811+ exit_with_error "ovbackup" "Unable to copy env configuration file"
812+fi
813+
814 print_status "ovbackup" "Copying routines" "$skip_status"
815
816-cp -a "$root/$instance/routines" "$tempdir" ||
817+# follow symlinks when copying (copy the routines pointed to by the symlink,
818+# not the symlink itself). this allows administrators to reference routines
819+# outside the OpenVista instance's routines directory and still have them
820+# backed up (e.g., to share routines between OpenVista instances)
821+cp -RLp "$root/$instance/routines" "$tempdir" ||
822 exit_with_error "ovbackup" "Unable to copy routines"
823
824 print_status "ovbackup" "Copying database files" "$skip_status"
825
826 {
827 install -m 2750 -d "$tempdir/globals" &&
828- cp -a "$root/$instance/globals/mumps.gld" "$tempdir/globals/"
829+ cp -p "$root/$instance/globals/mumps.gld" "$tempdir/globals/"
830 } || exit_with_error "ovbackup" "Unable to copy mumps.gld global directory file"
831
832 # save this timestamp - this is the timestamp that the backup is consistent to.
833@@ -165,7 +180,7 @@
834 #
835 # FIXME: if the routines did change, we should probably try again instead of
836 # just aborting - rsync the routines, then re-run the database backup
837-output=`rsync -rli --delete --dry-run "$root/$instance/routines/" "$tempdir/routines/"`
838+output=`rsync -rLi --delete --dry-run "$root/$instance/routines/" "$tempdir/routines/"`
839 [ -z "$output" ] || exit_with_error "ovbackup" "Routines changed during backup"
840
841 # if we get here, that means that the routines haven't changed, and either the
842@@ -185,7 +200,7 @@
843
844 (
845 umask 007
846- tar -c --remove-files `choose_bzip2` -f "$tempdir/${instance}-$timestamp.tar.bz2" -C "$tempdir" gtm_version routines globals
847+ tar -c --remove-files `choose_bzip2` -f "$tempdir/${instance}-$timestamp.tar.bz2" -C "$tempdir" gtm_version etc routines globals
848 ) || exit_with_error "ovbackup" "Unable to compress temporary backup directory"
849
850 # since redirection is not safe (it follows symlinks), create the file in the
851
852=== modified file 'scripts/usr/bin/ovcheckperms'
853--- scripts/usr/bin/ovcheckperms 2009-12-01 23:05:48 +0000
854+++ scripts/usr/bin/ovcheckperms 2009-12-21 19:35:21 +0000
855@@ -79,7 +79,7 @@
856 fi
857
858 if [ -z "$apache_user" ]; then
859- echo "ovinstanceadd: apache user not found in /etc/passwd" >&2
860+ echo "ovcheckperms: apache user not found in /etc/passwd" >&2
861 exit 2
862 fi
863
864@@ -114,6 +114,10 @@
865 check_perms "$root/$instance/routines" "drwxrws--- root openvista"
866 check_perms "$root/$instance/tmp" "drwxrws--- root openvista"
867
868+if [ -f "$root/$instance/etc/env" ]; then
869+ check_perms "$root/$instance/etc/env" "-rw-r----- root openvista"
870+fi
871+
872 count=`find "$root/$instance/journals" -type f -name '*.mjl*' \! \( -perm '0666' -a -group openvista \) | wc -l`
873 if [ "$count" -ne 0 ]; then
874 logger -p user.info -t "ovcheckperms[$$]" -- "$instance: $count journals found with incorrect permissions and/or ownership, should be -rw-rw-rw- and group openvista"
875
876=== added file 'scripts/usr/bin/ovgetvar'
877--- scripts/usr/bin/ovgetvar 1970-01-01 00:00:00 +0000
878+++ scripts/usr/bin/ovgetvar 2009-12-21 19:35:21 +0000
879@@ -0,0 +1,104 @@
880+#!/bin/bash
881+
882+# This script prints the effective values of $gtm_dist, $gtmroutines, and
883+# $gtmgbldir for the specified OpenVista instance.
884+
885+
886+# Copyright (C) 2009 Medsphere Systems Corporation
887+#
888+# This program is free software; you can redistribute it and/or modify it solely
889+# under the terms of the GNU Affero General Public License version 3 as published
890+# by the Free Software Foundation.
891+#
892+# This program is distributed in the hope that it will be useful, but WITHOUT
893+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
894+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
895+# for more details.
896+#
897+# You should have received a copy of the GNU Affero General Public License
898+# along with this program. If not, see <http://www.gnu.org/licenses>.
899+#
900+# You can contact Medsphere Systems Corporation headquarters at 1917 Palomar
901+# Oaks Way, Suite 200, Carlsbad, CA 92008 or at legal@medsphere.com.
902+
903+
904+# common functions
905+. /usr/lib/openvista/functions
906+
907+# parse arguments
908+while getopts hV option; do
909+ case $option in
910+ h)
911+ cat <<EOF
912+Usage: ovgetvar INSTANCE_NAME gtm_dist|gtm_path|gtmroutines|gtmgbldir
913+ or ovgetvar -h
914+ or ovgetvar -V
915+
916+ -h display this help text and exit
917+ -V display version information and exit
918+EOF
919+ exit 0
920+ ;;
921+ V)
922+ cat <<EOF
923+ovgetvar 0.8.6
924+Copyright (C) 2009 Medsphere Systems Corporation
925+
926+ovgetvar is powered by Medsphere and part of a suite of open source
927+utilities licensed under the AGPL, available at http://medsphere.org.
928+EOF
929+ exit 0
930+ ;;
931+ esac
932+done
933+shift `expr $OPTIND - 1`
934+
935+# check command syntax
936+if [ -z "$1" ]; then
937+ echo "ovgetvar: missing OpenVista instance name" >&2
938+ echo "Try 'ovgetvar -h' for more information" >&2
939+ exit 2
940+fi
941+
942+# check permissions
943+in_groups || {
944+ echo "ovgetvar: permission denied" >&2
945+ exit 1
946+}
947+
948+# check for for valid arguments (requires correct permissions to do; must happen after permission checks)
949+set_gtm_env "$1" || {
950+ echo "ovgetvar: $instance: Not an OpenVista instance" >&2
951+ exit 3
952+}
953+
954+if [ -z "$2" ]; then
955+ echo "ovgetvar: missing key" >&2
956+ echo "Try 'ovgetvar -h' for more information" >&2
957+ exit 2
958+fi
959+
960+case $2 in
961+ gtm_dist)
962+ echo "$gtm_dist"
963+ ;;
964+ gtm_path)
965+ if [ -L "$gtm_dist" ]; then
966+ readlink "$gtm_dist"
967+ else
968+ echo "$gtm_dist"
969+ fi
970+ ;;
971+ gtmroutines)
972+ echo "$gtmroutines"
973+ ;;
974+ gtmgbldir)
975+ echo "$gtmgbldir"
976+ ;;
977+ *)
978+ echo "ovgetvar: invalid key" >&2
979+ echo "Try 'ovgetvar -h' for more information" >&2
980+ exit 3
981+ ;;
982+esac
983+
984
985=== modified file 'scripts/usr/bin/ovimport'
986--- scripts/usr/bin/ovimport 2009-12-01 21:51:30 +0000
987+++ scripts/usr/bin/ovimport 2009-12-21 19:35:21 +0000
988@@ -25,16 +25,17 @@
989 . /usr/lib/openvista/functions
990
991 # parse arguments
992-while getopts hVqfc:r:g: option; do
993+while getopts hVqft:c:r:g: option; do
994 case $option in
995 h)
996 cat <<EOF
997-Usage: ovimport [-q] [-f] [-c imported|all|none] [-r ROUTINES] [-g GLOBALS] INSTANCE_NAME
998+Usage: ovimport [-q] [-f] [-t target] [-c imported|all|none] [-r ROUTINES] [-g GLOBALS] INSTANCE_NAME
999 or ovimport -h
1000 or ovimport -V
1001
1002 -q quiet; suppress status messages
1003 -f force; import routines and globals even if target instance is not empty
1004+ -t target; directory to import routines into (defaults to routines subdirectory of instance)
1005 -c compile imported routines only (the default), all routines, or no routines
1006 -r path to routine export file, archive, or directory
1007 -g path to global export file or archive
1008@@ -59,6 +60,9 @@
1009 f)
1010 force=true
1011 ;;
1012+ t)
1013+ target=$OPTARG
1014+ ;;
1015 c)
1016 compile=$OPTARG
1017 ;;
1018@@ -96,6 +100,15 @@
1019 exit 3
1020 }
1021
1022+: ${target:="$root/$instance/routines"}
1023+if [ ! -d "$target" ]; then
1024+ echo "ovimport: $target: No such directory" >&2
1025+ exit 3
1026+fi
1027+
1028+# make sure target ends in a slash
1029+target=`echo "$target" | sed 's;/$;;'`/
1030+
1031 if [ -z "$routines" ] && [ -z "$globals" ]; then
1032 echo "ovimport: No routines or globals specified; please use -r ROUTINES, -g GLOBALS, or both" >&2
1033 exit 3
1034@@ -103,14 +116,14 @@
1035
1036 if [ "0x0000000000000001" != `dse dump -fileheader 2>&1 | grep -F 'Current transaction' | awk '{ print $3 }'` ]; then
1037 $force || {
1038- echo "ovimport: $instance: OpenVista instance is not new; use -f to force"
1039+ echo "ovimport: $instance: OpenVista instance is not new; use -f to force" >&2
1040 exit 1
1041 }
1042 fi
1043
1044 if [ -n "`find \"$root/$instance/routines/\" -type f -name '*.m' -print -quit`" ]; then
1045 $force || {
1046- echo "ovimport: $instance: OpenVista instance is not new; use -f to force"
1047+ echo "ovimport: $instance: OpenVista instance is not new; use -f to force" >&2
1048 exit 1
1049 }
1050 fi
1051@@ -121,7 +134,7 @@
1052 # the EXIT handler may or may not run if we're interrupted or killed depending
1053 # on the shell used (from what I've read, it does run on bash, but not on
1054 # dash); use $exit to exit with the correct status in both cases
1055-trap '[ -z "$exit" ] && rm -rf "$tempdir"; exit ${exit:-0}' EXIT
1056+trap 'rm -rf "$tempdir"; exit ${exit:-0}' EXIT
1057
1058 trap 'print_status "ovimport" "Caught SIGINT, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=130}' INT
1059 trap 'print_status "ovimport" "Caught SIGTERM, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=143}' TERM
1060@@ -194,40 +207,41 @@
1061 real_routines=`cd "$dirname"; pwd`/"$basename"
1062
1063 # redirect output to a temporary file because we need to both log
1064- # the output and inspect it to determine success
1065+ # the output and inspect it later to determine success
1066 (
1067 umask 007
1068- mumps -run ^%RI > "$tempdir/ovimport.ri" 2>&1 <<EOF
1069-N
1070-$real_routines
1071-$root/$instance/routines/
1072-EOF
1073+ echo -e 'N\n'"$real_routines"'\n'"$target"'\n' | mumps -run ^%RI 2>&1 \
1074+ | tee "$tempdir/ovimport.ri" \
1075+ | grep -v '^$' \
1076+ | logger -p user.info -t "ovimport[$$]"
1077 )
1078
1079- cat "$tempdir/ovimport.ri" \
1080- | grep -v '^$' \
1081- | logger -p user.info -t "ovimport[$$]"
1082-
1083- grep '^Restored [0-9]\{1,\} lines in [0-9]\{1,\} routines' "$tempdir/ovimport.ri" > /dev/null ||
1084+ grep '^Restored [0-9]\{1,\} lines in [0-9]\{1,\} routine' "$tempdir/ovimport.ri" > /dev/null ||
1085 exit_with_error "ovimport" "Unable to import routines"
1086
1087- awk '{ if ($0 ~ /^Restored [0-9]+ lines in [0-9]+ routines/) { capture = 0 } if (capture == 1 && NF != 0) { print $0 } if ($0 ~ /^Output directory/) { capture = 1 } }' "$tempdir/ovimport.ri" > "$tempdir/ovimport.compile"
1088+ for routine in `awk '{ if ($0 ~ /^Restored [0-9]+ lines in [0-9]+ routine/) { capture = 0 } if (capture == 1 && NF != 0) { print $0 } if ($0 ~ /^Output directory/) { capture = 1 } }' "$tempdir/ovimport.ri"`; do
1089+ echo "$routine" | sed 's/^%/_/' >> "$tempdir/ovimport.compile"
1090+ done
1091 ;;
1092 M)
1093 print_status "ovimport" "Copying routines" "$skip_status"
1094
1095 (
1096 umask 007
1097- rsync -rl --exclude '.*/' --include '*/' --include '*.m' --exclude '*' --out-format='%n' "$real_routines/" "$root/$instance/routines/" > "$tempdir/ovimport.compile"
1098+ rsync -rlv --exclude '.*/' --include '*/' --include '*.m' --exclude '*' "$real_routines/" "$target" > "$tempdir/ovimport.rsync"
1099 ) || exit_with_error "ovimport" "Unable to import routines"
1100
1101+ for routine in `cat "$tempdir/ovimport.rsync" | grep '\.m$'`; do
1102+ basename "$routine" | sed 's/\.m$//' >> "$tempdir/ovimport.compile"
1103+ done
1104+
1105 # the umask is not enough to guarantee that the routines are user
1106 # and group readable and writable; if the source routines are not
1107 # group writable, the destination routines won't be, either.
1108 #
1109 # if we're not running as root, we won't be able to set the
1110 # permissions for files we don't own, so just do our best
1111- chmod -R u+rw,g+rw "$root/$instance/routines/" 2> /dev/null
1112+ chmod -R u+rw,g+rw "$target" 2> /dev/null
1113 ;;
1114 esac
1115
1116@@ -235,11 +249,19 @@
1117 all)
1118 print_status "ovimport" "Compiling all routines" "$skip_status"
1119
1120+ # FIXME: there is a possibility (if the env file doesn't match the
1121+ # -t target) that %RSEL will come up empty and no routines will be
1122+ # compiled.
1123+
1124+ # use mumps to compile all the files via auto-zlink; this will ensure that the
1125+ # correct version of the routine is compiled if more than one version exists
1126+ # in a different tier and that the object file is compiled to the right place.
1127 (
1128 umask 007
1129- cd "$root/$instance/objects" &&
1130- find "$root/$instance/routines/" -type f -name '*.m' -exec mumps {} \; 2> /dev/null
1131- ) || exit_with_error "ovimport" "Unable to compile routines"
1132+ echo -e 'D SILENT^%RSEL("*") S R="" F S R=$O(%ZR(R)) Q:R="" ZLINK $S($E(R)="%":"_"_$E(R,2,$L(R)),1:R)\nH\n' | mumps -dir 2>&1 \
1133+ | grep -v '^$' | grep -v '>$' \
1134+ | logger -p user.info -t "ovimport[$$]"
1135+ )
1136 ;;
1137 none)
1138 print_status "ovimport" "Skipping routine compilation" "$skip_status"
1139@@ -249,11 +271,39 @@
1140
1141 (
1142 umask 007
1143- cd "$root/$instance/objects" &&
1144- for routine in `cat "$tempdir/ovimport.compile" | sed 's/\.m//g'`; do
1145- mumps "../routines/$routine.m" 2> /dev/null
1146- done
1147- )
1148+ cat "$tempdir/ovimport.compile" | sort | uniq > "$tempdir/ovimport.compile.uniq"
1149+ echo -e 'S LIST="'"$tempdir/ovimport.compile.uniq"'"\nO LIST:(readonly) U LIST F R ROUTINE Q:ROUTINE="" ZLINK ROUTINE\nC LIST U $P\nH\n' | mumps -dir 2>&1 \
1150+ | tee "$tempdir/ovimport.zlink" \
1151+ | grep -v '^$' | grep -v '>$' \
1152+ | logger -p user.info -t "ovimport[$$]"
1153+
1154+ # There are a couple of things could cause the routine compilation to fail
1155+ # (besides compile errors, which we should ignore).
1156+ #
1157+ # The user could have used the wrong -r argument, e.g.,
1158+ # /home/jon/openvistaserver-1.5.sp2-gtm instead of
1159+ # /home/jon/openvistaserver-1.5.sp2-gtm/routines, which would cause the
1160+ # routines to be imported to /opt/openvista/instance/routines/routines.
1161+ #
1162+ # The user could have specified a target directory other than
1163+ # /opt/openvista/instance/routines with -t but forgot to update $gtmroutines in
1164+ # /opt/openvista/instance/etc/env to reflect the target directory.
1165+ #
1166+ # The reverse of the previous case -- the user updated $gtmroutines in the env
1167+ # file but forgot to specify a target directory with -t.
1168+ #
1169+ # The env file has an invalid $gtmroutines setting.
1170+ grep -F '%GTM-E-ZLINKFILE' "$tempdir/ovimport.zlink" > /dev/null && exit 1 # exit subshell
1171+
1172+ exit 0
1173+ ) || {
1174+ # provide a helpful suggestion for the most common error -- "Unable to compile routines" can be a little cryptic
1175+ if [ "$target" = "$root/$instance/routines/" ] && [ `cat "$root/$instance/etc/env" 2> /dev/null | grep -v '^$' | grep -v '^#' | wc -l` -eq 0 ] && [ -d "$routines" ]; then
1176+ suggestion=" (routines in $routines should not be in subdirectories)"
1177+ fi
1178+
1179+ exit_with_error "ovimport" "Unable to compile routines$suggestion"
1180+ }
1181 ;;
1182 esac
1183
1184@@ -289,7 +339,7 @@
1185 | logger -p user.info -t "ovimport[$$]"
1186 }
1187
1188- print_status "ovimport" "Loading globals using 'mupip load'" "$skip_status"
1189+ print_status "ovimport" "Loading globals" "$skip_status"
1190
1191 mupip load -format="$globals_format" "$real_globals" 2>&1 \
1192 | grep -v '^$' \
1193
1194=== modified file 'scripts/usr/lib/openvista/functions'
1195--- scripts/usr/lib/openvista/functions 2009-10-22 19:48:28 +0000
1196+++ scripts/usr/lib/openvista/functions 2009-12-21 19:35:21 +0000
1197@@ -19,9 +19,10 @@
1198 # Oaks Way, Suite 200, Carlsbad, CA 92008 or at legal@medsphere.com.
1199
1200
1201-# set environmental variables required by GT.M - takes a single argument, the
1202-# name of an OpenVista instance
1203-set_gtm_env()
1204+# check if an OpenVista instance exists. this is normally not called directly;
1205+# see list_openvista_instances or set_gtm_env. returns 0 if instance exists
1206+# and passes basic sanity checks, 1 otherwise
1207+is_openvista_instance()
1208 {
1209 # these are set for the benefit of the calling script
1210 root="/opt/openvista"
1211@@ -35,27 +36,85 @@
1212 # check for special characters in $instance
1213 case $instance in
1214 */*|*" "*|*"("*|*")"*)
1215- return 2
1216+ return 1
1217 ;;
1218 esac
1219
1220 # ensure the instance root directory exists
1221 if [ ! -d "$root/$instance" ]; then
1222- return 3
1223+ return 1
1224 fi
1225
1226 # ensure that the directory looks like an OpenVista instance
1227- if [ ! -L "$root/$instance/gtm" ]; then
1228- return 4
1229- fi
1230-
1231- gtm_dist="$root/$instance/gtm"
1232- gtmroutines="$root/$instance/objects($root/$instance/routines) $root/$instance/gtm"
1233- gtmgbldir="$root/$instance/globals/mumps.gld"
1234- gtm_zinterrupt='I $$JOBEXAM^ZU($ZPOSITION)'
1235- gtm_prompt=`echo "$instance>" | tr '[:lower:]' '[:upper:]'`
1236- GTMXC_openvista="$root/$instance/gtm/openvista.xc"
1237- PATH="$PATH:$root/$instance/gtm"
1238+ if [ ! -f "$root/$instance/etc/env" ] && [ ! -L "$root/$instance/gtm" ]; then
1239+ return 1
1240+ fi
1241+
1242+ return 0
1243+}
1244+
1245+# returns a list of openvista instances
1246+list_openvista_instances()
1247+{
1248+ is_openvista_instance "foo" # dummy call to set $root
1249+
1250+ for instance in `ls "$root" 2> /dev/null`; do
1251+ is_openvista_instance "$instance" || continue
1252+ echo $instance
1253+ done
1254+}
1255+
1256+# set environmental variables required by GT.M - takes a single argument, the
1257+# name of an OpenVista instance
1258+set_gtm_env()
1259+{
1260+ is_openvista_instance "$1" || return 1
1261+
1262+ # unset all vars to prevent contamination from the calling environment
1263+ gtm_dist=""
1264+ gtmroutines=""
1265+ gtmgbldir=""
1266+ gtm_zinterrupt=""
1267+ gtm_prompt=""
1268+ GTMXC_openvista=""
1269+
1270+ # if the env file exists, source it
1271+ if [ -f ${2:-"$root/$instance/etc/env"} ]; then
1272+ . ${2:-"$root/$instance/etc/env"}
1273+ fi
1274+
1275+ # set remaining variables if they have not been set already
1276+ #
1277+ # if none of these variables were dependent on each other, we could have
1278+ # just set them first, then sourced the env file, but since they depend on
1279+ # each other (e.g., gtmroutines contains gtm_dist), we need to first source
1280+ # the env file, then set the variables conditionally
1281+
1282+ if [ -z "$gtm_dist" ]; then
1283+ gtm_dist="$root/$instance/gtm"
1284+ fi
1285+
1286+ if [ -z "$gtmroutines" ]; then
1287+ gtmroutines="$root/$instance/objects($root/$instance/routines) $gtm_dist"
1288+ fi
1289+
1290+ if [ -z "$gtmgbldir" ]; then
1291+ gtmgbldir="$root/$instance/globals/mumps.gld"
1292+ fi
1293+
1294+ if [ -z "$gtm_zinterrupt" ]; then
1295+ gtm_zinterrupt='I $$JOBEXAM^ZU($ZPOSITION)'
1296+ fi
1297+
1298+ if [ -z "$gtm_prompt" ]; then
1299+ gtm_prompt=`echo "$instance>" | tr '[:lower:]' '[:upper:]'`
1300+ fi
1301+
1302+ if [ -z "$GTMXC_openvista" ]; then
1303+ GTMXC_openvista="$gtm_dist/openvista.xc"
1304+ fi
1305+
1306+ PATH="$PATH:$gtm_dist"
1307
1308 export gtm_dist
1309 export gtmroutines
1310@@ -71,6 +130,7 @@
1311 # check user's group membership - users need to be in the gtm group to use
1312 # GT.M; users need to be in the openvista group to access files under
1313 # /opt/openvista. If the user is root, pretend that root is in both groups.
1314+# returns 0 if group membership is OK, 1 if not OK
1315 in_groups()
1316 {
1317 if [ `id -u` -eq 0 ]; then
1318@@ -129,6 +189,7 @@
1319 fi
1320 }
1321
1322+# check if a certain bash function has been defined
1323 function function_exists()
1324 {
1325 type "$1" 2> /dev/null | grep -q 'function'
1326
1327=== modified file 'scripts/usr/sbin/ovinstanceadd'
1328--- scripts/usr/sbin/ovinstanceadd 2009-12-01 22:25:59 +0000
1329+++ scripts/usr/sbin/ovinstanceadd 2009-12-21 19:35:21 +0000
1330@@ -184,66 +184,11 @@
1331 set_gtm_env "$instance" ||
1332 exit_with_error "ovinstanceadd" "Unable to set GT.M environment"
1333
1334-(
1335- umask 027
1336- cat > "$root/$instance/etc/backups.conf" <<EOF
1337-# configuration file for OpenVista backup utilities
1338-# this file is sourced by bash, so any valid bash syntax is allowed
1339-
1340-# backup_daily: Back up this instance automatically once per day
1341-#
1342-# The /etc/cron.daily/openvista script runs once per day and backs up all
1343-# instances with backup_daily set to "yes" one after another to avoid excessive
1344-# I/O from all the instances being backed up simultaneously.
1345-#
1346-# If backup_daily is set to "yes" here, the /etc/cron.daily/openvista script
1347-# will back up this instance. The default is "yes".
1348-#
1349-# If you want this instance to be backed up on a custom schedule, set
1350-# backup_daily to "no" here and add an entry for this instance in
1351-# /etc/cron.d/openvista.
1352-#
1353-backup_daily=yes
1354-
1355-# num_backups: Number of backups to keep in the backups directory
1356-#
1357-# After a successful backup, if there are more than num_backups backup files in
1358-# the backups directory, the oldest file will be deleted until the number of
1359-# backup files is less than or equal to num_backups. The default is 3.
1360-#
1361-num_backups=3
1362-
1363-EOF
1364-) || exit_with_error "ovinstanceadd" "Unable to write backups.conf configuration file"
1365-
1366-(
1367- umask 027
1368- cat > "$root/$instance/etc/journals.conf" <<EOF
1369-# configuration file for OpenVista journaling
1370-# this file is sourced by bash, so any valid bash syntax is allowed
1371-
1372-# purge_daily: Purge old journals for this instance automatically once per day
1373-#
1374-# If purge_daily is set to "yes" here, the /etc/cron.daily/openvista script
1375-# will call ovpurgejournals on this instance. The default is "yes".
1376-#
1377-# If you want old journals for this instance to be removed on a custom
1378-# schedule, set purge_daily to "no" here and add an entry for this instance in
1379-# /etc/cron.d/openvista.
1380-#
1381-purge_daily=yes
1382-
1383-# num_journals: Number of old journals to keep in the journals directory
1384-#
1385-# After a successful backup, all inactive journals should be safe to delete.
1386-# However, disk space permitting, it is a good idea to keep a few old journal
1387-# files around in case there is a problem with the most recent backup. The
1388-# default is 3.
1389-#
1390-num_journals=3
1391-
1392-EOF
1393-) || exit_with_error "ovinstanceadd" "Unable to write journals.conf configuration file"
1394+{
1395+ install -o root -g $user -m 640 /usr/share/openvista/backups.conf "$root/$instance/etc/" &&
1396+ install -o root -g $user -m 640 /usr/share/openvista/journals.conf "$root/$instance/etc/" &&
1397+ install -o root -g $user -m 640 /usr/share/openvista/env "$root/$instance/etc/"
1398+} || exit_with_error "ovinstanceadd" "Unable to create configuration files"
1399
1400 # create the global directory file, mumps.gld
1401 (
1402
1403=== modified file 'scripts/usr/sbin/ovrestore'
1404--- scripts/usr/sbin/ovrestore 2009-12-01 03:37:46 +0000
1405+++ scripts/usr/sbin/ovrestore 2009-12-21 19:35:21 +0000
1406@@ -143,7 +143,7 @@
1407 # the EXIT handler may or may not run if we're interrupted or killed depending
1408 # on the shell used (from what I've read, it does run on bash, but not on
1409 # dash); use $exit to exit with the correct status in both cases
1410-trap '[ -z "$exit" ] && rm -rf "$tempdir"; exit ${exit:-0}' EXIT
1411+trap 'rm -rf "$tempdir"; exit ${exit:-0}' EXIT
1412
1413 trap 'print_status "ovrestore" "Caught SIGINT, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=130}' INT
1414 trap 'print_status "ovrestore" "Caught SIGTERM, exiting" "$skip_status"; rm -rf "$tempdir"; exit ${exit:=143}' TERM
1415@@ -157,6 +157,8 @@
1416 tar -x `choose_bzip2` -f "$backup_file" -C "$tempdir" ||
1417 exit_with_error "ovrestore" "Unable to extract contents of backup file"
1418
1419+print_status "ovrestore" "Checking contents of backup file" "$skip_status"
1420+
1421 [ -d "$tempdir/routines" ] || exit_with_error "ovrestore" "Backup file does not contain routines"
1422 [ -f "$tempdir/globals/mumps.gld" ] || exit_with_error "ovrestore" "Backup file does not contain mumps.gld global directory file"
1423 [ -f "$tempdir/globals/default.dat" ] || exit_with_error "ovrestore" "Backup file does not contain default.dat database file"
1424@@ -170,6 +172,43 @@
1425 logger -p user.info -t "ovrestore[$$]" Backup file does not contain GT.M version information
1426 fi
1427
1428+if [ -f "$tempdir/etc/env" ]; then
1429+ # set environment variables from new env file
1430+ set_gtm_env "$instance" "$tempdir/etc/env"
1431+
1432+ # change any references to the destination routines directory to point to
1433+ # the routines directory in the backup
1434+ gtmroutines=`echo "$gtmroutines" | sed "s;$root/$instance/routines;$tempdir/routines;g"`
1435+ export gtmroutines
1436+
1437+ # check $gtmroutines syntax
1438+ zro=`echo -e 'W $ZRO\nH\n' | mumps -dir 2>&1 | grep -v '^$' | grep -v '>$'`
1439+ if echo "$zro" | grep -F '%GTM-E-ZROSYNTAX' > /dev/null; then
1440+ echo "$zro" | logger -p user.info -t "ovrestore[$$]"
1441+ exit_with_error "ovrestore" 'Backup file contains invalid env configuration file ($gtmroutines has invalid syntax or a path in $gtmroutines does not exist)'
1442+ fi
1443+
1444+ # if $gtmgbldir is the default value, check the one in the backup
1445+ if [ "$gtmgbldir" = "$root/$instance/globals/mumps.gld" ]; then
1446+ gtmgbldir="$tempdir/globals/mumps.gld"
1447+ export gtmgbldir
1448+ fi
1449+
1450+ # check $gtmgbldir
1451+ zg=`echo -e 'W ^GLOBAL\nH\n' | mumps -dir 2>&1 | grep -v '^$' | grep -v '>$'`
1452+ if echo "$zg" | grep -F '%GTM-E-ZGBLDIRACC' > /dev/null; then
1453+ echo "$zg" | logger -p user.info -t "ovrestore[$$]"
1454+ exit_with_error "ovrestore" 'Backup file contains invalid env configuration file (global directory file specified by $gtmgbldir does not exist)'
1455+ fi
1456+ if echo "$zg" | grep -F '%GTM-E-GDINVALID' > /dev/null; then
1457+ echo "$zg" | logger -p user.info -t "ovrestore[$$]"
1458+ exit_with_error "ovrestore" 'Backup file contains invalid env configuration file (global directory file specified by $gtmgbldir is in an unrecognized format)'
1459+ fi
1460+
1461+ # re-set environment variables from original env file
1462+ set_gtm_env "$instance"
1463+fi
1464+
1465 # at this point, we're committed... we're about to kill processes, lock the
1466 # instance, overwrite files, etc.
1467
1468@@ -217,6 +256,22 @@
1469 # close this instance off so nobody can use it
1470 chmod 700 "$root/$instance"
1471
1472+print_status "ovrestore" "Restoring configuration files" "$skip_status"
1473+
1474+install -o root -g $user -m 640 /usr/share/openvista/env "$root/$instance/etc/" ||
1475+exit_with_error "ovrestore" "Unable to overwrite existing env configuration file"
1476+
1477+if [ -f "$tempdir/etc/env" ]; then
1478+ {
1479+ chown root:"$user" "$tempdir/etc/env" &&
1480+ chmod 640 "$tempdir/etc/env" &&
1481+ mv -f "$tempdir/etc/env" "$root/$instance/etc/env"
1482+ } || exit_with_error "ovrestore" "Unable to restore env configuration file"
1483+fi
1484+
1485+# re-set environment variables from new env file (or lack of env file)
1486+set_gtm_env "$instance"
1487+
1488 print_status "ovrestore" "Restoring routines" "$skip_status"
1489
1490 {
1491@@ -228,12 +283,19 @@
1492
1493 print_status "ovrestore" "Compiling routines" "$skip_status"
1494
1495+# remove all object files first
1496+find "$root/$instance/objects/" -type f -name '*.o' -exec rm -f {} \; ||
1497+exit_with_error "ovrestore" "Unable to remove existing object files"
1498+
1499+# use mumps to compile all the files via auto-zlink; this will ensure that the
1500+# correct version of the routine is compiled if more than one version exists
1501+# in more than one tier and that the object file is compiled to the right place.
1502 (
1503 umask 007
1504- find "$root/$instance/objects/" -type f -name '*.o' -exec rm -f {} \; &&
1505- cd "$root/$instance/objects" &&
1506- find "$root/$instance/routines/" -type f -name '*.m' -exec mumps {} \; 2> /dev/null
1507-) || exit_with_error "ovrestore" "Unable to compile routines"
1508+ echo -e 'D SILENT^%RSEL("*") S R="" F S R=$O(%ZR(R)) Q:R="" ZLINK $S($E(R)="%":"_"_$E(R,2,$L(R)),1:R)\nH\n' | mumps -dir 2>&1 \
1509+ | grep -v '^$' | grep -v '>$' \
1510+ | logger -p user.info -t "ovrestore[$$]"
1511+)
1512
1513 # if we're not applying journals, shut off journaling on the old database so
1514 # that there's a clean break, then move the journal file out of the way
1515@@ -248,7 +310,7 @@
1516 | grep -v '^$' \
1517 | logger -p user.info -t "ovrestore[$$]"
1518
1519- mv -f "$root/$instance/journals/default.mjl" "$root/$instance/journals/default.mjl_`date +%Y%j%H%M%S`_ovrestore"
1520+ mv -f "$root/$instance/journals/default.mjl" "$root/$instance/journals/default.mjl_`date +%Y%j%H%M%S`_ovrestore" 2> /dev/null
1521 }
1522
1523 print_status "ovrestore" "Restoring database files" "$skip_status"
1524@@ -277,7 +339,12 @@
1525 SHOW -SEGMENT DEFAULT
1526 QUIT
1527 EOF
1528-) || exit_with_error "ovrestore" "Unable to update mumps.gld global directory file"
1529+) || {
1530+ # delete mumps.gld as a safety measure -- it could be pointing to another database
1531+ rm -f "$root/$instance/globals/mumps.gld"
1532+
1533+ exit_with_error "ovrestore" "Unable to update mumps.gld global directory file"
1534+}
1535
1536 {
1537 chown root:"$user" "$tempdir/globals/default.dat" &&
1538@@ -286,7 +353,7 @@
1539 } || exit_with_error "ovrestore" "Unable to restore default.dat database file"
1540
1541 {
1542- mv -f "$root/$instance/globals/scratch.dat" "$root/$instance/globals/scratch.dat~" &&
1543+ mv -f "$root/$instance/globals/scratch.dat" "$root/$instance/globals/scratch.dat~" &&
1544 mupip create -region=SCRATCH 2>&1 \
1545 | grep -v '^$' \
1546 | logger -p user.info -t "ovrestore[$$]"
1547
1548=== modified file 'scripts/usr/share/munin/plugins/openvista_databases_'
1549--- scripts/usr/share/munin/plugins/openvista_databases_ 2009-10-21 17:48:07 +0000
1550+++ scripts/usr/share/munin/plugins/openvista_databases_ 2009-12-21 19:35:21 +0000
1551@@ -25,14 +25,9 @@
1552
1553 . /usr/lib/openvista/functions
1554
1555-root="/opt/openvista"
1556-user="openvista"
1557-
1558 case $1 in
1559 autoconf)
1560- for instance in `ls $root`; do
1561- [ -L "$root/$instance/gtm" ] || continue
1562-
1563+ for instance in `list_openvista_instances`; do
1564 echo "yes"
1565 exit 0
1566 done
1567@@ -42,9 +37,7 @@
1568 ;;
1569
1570 suggest)
1571- for instance in `ls $root`; do
1572- [ -L "$root/$instance/gtm" ] || continue
1573-
1574+ for instance in `list_openvista_instances`; do
1575 echo $instance
1576 done
1577 ;;
1578
1579=== modified file 'scripts/usr/share/munin/plugins/openvista_locks_'
1580--- scripts/usr/share/munin/plugins/openvista_locks_ 2009-10-21 17:48:07 +0000
1581+++ scripts/usr/share/munin/plugins/openvista_locks_ 2009-12-21 19:35:21 +0000
1582@@ -26,14 +26,9 @@
1583
1584 . /usr/lib/openvista/functions
1585
1586-root="/opt/openvista"
1587-user="openvista"
1588-
1589 case $1 in
1590 autoconf)
1591- for instance in `ls $root`; do
1592- [ -L "$root/$instance/gtm" ] || continue
1593-
1594+ for instance in `list_openvista_instances`; do
1595 echo "yes"
1596 exit 0
1597 done
1598@@ -43,9 +38,7 @@
1599 ;;
1600
1601 suggest)
1602- for instance in `ls $root`; do
1603- [ -L "$root/$instance/gtm" ] || continue
1604-
1605+ for instance in `list_openvista_instances`; do
1606 echo $instance
1607 done
1608 ;;
1609
1610=== modified file 'scripts/usr/share/munin/plugins/openvista_processes_'
1611--- scripts/usr/share/munin/plugins/openvista_processes_ 2009-10-21 17:48:07 +0000
1612+++ scripts/usr/share/munin/plugins/openvista_processes_ 2009-12-21 19:35:21 +0000
1613@@ -26,14 +26,9 @@
1614
1615 . /usr/lib/openvista/functions
1616
1617-root="/opt/openvista"
1618-user="openvista"
1619-
1620 case $1 in
1621 autoconf)
1622- for instance in `ls $root`; do
1623- [ -L "$root/$instance/gtm" ] || continue
1624-
1625+ for instance in `list_openvista_instances`; do
1626 echo "yes"
1627 exit 0
1628 done
1629@@ -43,9 +38,7 @@
1630 ;;
1631
1632 suggest)
1633- for instance in `ls $root`; do
1634- [ -L "$root/$instance/gtm" ] || continue
1635-
1636+ for instance in `list_openvista_instances`; do
1637 echo $instance
1638 done
1639 ;;
1640
1641=== added directory 'scripts/usr/share/openvista'
1642=== added file 'scripts/usr/share/openvista/backups.conf'
1643--- scripts/usr/share/openvista/backups.conf 1970-01-01 00:00:00 +0000
1644+++ scripts/usr/share/openvista/backups.conf 2009-12-21 19:35:21 +0000
1645@@ -0,0 +1,26 @@
1646+# configuration file for OpenVista backup utilities
1647+# this file is sourced by bash, so any valid bash syntax is allowed
1648+
1649+# backup_daily: Back up this instance automatically once per day
1650+#
1651+# The /etc/cron.daily/openvista script runs once per day and backs up all
1652+# instances with backup_daily set to "yes" one after another to avoid excessive
1653+# I/O from all the instances being backed up simultaneously.
1654+#
1655+# If backup_daily is set to "yes" here, the /etc/cron.daily/openvista script
1656+# will back up this instance. The default is "yes".
1657+#
1658+# If you want this instance to be backed up on a custom schedule, set
1659+# backup_daily to "no" here and add an entry for this instance in
1660+# /etc/cron.d/openvista.
1661+#
1662+backup_daily=yes
1663+
1664+# num_backups: Number of backups to keep in the backups directory
1665+#
1666+# After a successful backup, if there are more than num_backups backup files in
1667+# the backups directory, the oldest file will be deleted until the number of
1668+# backup files is less than or equal to num_backups. The default is 3.
1669+#
1670+num_backups=3
1671+
1672
1673=== added file 'scripts/usr/share/openvista/env'
1674--- scripts/usr/share/openvista/env 1970-01-01 00:00:00 +0000
1675+++ scripts/usr/share/openvista/env 2009-12-21 19:35:21 +0000
1676@@ -0,0 +1,96 @@
1677+# configuration file for OpenVista
1678+# this file is sourced by bash, so any valid bash syntax is allowed
1679+
1680+# The following environment variables are set to their defaults by set_gtm_env
1681+# in /usr/lib/openvista/functions if they are not set here. Leaving this file
1682+# completely commented out is recommended unless you need to change one of the
1683+# variables.
1684+#
1685+# WARNING: Use of the $root and $instance variables is recommended over
1686+# hard-coding paths such as /opt/openvista/production. Using variables allows
1687+# a backup of an OpenVista instance (e.g., production) to be restored into an
1688+# empty OpenVista instance with a different name (e.g., dev), since $root and
1689+# $instance are evaluated at run-time. Hard-coding a path to
1690+# /opt/openvista/production will cause the dev instance to look for its
1691+# routines (or worse, its globals!) in /opt/openvista/production.
1692+
1693+# Uncomment and modify these lines to set an alternate installation of GT.M
1694+# that this OpenVista instance should use. By default, this points to the gtm
1695+# symlink in the OpenVista instance's root directory. Updating the symlink is
1696+# the preferred way to change the version of GT.M this instance uses, so you
1697+# should almost always leave this commented out.
1698+#
1699+#gtm_dist="$root/$instance/gtm"
1700+#export gtm_dist
1701+
1702+# Uncomment and modify these lines to override GT.M's routine search path. By
1703+# default, GT.M is configured to look for routines in the routines subdirectory
1704+# in the OpenVista instance's root directory and store compiled objects in the
1705+# objects subdirectory.
1706+#
1707+# A common practice is to divide routines into "released routines" and
1708+# "patches". This can be accomplished by setting $gtmroutines as follows:
1709+#
1710+# gtmroutines="$root/$instance/objects($root/$instance/routines/patches $root/$instance/routines/routines) $root/$instance/gtm"
1711+#
1712+# Any routines in the patches directory will take precedence over the same
1713+# routine in the routines directory.
1714+#
1715+# Another common practice is to split routines into tiers that reflect their
1716+# origin, e.g.,
1717+#
1718+# gtmroutines="$root/$instance/objects($root/$instance/routines/medsphere $root/$instance/routines/vendor $root/$instance/routines/foia) $root/$instance/gtm"
1719+#
1720+# In a development environment, you may want to reference routines outside of
1721+# the routines directory:
1722+#
1723+# gtmroutines="$root/$instance/objects(/home/developer/routines $root/$instance/routines) $root/$instance/gtm"
1724+#
1725+# WARNING: Utilities such as ovbackup will ignore routines outside of the
1726+# routines directory. If you reference routines outside of the routines
1727+# directory, you must back them up yourself. In the development example
1728+# provided above, it is assumed that /home/developer/routines is managed by an
1729+# external revision control system.
1730+#
1731+# NOTE: If you want to reference routines outside of the routines directory,
1732+# but you still want to have them backed up by ovbackup, you should create a
1733+# symlink inside the routines directory that points to the external directory,
1734+# e.g.,
1735+#
1736+# gtmroutines="$root/$instance/objects($root/$instance/routines/instance-specific $root/$instance/routines/shared) $root/$instance/gtm"
1737+#
1738+# where $root/$instance/routines/shared is a symlink to a directory of routines
1739+# that are shared across instances. ovbackup and other utilities follow
1740+# symlinks, so the symlink targets will be backed up, allowing you to do a
1741+# restore with ovrestore and get a functional standalone system.
1742+#
1743+#gtmroutines="$root/$instance/objects($root/$instance/routines) $root/$instance/gtm"
1744+#export gtmroutines
1745+
1746+# Uncomment and modify these lines to set the path where GT.M looks for the
1747+# global directory file. By default, the global directory file is named
1748+# mumps.gld and resides in the globals subdirectory of the OpenVista instance's
1749+# root directory. Updating the default global directory file is the preferred
1750+# way to customize the global directory, so you should almost always leave this
1751+# commented out.
1752+#
1753+# WARNING: Utilities such as ovbackup will ignore alternate global directory
1754+# paths and back up the default mumps.gld file. If you change the path to the
1755+# global directory file here, you must back it up yourself.
1756+#
1757+# WARNING: Utilities such as ovrestore and /etc/init.d/openvista-databases
1758+# expect two database regions, DEFAULT and SCRATCH, and two physical segments
1759+# (database files), globals/default.dat and globals/scratch.dat. Your
1760+# alternate global directory file must have these regions and physical
1761+# segments.
1762+#
1763+# WARNING: Utilities such as the ZCD routine expect paths to physical segments
1764+# in the global directory file to be fully-evaluated, absolute, paths. Using
1765+# variables or relative paths will likely cause ZCD to malfunction, preventing
1766+# users from switching between OpenVista instances (or worse, it may look like
1767+# they have switched, but they are still accessing globals in the original
1768+# instance!)
1769+#
1770+#gtmgbldir="$root/$instance/globals/mumps.gld"
1771+#export gtmgbldir
1772+
1773
1774=== added file 'scripts/usr/share/openvista/journals.conf'
1775--- scripts/usr/share/openvista/journals.conf 1970-01-01 00:00:00 +0000
1776+++ scripts/usr/share/openvista/journals.conf 2009-12-21 19:35:21 +0000
1777@@ -0,0 +1,23 @@
1778+# configuration file for OpenVista journaling
1779+# this file is sourced by bash, so any valid bash syntax is allowed
1780+
1781+# purge_daily: Purge old journals for this instance automatically once per day
1782+#
1783+# If purge_daily is set to "yes" here, the /etc/cron.daily/openvista script
1784+# will call ovpurgejournals on this instance. The default is "yes".
1785+#
1786+# If you want old journals for this instance to be removed on a custom
1787+# schedule, set purge_daily to "no" here and add an entry for this instance in
1788+# /etc/cron.d/openvista.
1789+#
1790+purge_daily=yes
1791+
1792+# num_journals: Number of old journals to keep in the journals directory
1793+#
1794+# After a successful backup, all inactive journals should be safe to delete.
1795+# However, disk space permitting, it is a good idea to keep a few old journal
1796+# files around in case there is a problem with the most recent backup. The
1797+# default is 3.
1798+#
1799+num_journals=3
1800+

Subscribers

People subscribed via source and target branches