#!/bin/sh # # ------------------------------------------------------------------- # X-BONE # # http://www.isi.edu/xbone # USC Information Sciences Institute (USC/ISI) # Marina del Rey, California 90292, USA # Copyright (c) 1998-2005 # # ------------------------------------------------------------------- # # Copyright (c) 1998-2005 by the University of Southern California. # All rights reserved. # # Permission to use, copy, modify, and distribute this software and # its documentation in source and binary forms for non-commercial # purposes and without fee is hereby granted, provided that the above # copyright notice appear in all copies and that both the copyright # notice and this permission notice appear in supporting # documentation, and that any documentation, advertising materials, # and other materials related to such distribution and use acknowledge # that the software was developed by the University of Southern # California, Information Sciences Institute. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # # THE UNIVERSITY OF SOUTHERN CALIFORNIA MAKES NO REPRESENTATIONS ABOUT # THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS # PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Other copyrights might apply to parts of this software and are so # noted when applicable. # # ------------------------------------------------------------------- # # Effort partly sponsored by the Defense Advanced Research Projects # Agency (DARPA) and Air Force Research Laboratory, Air Force Materiel # Command, USAF, under agreement numbers F30602-98-1-0200 (X-Bone) and # F30602-01-2-0529 (DynaBone). The views and conclusions contained # herein are those of the authors and should not be interpreted as # necessarily representing the official policies or endorsements, # either expressed or implied, of the Defense Advanced Research # Projects Agency (DARPA), the Air Force Research Laboratory, or the # U.S. Government. # # This work was partly supported by the NSF STI-XTEND (ANI-0230789) # and NETFS (ANI-0129689) projects. Any opinions, findings, and # conclusions or recommendations expressed in this material are those # of the authors and do not necessarily reflect the views of the # National Science Foundation. # # ------------------------------------------------------------------- # $RCSfile: abone-script,v $ # # $Revision: 1.9 $ # $Author: pingali $ # $Date: 2005/03/31 07:03:42 $ # $State: Exp $ # ---------------------------------------------------------------------------- # # Primary Author: Yu-Shun Wang # Script for deploying ABone (anetd) using XBone Application Deployment # mechanism #- Parameters: XBone Application Deployment processing [OM & RD] ------------- # Parameters to determine the availability of the application: # APP_NAME= ABone # APP_FILE= /usr/local/anetd/bin/ad.bsd44 # APP_VCMD= VNAMES="ALL_NAMES" # Parameters to be replaced by XBone OM & RD: OVL_NAME="OVLNAME" IP_ALL="IPLIST" IP="IP1" OVL="-$OVL_NAME" #- Parameters for Deploying Anetd -------------------------------------------- # Parameters for add/delete users. See pw(8). HOME=/usr/testhome ADD=useradd AARG="-b $HOME -m" DEL=userdel DARG="-r" SHOW=usershow # Signal used to kill anetd KILL="-INT" # Anetd installation path INSTALL=/usr/local # Path & filename of the source tarball ANETDSRC=~yushunwa/projects/anetd/anetd-RELEASE_1_6_9-bsd44.tar.gz ASPEESRC=~yushunwa/projects/anetd/asp-1.5.tar.gz # Anetd Directory ADDIR=$HOME/abocc$OVL/anetd # Anetd Daemon Binary ANETD=$ADDIR/bin/ad.bsd44 # Anetd Client Binary SC=$ADDIR/bin/sc.bsd44 # Master Conf File MCONF=$ADDIR/etc/anetd.conf # Local ACL File LACL=$ADDIR/etc/hosts.allow.local # Local TCL File TCL=$ADDIR/etc/web.allow.local # Anetd command-line arguments ANETD_ARG="-c $MCONF -m abocc$OVL" # Anetd Client (sc) command-line arguements SCARGS="-t 5" # JDK-1.2.2 location JDK122=/usr/local/jdk1.2.2 # JDK-1.1.8 location JDK118=/usr/local/jdk1.1.8 # ABone monitoring STATUS_PATH=/usr/local/www/data/abone/results SCRIPT=query.pl #- Script starts ------------------------------------------------------------- case "$1" in test) $SC $IP QUERY > /dev/null 2>&1 && echo "anetd running" || echo "no anetd" # pw $SHOW anee7$OVL > /dev/null 2>&1 \ # && echo " - anee7$OVL exists" \ # || (pw $ADD anee7$OVL -c "Testing" $AARG && echo " > anee7$OVL") # pw $SHOW anee7$OVL > /dev/null 2>&1 \ # && (pw $DEL anee7$OVL $DARG && echo " > delete anee7$OVL") \ # || echo " - anee6$OVL not exists" # pw usershow anee5$OVL > /dev/null && echo "anee5$OVL exists" \ # || echo "anee5$OVL not exists" # pw usershow anee6$OVL > /dev/null 2>&1 && echo "anee6$OVL exists" \ # || echo "anee6$OVL not exists" # echo "HOME = $HOME" echo "End test" ;; conf) echo ">>> ABone Configuration" if [ ! -d $HOME ]; then mkdir -p $HOME fi chmod 0755 $HOME echo " (1) Create ABone Account for Overlay $OVL_NAME" pw $SHOW abocc$OVL > /dev/null 2>&1 && echo " - abocc$OVL exists" \ || (pw $ADD abocc$OVL -c "Abone administrator" $AARG && \ echo " + abocc$OVL") pw $SHOW anee1$OVL > /dev/null 2>&1 && echo " - anee1$OVL exists" \ || (pw $ADD anee1$OVL -c "Abone EE account #1" $AARG && \ echo " + anee1$OVL") pw $SHOW anee2$OVL > /dev/null 2>&1 && echo " - anee2$OVL exists" \ || (pw $ADD anee2$OVL -c "Abone EE account #2" $AARG && \ echo " + anee2$OVL") pw $SHOW anee3$OVL > /dev/null 2>&1 && echo " - anee3$OVL exists" \ || (pw $ADD anee3$OVL -c "Abone EE account #3" $AARG && \ echo " + anee3$OVL") pw $SHOW anee4$OVL > /dev/null 2>&1 && echo " - anee4$OVL exists" \ || (pw $ADD anee4$OVL -c "Abone EE account #4" $AARG && \ echo " + anee4$OVL") pw $SHOW anee5$OVL > /dev/null 2>&1 && echo " - anee5$OVL exists" \ || (pw $ADD anee5$OVL -c "Abone EE account #5" $AARG && \ echo " + anee5$OVL") pw $SHOW anpub$OVL > /dev/null 2>&1 && echo " - anpub$OVL exists" \ || (pw $ADD anpub$OVL -c "Abone public account" $AARG && \ echo " + anpub$OVL") echo " (2) Fix directory ACLs" chmod og+rx $HOME/abocc$OVL $HOME/anee1$OVL $HOME/anee2$OVL $HOME/anee3$OVL chmod og+rx $HOME/anee4$OVL $HOME/anee5$OVL $HOME/anpub$OVL echo -n " (3) Copy anetd files to ~abocc$OVL: " su abocc$OVL -c 'cp -Rfp /usr/local/anetd ~' && echo "done" echo " (3) Check/Generate keys for root" if [ -f ~root/.anetd/id_publickey ]; then echo " Keys for root available" else echo " Generating keys for root" date -u | /usr/local/anetd/bin/makekey.bsd44 -i root fi echo " (4) Local ACL File: $LACL" if [ -f $LACL ]; then rm -f $LACL fi echo "`more ~root/.anetd/id_publickey` P" > $LACL chmod 644 $LACL chown abocc$OVL $LACL echo " (5) Master Configuration File:" echo " $MCONF" rm -f $MCONF echo "# ABone Master Configuration File for Overlay $OVERLAY" > $MCONF echo "ip_addr $IP_ALL" >> $MCONF if [ -d $JDK122 ]; then echo "jdk1.2.2 $JDK122" >> $MCONF echo "java1.2.2 $JDK122/bin/java" >> $MCONF fi if [ -d $JDK118 ]; then echo "jdk1.1.8 $JDK118" >> $MCONF echo "java1.1.8 $JDK118/bin/java" >> $MCONF fi if [ -f $LACL ]; then echo "local_acl_file $LACL" >> $MCONF fi chmod 644 $MCONF chown abocc$OVL $MCONF echo " (6) TCL File" if [ -d $STATUS_PATH ]; then echo " (7) Status Files" rm -f $STATUS_PATH/$OVL_NAME.nodes touch $STATUS_PATH/$OVL_NAME.nodes for v in $VNAMES; do echo "$v.$OVL_NAME.xbone.net" >> $STATUS_PATH/$OVL_NAME.nodes done chmod 644 $STATUS_PATH/$OVL_NAME.nodes fi echo "<<< conf done" ;; run) echo ">>> Start anetd for $OVL_NAME" if [ -x $ANETD ]; then $SC $IP:3322 QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anpub" \ || (su - anpub$OVL -c "$ANETD $ANETD_ARG -a anpub" && \ echo " + anpub" && sleep 2) $SC -f abocc $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on abocc" \ || (su - abocc$OVL -c "$ANETD $ANETD_ARG -a abocc" && \ echo " + abocc" && sleep 2) $SC -f anee1 $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anee1" \ || (su - anee1$OVL -c "$ANETD $ANETD_ARG -a anee1" && \ echo " + anee1" && sleep 2) $SC -f anee2 $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anee2" \ || (su - anee2$OVL -c "$ANETD $ANETD_ARG -a anee2" && \ echo " + anee2" && sleep 2) $SC -f anee3 $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anee3" \ || (su - anee3$OVL -c "$ANETD $ANETD_ARG -a anee3" && \ echo " + anee3" && sleep 2) $SC -f anee4 $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anee4" \ || (su - anee4$OVL -c "$ANETD $ANETD_ARG -a anee4" && \ echo " + anee4" && sleep 2) $SC -f anee5 $IP QUERY > /dev/null 2>&1 \ && echo " - anetd already running on anee5" \ || (su - anee5$OVL -c "$ANETD $ANETD_ARG -a anee5" && \ echo " + anee5" && sleep 2) echo "<<< Anetd started" echo -n "PID " for ACC in anpub abocc anee1 anee2 anee3 anee4 anee5; do echo -n `$SC $SCARGS -f $ACC $IP QUERY pid | grep '^[0123456789]\+$'` echo -n " " done echo "" if [ -d $STATUS_PATH ]; then cd $STATUS_PATH && \ $STATUS_PATH/$SCRIPT -f $OVL_NAME.nodes -o $OVL_NAME.data chmod 666 $STATUS_PATH/$OVL_NAME.data fi else echo " ! Binary $ANETD not accessable." fi ;; pid) if [ -x $ANETD ]; then for ACC in anpub abocc anee1 anee2 anee3 anee4 anee5; do echo -n `$SC $SCARGS -f $ACC $IP QUERY pid | grep '^[0123456789]\+$'` echo -n " " done echo "" else echo " ! Binary $ANETD not executable." fi ;; kill) echo ">>> Kill Anetd Processes" for ACCT in anee5 anee4 anee3 anee2 anee1 abocc anpub; do echo -n " - $ACCT" RES=`ps -o pid -U $ACCT$OVL | grep '[0123456789]\+'` if [ ! -z $RES ]; then kill $KILL $RES && echo " [killed]" || echo " [failed]" else echo " [not found]" fi done echo "<<< Anetd stopped" ;; old_kill) echo ">>> Stop Anetd Processes" if [ -x $SC ]; then echo -n " Stop Anetd:" for ACCT in anee5 anee4 anee3 anee2 anee1 abocc anpub; do $SC -q -f $ACCT $IP RAISE -SIGKILL force > /dev/null 2>&1 \ && ( echo -n " $ACCT" && sleep 2 ) \ || echo -n " $ACCT-x" done echo "." echo "<<< Anetd Stopped" else echo " ! $SC not executable" fi ;; cleanup) echo ">>> Cleanup ABone Accounts & Directories for Overlay $OVL_NAME" pw $SHOW abocc$OVL > /dev/null 2>&1 \ && (pw $DEL abocc$OVL $DARG && echo " > abocc$OVL deleted") \ || echo " - abocc$OVL not exists" pw $SHOW anee1$OVL > /dev/null 2>&1 \ && (pw $DEL anee1$OVL $DARG && echo " > anee1$OVL deleted") \ || echo " - anee1$OVL not exists" pw $SHOW anee2$OVL > /dev/null 2>&1 \ && (pw $DEL anee2$OVL $DARG && echo " > anee2$OVL deleted") \ || echo " - anee2$OVL not exists" pw $SHOW anee3$OVL > /dev/null 2>&1 \ && (pw $DEL anee3$OVL $DARG && echo " > anee3$OVL deleted") \ || echo " - anee3$OVL not exists" pw $SHOW anee4$OVL > /dev/null 2>&1 \ && (pw $DEL anee4$OVL $DARG && echo " > anee4$OVL deleted") \ || echo " - anee4$OVL not exists" pw $SHOW anee5$OVL > /dev/null 2>&1 \ && (pw $DEL anee5$OVL $DARG && echo " > anee5$OVL deleted") \ || echo " - anee5$OVL not exists" pw $SHOW anpub$OVL > /dev/null 2>&1 \ && (pw $DEL anpub$OVL $DARG && echo " > anpub$OVL deleted") \ || echo " - anpub$OVL not exists" if [ -d $STATUS_PATH ]; then rm -f $STATUS_PATH/$OVL_NAME.nodes rm -f $STATUS_PATH/$OVL_NAME.data fi echo "<<< cleanup done" ;; # Target "install" is not part of the official XBone application deployment # mechanism. This is just an example and for our own convenience. install) echo ">>> Install anetd" cd $INSTALL && \ tar xfz $ANETDSRC && tar xvfz $ASPEESRC echo " - anetd installed under $INSTALL." ;; esac exit 0