From 8843e71b86755d98613eb9f760b10efba209a67a Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Sat, 10 Apr 2010 18:10:33 +0300 Subject: [PATCH] added admin scripts --- scripts/admin/clusterctl | 94 ++++++++++++++++++++++++++++++++++++++++ scripts/admin/config | 18 ++++++++ 2 files changed, 112 insertions(+) create mode 100755 scripts/admin/clusterctl create mode 100644 scripts/admin/config diff --git a/scripts/admin/clusterctl b/scripts/admin/clusterctl new file mode 100755 index 0000000..a82b6aa --- /dev/null +++ b/scripts/admin/clusterctl @@ -0,0 +1,94 @@ +#!/bin/bash + +# +# cluster administration tool +# +# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro +# + +# source configuration file +source ./config + +verbose=0 +add_keyfile="" +delete_expr="" +remoteuser="all" +remotehost="all" +vzcontainer="all" +list=0 + +list_keys() +{ + this_user=$1 + this_host=$2 + echo "$this_user@$this_host keys" + ssh -l root $this_host "eval cat ~$this_user/.ssh/authorized_keys" | sed 's/ [^ =]*=\+//g' | sed 's/^/ * /g' + echo +} + +usage() +{ + echo "Usage:" >&2 + echo -e "\t$0 -h" >&2 + echo -e "\t$0 [-v] [-r remotehost] [-c vzcontainer] [-u user] -a key" >&2 + echo -e "\t$0 [-v] [-r remotehost] [-c vzcontainer] [-u user] -d string" >&2 + echo -e "\t$0 [-v] [-r remotehost] [-c vzcontainer] [-u user] -l" >&2 +} + +while getopts "hvr:c:u:a:d:l" option; do + case $option in + a) + add_keyfile="$OPTARG" + ;; + d) + delete_expr="$OPTARG" + ;; + l) + list=1 + ;; + h) + usage + exit 0 + ;; + v) + verbose=1 + ;; + \?) + usage + exit 1 + ;; + esac +done + +if ! test -z $add_keyfile; then + echo "add $add_keyfile" +fi + +if ! test -z $delete_expr; then + echo "delete $delete_expr" +fi + +if test $list -eq 1; then + if test "$remotehost" == "all"; then + echo "yeah" + for host in ${remote_hosts[*]}; do + if test "$remoteuser" == "all"; then + for user in ${remote_users[*]}; do + list_keys $user $host + done + continue + fi + list_keys $remoteuser $host + done + else + if test "$user" == "all"; then + for user in ${remote_users[*]}; do + list_keys $user $remotehost + done + else + list_keys $remoteuser $remotehost + fi + fi +fi + +exit 0 diff --git a/scripts/admin/config b/scripts/admin/config new file mode 100644 index 0000000..3fd7625 --- /dev/null +++ b/scripts/admin/config @@ -0,0 +1,18 @@ +#!/bin/bash + +# +# config file for cluster administration (used by configctl) +# +# 2010, Razvan Deaconescu, razvan.deaconescu@cs.pub.ro +# + +remote_hosts=(141.85.224.201 141.85.224.202 141.85.224.203\ + 141.85.224.204 141.85.224.205 141.85.224.207\ + 141.85.224.208 141.85.224.210) + +remote_users=("p2p" "root") + +# IMPORTANT: update root variable; points to script root folder +root_dir=~/projects/p2p-next/cs-p2p-next/scripts/admin + +keys_dir=$root_dir/keys -- 2.20.1