From 873b075485c0114674d1c37a42b6a6180423f8ae Mon Sep 17 00:00:00 2001 From: Gene Hsu Date: Wed, 8 May 2019 19:44:25 +0000 Subject: [PATCH 1/3] Make shebang line use /usr/bin/env --- bin/couchdb/generate_design_docs.js | 2 +- bin/couchdb/new_couch_user.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/couchdb/generate_design_docs.js b/bin/couchdb/generate_design_docs.js index 9689aa39..f596ff14 100755 --- a/bin/couchdb/generate_design_docs.js +++ b/bin/couchdb/generate_design_docs.js @@ -1,4 +1,4 @@ -#!/usr/bin/node +#!/usr/bin/env node // Scan the current directory for Javascript files that contain // CouchDB design documents. Such files will have the following diff --git a/bin/couchdb/new_couch_user.js b/bin/couchdb/new_couch_user.js index a788b1c2..7de01f8e 100755 --- a/bin/couchdb/new_couch_user.js +++ b/bin/couchdb/new_couch_user.js @@ -1,4 +1,4 @@ -#!/usr/bin/node +#!/usr/bin/env node var async = require('async'); var commander = require('commander'); From 6680b7bcf1d2a1290a978a5345ddbf4105bcb4e4 Mon Sep 17 00:00:00 2001 From: Gene Hsu Date: Wed, 8 May 2019 19:45:07 +0000 Subject: [PATCH 2/3] Use the correct console.error method --- test/node-insert.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/node-insert.js b/test/node-insert.js index 0d2f1bc3..229ee663 100644 --- a/test/node-insert.js +++ b/test/node-insert.js @@ -130,7 +130,7 @@ describe('node-insert', function() { if (inserted) { tutils.delete_node(node_id, auth, function(err) { if (err) { - console.err('Problem deleting inserted node: ', err); + console.error('Problem deleting inserted node: ', err); } }); } @@ -327,7 +327,7 @@ describe('node-insert', function() { // invalid, but if we DID insert anyway (perhaps due to a bug), // then we clean up after ourselves by deleting. tutils.delete_node(node_id, auth, function(err) { - console.err('Problem deleting inserted node: ', err); + console.error('Problem deleting inserted node: ', err); }); } From 76fa619a104cee8149173e33b982e313084462e2 Mon Sep 17 00:00:00 2001 From: Gene Hsu Date: Tue, 14 May 2019 18:12:20 +0000 Subject: [PATCH 3/3] Fix new_namespace script to make a correct namespace directory --- bin/new_namespace | 57 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/bin/new_namespace b/bin/new_namespace index 74234c8d..5e42dba1 100755 --- a/bin/new_namespace +++ b/bin/new_namespace @@ -1,27 +1,58 @@ #!/bin/bash -# Determine the path to this script -ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")" -DIR=`dirname $ABSPATH` +function usage { + echo "$0 " >&2 + echo >&2 + echo "This script creates an OSDF namespace in a directory. The directory" >&2 + echo "should be the working namespace directory of the OSDF server." >&2 + echo >&2 + echo "e.g. /usr/src/app/working/namespaces" >&2 + echo >&2 + echo "The namespace_name parameter must not already exist in the namespace directory." >&2 +} + +DIR=$1 +NS_NAME=$2 -NS_NAME=$1 +if [ -z $DIR ]; then + echo "A directory parameter must be specified." >&2 + usage + exit 1 +fi if [ -z $NS_NAME ]; then - echo "$0 " >&2 - exit 1; + echo "A namespace name parameter must be specified." >&2 + usage + exit 1 +fi + +if [ ! "${DIR##*/}" = "namespaces" ]; then + echo "The directory parameter must end in \`namespaces\`." >&2 + echo + usage + exit 1 +fi + +if [ ! -e $DIR ]; then + echo "Namespace directory <<$DIR>> must exist." >&2 + echo + usage + exit 2; fi -if [ -d "$DIR/namespaces/$NS_NAME" ]; then - echo "It appears that this namespace already exists." >&2 +if [ -e "$DIR/$NS_NAME" ]; then + echo "File with name <<$NS_NAME>> already exists within the namespace directory." >&2 + echo + usage exit 2; fi -mkdir "$DIR/namespaces/$NS_NAME" && \ -mkdir "$DIR/namespaces/$NS_NAME/aux" && \ -mkdir "$DIR/namespaces/$NS_NAME/schemas" && \ -mkdir "$DIR/namespaces/$NS_NAME/vocabs" +mkdir "$DIR/$NS_NAME" && \ +mkdir "$DIR/$NS_NAME/aux" && \ +mkdir "$DIR/$NS_NAME/schemas" && \ +mkdir "$DIR/$NS_NAME/acls" -INFO_JSON="$DIR/namespaces/$NS_NAME/info.json" +INFO_JSON="$DIR/$NS_NAME/info.json" cat > $INFO_JSON <