cleanup for the specialaccounts nodemanager plugin:
[myplc.git] / bashrc
1 # -*-sh-*-
2 # $Id$
3 # $URL$
4 # this file defines a few convenience bash shorthands for managing myplc nodes
5 # it is installed in /usr/share/myplc/aliases
6 # you might wish to use it in your own bash startup files (.profile/.bashrc)
7
8 ssh_options="-o BatchMode=yes -o StrictHostKeyChecking=no"
9
10 function node_key () {
11     key="$1"; shift
12     hostname="$1"; shift
13     echo Running "$@" on root@"$hostname"
14     ssh $ssh_options -i "$key" "root@$hostname" "$@"
15 }
16
17 function nodes_key () {
18     key="$1"; shift
19     filename="$1"; shift
20     for hostname in $(grep -v '#' $filename); do
21         node_boot "$hostname" "$key" "$@"
22     done
23 }
24
25 function node_dbg () {
26     [[ -z "$@" ]] && { echo "Usage: $0 hostname [command]" ; return 1; }
27     node_key /etc/planetlab/debug_ssh_key.rsa "$@"
28 }
29 function nodes_dbg () {
30     [[ -z "$@" ]] && { echo "Usage: $0 hosts_file [command]" ; return 1; }
31     node_keys /etc/planetlab/debug_ssh_key.rsa "$@"
32 }
33 function clear_known_hosts () {
34     for hostname in "$@"; do    
35         sed -i "/$hostname/d" ~/.ssh/known_hosts
36     done
37 }