changeset 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 5cd4aaf85d02
children 8516a3c7ed22
files distribution/pom.xml distribution/tools/setup_remote_storage.sh
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/pom.xml	Tue Sep 11 22:59:49 2012 +0200
+++ b/distribution/pom.xml	Wed Sep 12 12:14:46 2012 +0200
@@ -132,6 +132,11 @@
                     <include>bundles.properties</include>
                   </includes>
                 </resource>
+                <resource>
+                  <directory>tools</directory>
+                  <targetPath>tools</targetPath>
+                  <filtering>true</filtering>
+                </resource>
               </resources>
             </configuration>
           </execution>
@@ -148,6 +153,7 @@
             <configuration>
               <target>
                 <chmod file="${project.build.directory}/bin/*" perm="755" />
+                <chmod file="${project.build.directory}/tools/*" perm="755" />
               </target>
             </configuration>
             <goals>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distribution/tools/setup_remote_storage.sh	Wed Sep 12 12:14:46 2012 +0200
@@ -0,0 +1,35 @@
+#!/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