#!/bin/rc
# dialreg DIALSTRING REGNAME
# dials a registry and mounts it and writes information to relevant /tmp/grid
areas
# set variables from args or prompt user if missing
switch($1){
case ''
echo Enter an IP address for this registry
REGIP=`{read}
echo Enter registry service port
REGPORT=`{read}
echo choose a name for this registry
REGNAME=`{read}
REGADDR=tcp!$REGIP!$REGPORT
echo use dialreg tcp!IPADDRESS!PORT REGNAME to skip these prompts
case *
REGADDR=$1
switch($2){
case ''
REGNAME=`{echo $ADDRESS |awk -F! '{print (NF>1) ? $2:$1}'}
case *
REGNAME=$2
}
}
echo attaching registry
if (recover $REGADDR $REGNAME) ATTACH=success
if (! ~ $ATTACH success) {
echo registry mount failed
exit
}
g/local mntgen /g/r/$REGNAME
g/local mount /srv/$REGNAME /g/r/$REGNAME/r
echo adding registry info to /tmp/grid
echo `{date} dialreg $REGADDR $REGNAME >>/tmp/grid/log/log
#echo $REGNAME >/tmp/grid/registries/$REGADDR
echo $REGADDR > /tmp/grid/registries/$REGNAME
echo $REGNAME $REGADDR >> /tmp/grid/info/reglist
echo harvesting information
cat /g/r/$REGNAME/r/index > /tmp/grid/info/reg$REGNAME
cat /tmp/grid/info/reg$REGNAME >>/tmp/grid/info/regbucket
echo registry mounted at /g/r/$REGNAME/r
echo registry contents:
cat /tmp/grid/info/reg$REGNAME
# this script part of the /g/toolkit licensed under the MIT license but be cool
# keep the code open, share your scripts and config files