#!/bin/sh

# File Name: planetnode_sample.sh
# Description: This script contains all configuration related information
#----------------------------------------------------------------------------
# Author: JonhHan Park and Rex Chen
#
#
#
#----------------------------------------------------------------------------

# ----------configuration------------------#
#general
USER_HOME="/home/rex"
TIMEOUT="120"  

#slice information
SLICE_NAME="uci_dandelion"
REMOTE_HOME="/home/${SLICE_NAME}"

#file information
SRC_DIR="${USER_HOME}/src"
DST_DIR="${REMOTE_HOME}/dst"
HOST_LIST="planetlab_uci_node.txt"

# clear environments in each node
CLEAR_CMD="rm -rf ${REMOTE_HOME}/*"
# ----------end of configuration------------#


# //If you don't run ssh-agent in the background or 
# //ssh-agent script in auto user login (e.g. .bash_profile, .cshrc)
# //you will need to uncomment the 4 lines of code below
# ssh-agent -s > _ssh-agent.tmp
# source ./_ssh-agent.tmp
# ssh-add 
# rm _ssh-agent.tmp

# Be sure the machine has pssh and pscp packages available
# One site to download from is: lhttp://www.theether.org/pssh
# Be sure to set the relative path of pssh and pscp to your environment 
# or use absolute path name 

pssh -l ${SLICE_NAME} -o output -e error -t ${TIMEOUT} -h ${HOST_LIST} $CLEAR_CMD 

# copy files in /home/rex/src/ to /home/rex/dst/ remote nodes in planetlab_node.txt 
pscp -r -t ${TIMEOUT} -h ${HOST_LIST} -l ${SLICE_NAME} ${SRC_DIR} ${DST_DIR} 

