view distribution/tools/setup_remote_storage.sh @ 605:eea20cd2356b

Provide simple shell script for remote storage user setup. This is a convenience script. Example usage (on host where storage is supposed to run, and storage binding should be to IP 192.168.0.1): $ mvn clean package $ ./distribution/target/tools/setup_remote_storage.sh 192.168.0.1 \ ./distribution/target This creates an admin user, authenticates as such, creates a user for the thermostat db with username "t" and password "t" and starts storage which binds to 192.168.0.1. After that the agent can be started on remote host as follows: $ ./distribution/target/bin/thermostat agent -d mongodb://192.168.0.1:27518 \ --username t --password t Quick and dirty, but is faster than doing this manually :) Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003158.html
author Severin Gehwolf <sgehwolf@redhat.com>
date Wed, 12 Sep 2012 12:14:46 +0200
parents
children
line wrap: on
line source

#!/bin/bash
#set -x

if [ $# -ne 2 ]; then
  echo 1>&2 "usage: $0 <ip-of-storage-host> <path-to-thermostat-home>" 
  exit 1
fi

STORAGE_IP=$1

THERMOSTAT_HOME="$2"
THERMOSTAT_USER="t"
THERMOSTAT_PWD="t"
MONGO_ADMIN_USER="admin"
MONGO_ADMIN_PWD="admin"

$THERMOSTAT_HOME/bin/thermostat storage --start
cat > /tmp/thermostat_setup.txt <<EOF
db.addUser("$MONGO_ADMIN_USER", "$MONGO_ADMIN_PWD");
db.auth("$MONGO_ADMIN_USER", "$MONGO_ADMIN_PWD");
db = db.getMongo().getDB( "thermostat" );
db.addUser("$THERMOSTAT_USER", "$THERMOSTAT_PWD");
EOF

mongo localhost:27518/admin /tmp/thermostat_setup.txt
$THERMOSTAT_HOME/bin/thermostat storage --stop

cat > $THERMOSTAT_HOME/storage/db.properties <<EOF
PORT=27518
BIND=$STORAGE_IP
PROTOCOL=mongodb
EOF
$THERMOSTAT_HOME/bin/thermostat storage --start

exit 0