#!/bin/bash echo "SETISTART.sh version 03242k3-f" echo "SYNTAX" echo "setistart [start]{end][make]" echo " Where start is the number of the first seti to start" echo " and end is the number of the last seti to start" echo " 'make' is optional: The program will make seti directories" echo " numbered from START to END." echo " " echo "NOTE--This program will act upon your home directory!" echo " " #This sets the start and end params. if [ -z $1 ]; then START=1 else START=$1 fi if [ -z $2 ]; then END=1 else END=$2 fi echo "Start: $START" echo "End: $END" VALID=`expr $END - $START` if [ $VALID -lt 0 ]; then echo "You need to specify an ending value greater than or equal to" echo "the starting value." echo " For example: setistart 1 2 is valid, while" echo " setistart 3 2 is not." echo " NOTE: " echo " setistart -3 1, while valid according to the above rule will" echo " fail the test because -3 - 1 = -4 && -4 < 0." echo " but setistart -1 4 will probably work because 3 > 0." echo " Of course, why would anyone want a seti directory called 'seti-3'?" echo "Exiting with error 2." exit 2 fi # This checks for presence of a third argument. If there is one, the # program will make seti directories and populate them from a setimaster # directory in the user's home directory. #This makes directories case "$3" in #This removes directories very fast, very brutally. purge | PURGE) for i in ` seq $START 1 $END`; do rm -r $HOME/seti$i echo "Removed seti$i...." done ;; make | MAKE | M | m | create | CREATE | Create | Make) #This makes directories. echo "Changing to your home directory, $HOME." cd $HOME if [ -d $HOME/setimaster ]; then for i in `seq $START 1 $END`; do echo "----------------------------------------" echo "Trying to make $HOME/seti$i" echo "----------------------------------------" mkdir ./seti$i cp -Rf ./setimaster/* ./seti$i #Had to use the above kludge. The following rsync #command doesn't work in this script. Maybe #I'll figure out why someday. #rsync -av ./setimaster/ ./seti$1 --progress --delete done else echo "$HOME/setimaster does not exist." echo "You need to create it. I don't do that" echo "because I'm just a bloody script!" echo "Exiting with code 10." exit 10 fi ;; *) # This just starts multiple instances of setiathome. for i in `seq $START 1 $END`; do echo "Starting seti in $i..." cd $HOME/seti$i cpujob ./setiathome & cd $HOME done esac