convenience functions defined in /usr/share/myplc/bashrc
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 17 Nov 2008 14:20:35 +0000 (14:20 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 17 Nov 2008 14:20:35 +0000 (14:20 +0000)
bashrc [new file with mode: 0644]
build-native.sh

diff --git a/bashrc b/bashrc
new file mode 100644 (file)
index 0000000..41b27c6
--- /dev/null
+++ b/bashrc
@@ -0,0 +1,46 @@
+# -*-sh-*-
+# this file defines a few convenience bash shorthands for managing myplc nodes
+# it is installed in /usr/share/myplc/aliases
+# you might wish to use it in your own bash startup files (.profile/.bashrc)
+
+ssh_options="-o BatchMode=yes -o StrictHostKeyChecking=no"
+
+function node_key () {
+    key="$1"; shift
+    hostname="$1"; shift
+    echo Running "$@" on root@"$hostname"
+    ssh $ssh_options -i "$key" "root@$hostname" "$@"
+}
+
+function nodes_key () {
+    key="$1"; shift
+    filename="$1"; shift
+    for hostname in $(grep -v '#' $filename); do
+       node_boot "$hostname" "$key" "$@"
+    done
+}
+
+function node_dbg () {
+    [[ -z "$@" ]] && { echo "Usage: $0 hostname [command]" ; return 1; }
+    node_key /etc/planetlab/debug_ssh_key.rsa "$@"
+}
+function node_boot () {
+    [[ -z "$@" ]] && { echo "Usage: $0 hostname [command]" ; return 1; }
+    node_key /etc/planetlab/root_ssh_key.rsa "$@"
+}
+
+function nodes_dbg () {
+    [[ -z "$@" ]] && { echo "Usage: $0 hosts_file [command]" ; return 1; }
+    node_keys /etc/planetlab/debug_ssh_key.rsa "$@"
+}
+function nodes_boot () {
+    [[ -z "$@" ]] && { echo "Usage: $0 hosts_file [command]" ; return 1; }
+    nodes_key /etc/planetlab/root_ssh_key.rsa "$@"
+}
+
+function clear_keys () {
+    for hostname in "$@"; do   
+        sed -i "/$hostname/d" ~/.ssh/known_hosts
+    done
+}
+       
index a57232e..8ac4f25 100755 (executable)
@@ -24,6 +24,8 @@ rm -rf ${RPM_BUILD_ROOT}
 mkdir -p ${RPM_BUILD_ROOT}
 echo "* myplc-native: installing plc_config.py in /usr/share/myplc"
 install -D -m 755 plc_config.py ${RPM_BUILD_ROOT}/usr/share/myplc/plc_config.py
+install -D -m 644 bashrc ${RPM_BUILD_ROOT}/usr/share/myplc/bashrc
+echo "* myplc-native: installing scripts in /usr/bin"
 install -D -m 755 plc-config ${RPM_BUILD_ROOT}/usr/bin/plc-config
 install -D -m 755 plc-config-tty ${RPM_BUILD_ROOT}/usr/bin/plc-config-tty
 install -D -m 755 db-config ${RPM_BUILD_ROOT}/usr/bin/db-config
@@ -35,6 +37,7 @@ install -D -m 755 clean-empty-dirs.py ${RPM_BUILD_ROOT}/usr/bin/clean-empty-dirs
 install -D -m 755 mtail.py ${RPM_BUILD_ROOT}/usr/bin/mtail.py
 install -D -m 755 check-ssl-peering.py ${RPM_BUILD_ROOT}/usr/bin/check-ssl-peering.py
 # Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
+echo "* myplc-native: installing scripts in /etc/support-scripts"
 mkdir -p ${RPM_BUILD_ROOT}/etc/support-scripts
 cp support-scripts/* ${RPM_BUILD_ROOT}/etc/support-scripts
 # copy initscripts to etc/plc_sliceinitscripts