OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-registry Date: 20-Feb-2007 23:19:24
Branch: HEAD Handle: 2007022022192400
Modified files:
openpkg-registry register.sh
Log:
make --mode=post the default; make --mode and --user optional and
attempt to grab missing configuration from autoregister service; in
automatic mode, do not run interaction stuff unless STDIN is tied to a
terminal; log in UTC
Summary:
Revision Changes Path
1.61 +77 -17 openpkg-registry/register.sh
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-registry/register.sh
============================================================================
$ cvs diff -u -r1.60 -r1.61 register.sh
--- openpkg-registry/register.sh 20 Feb 2007 22:13:12 -0000 1.60
+++ openpkg-registry/register.sh 20 Feb 2007 22:19:24 -0000 1.61
@@ -29,8 +29,8 @@
# program name, version and date
progname="register"
-progvers="1.0.1"
-progdate="22-Oct-2006"
+progvers="1.1.0"
+progdate="20-Feb-2007"
# determine path to OpenPKG instance
PREFIX="@l_prefix@"
@@ -102,7 +102,8 @@
op="automatic"
# standard options
-REGISTRY_MODE=""
+REGISTRY_AUTO="http://openpkg.org/go/autoregister"
+REGISTRY_MODE="post"
REGISTRY_ARGS="http://registry.openpkg.org/register"
REGISTRY_USER=""
REGISTRY_LINK=""
@@ -248,8 +249,8 @@
if [ ".$help" != ".Usage" ]; then
echo "$progname:ERROR: $help" 1>&2
fi
- echo "Usage: $progname -m|--mode=fake|post|wipe [-a|--args=<args>]"
- echo " -u|--user=<user> [-d|--desc=<text>]"
+ echo "Usage: $progname [-u|--user=<user>] [-l|--link=<token>]
[-d|--desc=<text>]"
+ echo " [-m|--mode=fake|post|wipe] [-a|--args=<args>]"
echo " [--plat=<text>] [--orel=<text>] [--uuid=<file>]"
echo " [--conf=<file>] [--prep=<file>] [--tran=<file>]
[--util=<file>] [--data=<tag>[,<tag>...]]"
echo " [-P|--preparation] [-T|--transaction] [-U|--utilization]"
@@ -429,6 +430,34 @@
}
##
+## Automatic registration data retrieval
+##
+autoregdata()
+{
+ if [ ".$REGISTRY_AUTO" != . ]; then
+ O=""
+ if [ $verbose = no ]; then O="$O --silent"; fi
+ response=`$curl \
+ $O -L \
+ --user-agent "$useragent" \
+ --connect-timeout 8 \
+ --max-time 16 \
+ $REGISTRY_AUTO \
+ | awk '
+ BEGIN { registry=0 }
+ /<registry>/ { registry=1 }
+ /<autoregister / { if (registry) { print $0 } }
+ /<\/registry>/ { registry=0 }' \
+ | sed -e 's;^.*<autoregister *;;' -e 's;>[^>]*</autoregister>.*$;;' \
+ -e 's;\([^=]*\)="\([^"]*\)" *;\1="\2"\\
+;g' \
+ | awk -F= '/=/ { print "REGISTRY_"toupper($1)"="$2"" }'`
+ if [ $verbose = yes ]; then echo "autoregdata from $REGISTRY_AUTO";
echo "$response"; fi
+ eval "$response"
+ fi
+}
+
+##
## Primary operation Convenience
##
convenience()
@@ -441,6 +470,24 @@
fi
preparation | transaction | utilization
+
+ readutil || error "problem reading util"
+ if [ ".$REGISTRY_DONE" = .yes ]; then
+ echo "#`TZ= date '+%Y-%m-%d %H:%M:%S'` UTC" | tee "$REGISTRY_CONF"
|| return
+ (
+ echo "REGISTRY_USER=\"$REGISTRY_USER\""
+ echo "REGISTRY_LINK=\"$REGISTRY_LINK\""
+ echo "REGISTRY_DESC=\"$REGISTRY_DESC\""
+ echo "REGISTRY_PLAT=\"$REGISTRY_PLAT\""
+ echo "REGISTRY_OREL=\"$REGISTRY_OREL\""
+ echo "REGISTRY_UUID=\"$REGISTRY_UUID\""
+ echo "REGISTRY_PREP=\"$REGISTRY_PREP\""
+ echo "REGISTRY_MODE=\"$REGISTRY_MODE\""
+ echo "REGISTRY_ARGS=\"$REGISTRY_ARGS\""
+ echo "REGISTRY_TRAN=\"$REGISTRY_TRAN\""
+ echo "REGISTRY_UTIL=\"$REGISTRY_UTIL\""
+ ) | tee -a "$REGISTRY_CONF"
+ fi
}
##
@@ -473,7 +520,7 @@
echo ""
echo "==== Step 1/3: Preparation ===="
echo "Attempting to write to the configuration file \"$REGISTRY_CONF\""
- echo "#`TZ= date '+%Y-%m-%d %H:%M:%S'`" | tee -a "$REGISTRY_CONF"
2>/dev/null \
+ echo "#`TZ= date '+%Y-%m-%d %H:%M:%S'` UTC" | tee -a "$REGISTRY_CONF"
2>/dev/null \
|| error "Configuration file not writable. Get more permissions and
try again"
read -p "[REGISTRY_USER=\"$REGISTRY_USER\"] username? "; [
".$REPLY" != . ] && REGISTRY_USER="$REPLY"
@@ -584,16 +631,10 @@
}
##
-## automatically pick interaction or convenience
+## check whether important configuration data is missing
##
-automatic()
+checkmissing()
{
- if [ ".$REGISTRY_MODE" = .wipe ]; then
- convenience
- interaction
- return
- fi
-
missing=""
[ ".$REGISTRY_USER" = . ] && missing="$missing REGISTRY_USER"
[ ".$REGISTRY_DESC" = . ] && missing="$missing REGISTRY_DESC"
@@ -605,10 +646,29 @@
[ ".$REGISTRY_ARGS" = . ] && missing="$missing REGISTRY_ARGS"
[ ".$REGISTRY_TRAN" = . ] && missing="$missing REGISTRY_TRAN"
[ ".$REGISTRY_UTIL" = . ] && missing="$missing REGISTRY_UTIL"
+}
+##
+## automatically pick interaction or convenience
+##
+automatic()
+{
+ if [ ".$REGISTRY_MODE" = .wipe ]; then
+ convenience
+ interaction
+ return
+ fi
+
+ checkmissing
+ if [ ".$missing" != . ]; then
+ autoregdata
+ fi
+
+ checkmissing
if [ ".$missing" = . ]; then
convenience
else
+ tty -s || return
echo "missing $missing"
interaction
fi
@@ -632,8 +692,8 @@
=head1 SYNOPSIS
-B<register> -m|--mode=fake|post|wipe [I<-a|--args=<args>>]
- -u|--user=<user|token> [-u|--link=<token>] [I<-d|--desc=<text>>]
+B<register> [-u|--user=<user|token>] [-l|--link=<token>]
[I<-d|--desc=<text>>]
+ [-m|--mode=fake|post|wipe] [I<-a|--args=<args>>]
[I<--plat=<text>>] [I<--orel=<text>>] [I<--uuid=<file>>]
[I<--conf=<file>>] [I<--prep=<file>>] [I<--tran=<file>>]
[I<--util=<file>>] [--data=<tag>[,<tag>...]]
@@ -790,7 +850,7 @@
If the token is also enabled for "assoc" the registered instance is
immediately associated
to the user with no need for the user to visit the web interface.
This information in submitted via the "registry_user" attribute of the XML
request.
-Has no default and is a manadatory setting.
+Retrieves default online from http://openpkg.org/go/autoregister and is a
manadatory setting.
=item B<-l>, B<--link> I<token>
@@ .
______________________________________________________________________
OpenPKG http://openpkg.org
CVS Repository Commit List [email protected]