Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Dave Whitten
freem
Commits
52e2a1bd
Commit
52e2a1bd
authored
Mar 24, 2020
by
John P. Willis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port namespace script to pure Bourne shell
parent
242f63c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
128 deletions
+126
-128
.gitignore
.gitignore
+1
-0
Makefile.am
Makefile.am
+2
-2
bin/namespace
bin/namespace
+123
-126
No files found.
.gitignore
View file @
52e2a1bd
...
...
@@ -34,3 +34,4 @@ src/gverify
src/libfreem.la
src/ri
src/stamp-h1
src/config.h.in~
Makefile.am
View file @
52e2a1bd
...
...
@@ -5,6 +5,6 @@ EXTRA_DIST = src/*.h doc/freem.1 doc/*.8
install-exec-hook
:
mkdir
-p
/var/local/freem
namespace add
--namespace
=
SYSTEM
-
-path
=
/var/local/freem
namespace add
--namespace
=
USER
--path
=
/var/local/freem
namespace add SYSTEM
-
p
/var/local/freem
namespace add
USER
-p
/var/local/freem
cp
mlib/
*
.m /var/local/freem/SYSTEM/routines
bin/namespace
View file @
52e2a1bd
#!/bin/
ba
sh
#!/bin/sh
function
usage
{
if
[
$#
-lt
1
]
then
echo
echo
echo
"namespace"
echo
echo
" Adds, removes, lists
, or displays the configuration of
FreeM namespaces,"
echo
" Adds, removes,
or
lists FreeM namespaces,"
echo
" allowing the user to specify all relevant configuration options."
echo
echo
" Syntax:"
echo
" namespace [add | remove
| show] [-n <namespace> | --namespace=<namespace>]
[OPTIONS...] "
echo
" namespace [add | remove
] <namespace-name>
[OPTIONS...] "
echo
" namespace list"
echo
echo
" Arguments:"
echo
echo
" -h, --help"
echo
" Displays this help text."
echo
echo
" -n <namespace>, --namespace=<namespace>"
echo
" Sets the namespace being acted upon."
echo
echo
" -m [inactive | read | write], --jnlmode=[inactive | read | write]"
echo
" -m [inactive | read | write]"
echo
" Sets the journaling mode for the namespace; 'inactive' by default."
echo
echo
" -f
<journal-file>, --jnlfile=
<journal-file>"
echo
" -f <journal-file>"
echo
" Sets the file that FreeM will use for journaling;"
echo
" '/tmp/freem.journal' by default."
echo
echo
" -l
<locktab-file>, --locktab=
<locktab-file>"
echo
" -l <locktab-file>"
echo
" Sets the file that FreeM will use for maintaining the LOCK table;"
echo
" '/tmp/freem.locktab' by default."
echo
echo
" -z
<zalloctab-file>, --zalloctab=
<zalloctab-file>"
echo
" -z <zalloctab-file>"
echo
" Sets the file that FreeM will use for maintaining the ZALLOCATE table;"
echo
" '/tmp/freem.zalloctab' by default."
echo
echo
" -c
<hardcopy-file>, --hardcopy=
<hardcopy-file>"
echo
" -c <hardcopy-file>"
echo
" Sets the file FreeM will use when invoked in hardcopy mode;"
echo
" '/tmp/freem.hardcopy' by default."
echo
echo
" -r
<rga-file>, --rgafile=
<rga-file>"
echo
" -r <rga-file>"
echo
" Sets the file where FreeM will log routine and global accesses;"
echo
" '/tmp/freem.rgafile' by default."
echo
echo
" -p <freem-path>, --path=<freem-path>"
echo
" Informs this program of the location where FreeM is installed."
echo
" Supply -p if the
\$
freem_base environment variable is not set."
echo
echo
echo
exit
1
}
[[
$#
< 1
]]
&&
usage
fi
NSNAME
=
""
JNLMODE
=
"inactive"
...
...
@@ -63,188 +51,197 @@ ZALLOCTAB="/tmp/freem.zalloctab"
HARDCOPY
=
"/tmp/freem.hardcopy"
RGAFILE
=
"/tmp/freem.rgafile"
if
[
[
!
-z
$freem_base
]
]
if
[
!
-z
$freem_base
]
then
DSTPATH
=
"
$
{
freem_base
}
"
DSTPATH
=
"
$freem_base
"
else
DSTPATH
=
""
DSTPATH
=
"
/var/local/freem
"
fi
ACTION
=
$1
shift
if
[
[
$
{
ACTION
}
!=
"add"
]]
&&
[[
${
ACTION
}
!=
"delete"
]]
&&
[[
${
ACTION
}
!=
"show"
]]
&&
[[
${
ACTION
}
!=
"list"
]
]
if
[
$
#
-ge
2
]
then
usage
NSNAME
=
$1
shift
fi
if
[[
${
ACTION
}
==
"delete"
]]
||
[[
${
ACTION
}
==
"show"
]]
if
[
$ACTION
!=
"add"
-a
{
ACTION
}
!=
"delete"
-a
$ACTION
!=
"show"
-a
$ACTION
!=
"list"
]
then
echo
echo
echo
"namespace"
echo
echo
" Adds, removes, or lists FreeM namespaces,"
echo
" allowing the user to specify all relevant configuration options."
echo
echo
" Syntax:"
echo
" namespace [add | remove] <namespace-name> [OPTIONS...] "
echo
" namespace list"
echo
echo
" Arguments:"
echo
echo
echo
" -m [inactive | read | write]"
echo
" Sets the journaling mode for the namespace; 'inactive' by default."
echo
echo
" -f <journal-file>"
echo
" Sets the file that FreeM will use for journaling;"
echo
" '/tmp/freem.journal' by default."
echo
echo
" -l <locktab-file>"
echo
" Sets the file that FreeM will use for maintaining the LOCK table;"
echo
" '/tmp/freem.locktab' by default."
echo
echo
" -z <zalloctab-file>"
echo
" Sets the file that FreeM will use for maintaining the ZALLOCATE table;"
echo
" '/tmp/freem.zalloctab' by default."
echo
echo
" -c <hardcopy-file>"
echo
" Sets the file FreeM will use when invoked in hardcopy mode;"
echo
" '/tmp/freem.hardcopy' by default."
echo
echo
" -r <rga-file>"
echo
" Sets the file where FreeM will log routine and global accesses;"
echo
" '/tmp/freem.rgafile' by default."
echo
fi
if
[
$ACTION
=
"delete"
-o
$ACTION
=
"show"
]
then
echo
"'delete' and 'show' have not yet been implemented."
exit
2
fi
TEMP
=
$(
getopt
-o
hn:m:f:l:z:c:r:p:
--long
help
,namespace:,jnlmode:,jnlfile:,locktab:,zalloctab:,hardcopy:,rgafile:,path:
-n
'namespace'
--
"
$@
"
)
eval set
--
"
$TEMP
"
while
true
while
getopts
m:f:k:z:c:r:p: OPT
do
case
"
$1
"
in
-h
|
--help
)
usage
;;
-n
|
--namespace
)
NSNAME
=
$2
shift
2
;;
-m
|
--jnlmode
)
if
[[
$2
!=
"inactive"
]]
&&
[[
$2
!=
"read"
]]
&&
[[
$2
!=
"write"
]]
case
$OPT
in
m
)
if
[
$OPTARG
!=
"inactive"
-a
$OPTARG
!=
"read"
-a
$OPTARG
!=
"write"
]
then
echo
"Journal mode must be one of 'inactive', 'read', or 'write'."
exit
3
fi
JNLMODE
=
$2
shift
2
JNLMODE
=
$OPTARG
;;
-f
|
--jnlfile
)
JNLFILE
=
$2
shift
2
f
)
JNLFILE
=
$OPTARG
;;
-l
|
--locktab
)
LOCKTAB
=
$2
shift
2
l
)
LOCKTAB
=
$OPTARG
;;
-z
|
--zalloctab
)
ZALLOCTAB
=
$2
shift
2
z
)
ZALLOCTAB
=
$OPTARG
;;
-c
|
--hardcopy
)
HARDCOPY
=
$2
shift
2
c
)
HARDCOPY
=
$OPTARG
;;
-r
|
--rgafile
)
RGAFILE
=
$2
shift
2
r
)
RGAFILE
=
$OPTARG
;;
-p
|
--path
)
DSTPATH
=
$2
shift
2
p
)
DSTPATH
=
$OPTARG
;;
--
)
shift
break
;;
esac
done
if
[
[
$
{
NSNAME
}
=
=
""
]]
&&
[[
$
{
ACTION
}
!=
"list"
]
]
if
[
$NSNAME
=
""
-a
$ACTION
!=
"list"
]
then
echo
"Must specify namespace name
using -n or --name
"
echo
"Must specify namespace name"
exit
4
else
INISEC
=
"[
${
NSNAME
}
]"
fi
if
[[
${
DSTPATH
}
==
""
]]
then
read
-p
"Where is FreeM installed? "
DSTPATH
INISEC
=
"[
$NSNAME
]"
fi
if
[
[
!
-d
$
{
DSTPATH
}
]
]
if
[
!
-d
$DSTPATH
]
then
echo
"
$
{
DSTPATH
}
does not appear to be a directory."
echo
"
$DSTPATH
does not appear to be a directory."
exit
5
fi
CONFFILE
=
""
if
[
[
-f
/etc/freem.conf
]
]
&&
[[
!
-f
~/.freemrc
]]
if
[
-f
/etc/freem.conf
]
then
CONFFILE
=
/etc/freem.conf
fi
if
[
[
!
-f
/etc/freem.conf
]]
&&
[[
-f
~/.freemrc
]
]
if
[
$CONFFILE
=
""
]
then
CONFFILE
=
~/.freemrc
CONFFILE
=
/etc/freem.conf
fi
if
[[
${
CONFFILE
}
==
""
]]
then
CONFFILE
=
~/.freemrc
fi
if
[[
${
ACTION
}
==
"add"
]]
if
[
$ACTION
=
"add"
]
then
echo
"Adding namespace
${
NSNAME
}
..."
if
[[
$(
cat
${
CONFFILE
}
|
grep
${
INISEC
}
)
==
${
INISEC
}
]]
then
echo
"Namespace '
${
NSNAME
}
' already exists."
exit
6
fi
echo
"Adding namespace
$NSNAME
..."
PCTROUT
=
"
$
{
DSTPATH
}
/SYSTEM/routines"
PCTGLOB
=
"
$
{
DSTPATH
}
/SYSTEM/globals"
PCTROUT
=
"
$DSTPATH
/SYSTEM/routines"
PCTGLOB
=
"
$DSTPATH
/SYSTEM/globals"
if
[
[
$
{
NSNAME
}
=
=
"SYSTEM"
]
]
if
[
$NSNAME
=
"SYSTEM"
]
then
USRROUT
=
"
$
{
PCTROUT
}
"
USRGLOB
=
"
$
{
PCTGLOB
}
"
USRROUT
=
"
$PCTROUT
"
USRGLOB
=
"
$PCTGLOB
"
else
USRROUT
=
"
$
{
DSTPATH
}
/
$
{
NSNAME
}
/routines"
USRGLOB
=
"
$
{
DSTPATH
}
/
$
{
NSNAME
}
/globals"
USRROUT
=
"
$DSTPATH
/
$NSNAME
/routines"
USRGLOB
=
"
$DSTPATH
/
$NSNAME
/globals"
fi
mkdir
-p
$
{
PCTROUT
}
$
{
PCTGLOB
}
$
{
USRROUT
}
$
{
USRGLOB
}
chmod
777
$
{
PCTROUT
}
$
{
PCTGLOB
}
$
{
USRROUT
}
$
{
USRGLOB
}
chmod
777
$
{
DSTPATH
}
/
$
{
NSNAME
}
mkdir
-p
$PCTROUT
$PCTGLOB
$USRROUT
$USRGLOB
chmod
777
$PCTROUT
$PCTGLOB
$USRROUT
$USRGLOB
chmod
777
$DSTPATH
/
$NSNAME
cat
<<
EOF
>>
$
{
CONFFILE
}
cat
<<
EOF
>>
$CONFFILE
$
{
INISEC
}
percent_routines_path=
$
{
PCTROUT
}
percent_globals_path=
$
{
PCTGLOB
}
routines_path=
$
{
USRROUT
}
globals_path=
$
{
USRGLOB
}
locktable_file=
$
{
LOCKTAB
}
zalloctab_file=
$
{
ZALLOCTAB
}
journal_file=
$
{
JNLFILE
}
journal_mode=
$
{
JNLMODE
}
rga_protocol_file=
$
{
RGAFILE
}
hardcopy_file=
$
{
HARDCOPY
}
$INISEC
percent_routines_path=
$PCTROUT
percent_globals_path=
$PCTGLOB
routines_path=
$USRROUT
globals_path=
$USRGLOB
locktable_file=
$LOCKTAB
zalloctab_file=
$ZALLOCTAB
journal_file=
$JNLFILE
journal_mode=
$JNLMODE
rga_protocol_file=
$RGAFILE
hardcopy_file=
$HARDCOPY
EOF
echo
echo
echo
"Namespace
$
{
NSNAME
}
has been created."
echo
"Namespace
$NSNAME
has been created."
echo
"Access it with the following command:"
echo
echo
"
\$
${
DSTPATH
}
/bin/
freem --namespace=
$
{
NSNAME
}
"
echo
"
\$
freem --namespace=
$NSNAME
"
echo
echo
"Or if FreeM is already running:"
echo
echo
" SYSTEM> ZNAMESPACE
\"
$
{
NSNAME
}
\"
"
echo
" SYSTEM> ZNAMESPACE
\"
$NSNAME
\"
"
echo
fi
if
[
[
${
ACTION
}
=
=
"list"
]
]
if
[
${
ACTION
}
=
"list"
]
then
echo
echo
"Namespaces Defined in
$
{
CONFFILE
}
"
echo
"Namespaces Defined in
$CONFFILE
"
echo
cat
$
{
CONFFILE
}
|
grep
"^
\[
.*
\]
"
|
tr
-d
"[ ]"
cat
$CONFFILE
|
grep
"^
\[
.*
\]
"
|
tr
-d
"[ ]"
echo
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment