From 831c88bd689ea3c5e6c0350ee9e389573377e743 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 13 Oct 2012 13:57:26 +0200 Subject: local manage script works --- src/deploy.sh | 58 --------------------------- src/manage.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 58 deletions(-) delete mode 100755 src/deploy.sh create mode 100755 src/manage.sh diff --git a/src/deploy.sh b/src/deploy.sh deleted file mode 100755 index 23400b2..0000000 --- a/src/deploy.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# -# flufigut -# -# flufigut, the flumotion configuration utility, is a simple tool -# that generates flumotion configuration files using pyhton jinja2 -# template engine and simplejson. flufigut generates planet.xml -# and worker.xml files from configuration templates and an easy to -# understand representation of the flow structure written in json. -# -# -# Copyright (C) 2012 Christian Pointner -# Michael Gebetsroither -# -# This file is part of flufigut. -# -# flufigut is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# any later version. -# -# flufigut is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with flufigut. If not, see . -# - -# -# Initialization: -# - generate ssh key: -# $ ssh-keygen -f id_rsa -# - configure ssh.config -# - copy flufigut-client.sh to every machine and install it -# $ sudo ./flufigut-client.sh install -# - -OUTPUT_DIR="output/" -SSH_KEY="../id_rsa" -SSH_CONFIG="../ssh.config" -SSH_USER="flufigut" - -set -e - -cd $OUTPUT_DIR -for machine in *; do - if [ -d "$machine" ]; then - echo "copying files to $machine ... " - tar -czf "$machine.tar.gz" "$machine"/* - scp -i "$SSH_KEY" -F "$SSH_CONFIG" "$machine.tar.gz" $SSH_USER@"$machine":/tmp - ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" install "/tmp/$machine.tar.gz" - rm "$machine.tar.gz" - fi -done - -exit 0 diff --git a/src/manage.sh b/src/manage.sh new file mode 100755 index 0000000..9123cb8 --- /dev/null +++ b/src/manage.sh @@ -0,0 +1,123 @@ +#!/bin/sh +# +# flufigut +# +# flufigut, the flumotion configuration utility, is a simple tool +# that generates flumotion configuration files using pyhton jinja2 +# template engine and simplejson. flufigut generates planet.xml +# and worker.xml files from configuration templates and an easy to +# understand representation of the flow structure written in json. +# +# +# Copyright (C) 2012 Christian Pointner +# Michael Gebetsroither +# +# This file is part of flufigut. +# +# flufigut is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# any later version. +# +# flufigut is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with flufigut. If not, see . +# + +# +# Initialization: +# - generate ssh key: +# $ ssh-keygen -f id_rsa +# - configure ssh.config +# - copy flufigut-client.sh to every machine and install it +# $ sudo ./flufigut-client.sh install +# + +OUTPUT_DIR="output" +SSH_KEY="id_rsa" +SSH_CONFIG="ssh.config" +SSH_USER="flufigut" + +set -e + +deploy_all() { + for machine in "$OUTPUT_DIR"/*; do + if [ -d "$machine" ]; then + machine=`basename $machine` + echo "copying files to $machine ... " + tar -czf "$OUTPUT_DIR/$machine.tar.gz" "$OUTPUT_DIR/$machine"/* + scp -i "$SSH_KEY" -F "$SSH_CONFIG" "$OUTPUT_DIR/$machine.tar.gz" $SSH_USER@"$machine":/tmp + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" install "/tmp/$machine.tar.gz" + rm "$OUTPUT_DIR/$machine.tar.gz" + fi + done +} + +start_all() { + for machine in "$OUTPUT_DIR"/*; do + if [ -d "$machine" ] && [ -d "$machine/managers" ]; then + machine=`basename $machine` + echo " $machine (manager, worker)" + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start + break + fi + done + for machine in "$OUTPUT_DIR"/*; do + if [ -d "$machine" ] && [ ! -d "$machine/managers" ]; then + machine=`basename $machine` + echo " $machine (worker)" + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start + break + fi + done +} + +stop_all() { + for machine in "$OUTPUT_DIR"/*; do + if [ -d "$machine" ] && [ ! -d "$machine/managers" ]; then + machine=`basename $machine` + echo " $machine (worker)" + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop + break + fi + done + for machine in "$OUTPUT_DIR"/*; do + if [ -d "$machine" ] && [ -d "$machine/managers" ]; then + machine=`basename $machine` + echo " $machine (manager, worker)" + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop + break + fi + done +} + +case "$1" in + deploy) + echo "Deploying configuration to all machines ..." + deploy_all + ;; + start) + echo "Start manager and worker on all machines ..." + start_all + ;; + stop) + echo "Stop manager and worker on all machines ..." + stop_all + ;; + restart) + echo "Restart manager and worker on all machines ..." + stop_all + sleep 1 + start_all + ;; + *) + echo "Usage $0 (deploy|start|stop|restart)" + exit 1 + ;; +esac + +exit 0 -- cgit v1.2.3