summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2012-10-13 02:14:40 +0200
committerChristian Pointner <equinox@spreadspace.org>2012-10-13 02:14:40 +0200
commit49d50474e0a69ad45c78c2b4b3dff8ca91ef4e72 (patch)
tree25af8d3d4a713aec5d684fdf12135d6c364cef55 /src
parentadded deployment scripts (not finished) (diff)
improved deployment scripts
Diffstat (limited to 'src')
-rwxr-xr-xsrc/deploy.sh9
-rwxr-xr-xsrc/flufigut-client.sh43
2 files changed, 39 insertions, 13 deletions
diff --git a/src/deploy.sh b/src/deploy.sh
index 1c7c2f8..0ed5f17 100755
--- a/src/deploy.sh
+++ b/src/deploy.sh
@@ -37,17 +37,18 @@
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 -n "copying files to $machine ... "
+ echo "copying files to $machine ... "
tar -czf "$machine.tar.gz" "$machine"/*
- scp -i "$SSH_KEY" -F "$SSH_CONFIG" "$machine.tar.gz" "$machine":/tmp
- ssh -i "$SSH_KEY" -F "$SSH_CONFIG" "$machine" install
- echo "done."
+ 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 "$machine.tar.gz"
+ rm "$machine.tar.gz"
fi
done
diff --git a/src/flufigut-client.sh b/src/flufigut-client.sh
index 8ac58ce..91591fd 100755
--- a/src/flufigut-client.sh
+++ b/src/flufigut-client.sh
@@ -28,29 +28,51 @@
# along with flufigut. If not, see <http://www.gnu.org/licenses/>.
#
-# INSTALLATION
-# - copy script to /usr/local/bin
-# - add ssh key to authorized keys of flumotion user with options:
-# command="/usr/local/bin/flufigut-client.sh",no-X11-forwarding,no-agent-forwarding,no-port-forwarding
-# -
-
NAME="flumotion"
LOGFILE="/var/log/flumotion/service.log"
DAEMON="/usr/sbin/$NAME"
DAEMON_ARGS="-d 3 -l $LOGFILE"
CONF_DIR="/etc/flumotion"
+
+if [ "install" = "$1" ]; then
+ UID=`/usr/bin/id -u`
+ if [ $UID -ne 0 ]; then
+ echo "ERROR: this script must run as root for install installation."
+ exit 1
+ fi
+ cp $0 /usr/local/bin
+ getent passwd flufigut > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -n "copy&paste public key and press enter: "
+ read pubkey
+ if [ -z "$pubkey" ]; then
+ echo "ERROR: no keyfile given"
+ exit 1
+ fi
+ adduser flufigut --disabled-password --home /var/lib/flufigut --gecos "flufigut management" --shell "/bin/sh"
+ mkdir -p /var/lib/flufigut/.ssh
+ echo 'command="/usr/local/bin/flufigut-client.sh",no-X11-forwarding,no-agent-forwarding,no-port-forwarding '$pubkey > /var/lib/flufigut/.ssh/authorized_keys
+ chown -R flufigut:flufigut /var/lib/flufigut/.ssh
+ chmod 600 /var/lib/flufigut/.ssh/authorized_keys
+ echo "flufigut ALL = (flumotion) NOPASSWD: $DAEMON" >> /etc/sudoers
+ fi
+ echo "successfully installed flufigut client."
+
+ exit 0
+fi
+
start_instance() {
type="$1"
name="$2"
- $DAEMON $DAEMON_ARGS start $type $name
+ sudo -u flumotion $DAEMON $DAEMON_ARGS start $type $name
return "$?"
}
stop_instance() {
type="$1"
name="$2"
- $DAEMON $DAEMON_ARGS stop $type $name
+ sudo -u flumotion $DAEMON $DAEMON_ARGS stop $type $name
return "$?"
}
@@ -76,8 +98,11 @@ case "$command" in
echo -n "starting ..."
echo "ok."
;;
+ scp)
+ $SSH_ORIGINAL_COMMAND
+ ;;
*)
- echo "Unknown command"
+ echo "Unknown command: '$command'"
exit 1
;;
esac