#!/bin/bash CVSREPOSITORY='ord' PROJECT_NAME='ordnance' VERSIONS="" MUST_B_ROOT=0 SERVER="www.SiliconTao.com" BRANCH="gnu" # To run this program do this as root from the command line # bash GetProject.bsh # replace GetProject.bsh with the full name of this file echo "This program is intened for people that do not have the $PROJECT_NAME software yet," echo "and want an easy way to download and install it. If you already have the new version" echo "from the CVS server you need only cd to the directory where the CVS directory is" echo "and run the \"cvs update\" command." echo "Do not run this program if you have the newest version already." echo -n "Do you want to run this program (Y/N) [N] " read USER_INPUT RUN_THIS=`echo $USER_INPUT |grep -i Y` if [ "$RUN_THIS" = "" ]; then echo "You chose not to continue, exiting now." exit fi if [ $MUST_B_ROOT -eq 1 ]; then USER_ID=`id -u` if [ ! $USER_ID -eq 0 ]; then echo "You must be root to install this software." exit fi fi mkdir $CVSREPOSITORY cd $CVSREPOSITORY PREVIOUSLOGINS="" DEFAULTNAME="anonymous" if [ -f ~/.cvspass ]; then PREVIOUSLOGINS=`cat ~/.cvspass|grep -i "$SERVER:"|grep -i /cvsroot/$BRANCH/$CVSREPOSITORY|cut -d: -f3|cut -d@ -f1` fi if [ ! "$PREVIOUSLOGINS" = "" ]; then echo "You have loged in before using these names" for ITEM in $PREVIOUSLOGINS; do if [ "$DEFAULTNAME" = "" ]; then DEFAULTNAME=$ITEM fi echo " $ITEM" done fi echo "Press enter to login as $DEFAULTNAME"; echo -n "Enter your login name: " read LOGIN_NAME if [ "$LOGIN_NAME" = "" ]; then LOGIN_NAME=$DEFAULTNAME fi if [ "$LOGIN_NAME" = "anonymous" ]; then PREVIOUSLOGINS="" if [ -f ~/.cvspass ]; then PREVIOUSLOGINS=`cat ~/.cvspass|grep -i "$SERVER:"|grep -i /cvsroot/$BRANCH/$CVSREPOSITORY|grep $LOGIN_NAME|cut -d: -f3|cut -d@ -f1` fi if [ "$PREVIOUSLOGINS" = "" ]; then echo "Press enter as the password" fi else PREVIOUSLOGINS="" if [ -f ~/.cvspass ]; then PREVIOUSLOGINS=`cat ~/.cvspass|grep -i "$SERVER:"|grep -i /cvsroot/$BRANCH/$CVSREPOSITORY|grep $LOGIN_NAME|cut -d: -f3|cut -d@ -f1` fi if [ "$PREVIOUSLOGINS" = "" ]; then echo "Please enter your password" fi fi if [ "$PREVIOUSLOGINS" = "" ]; then cvs -d:pserver:$LOGIN_NAME@$SERVER:/cvsroot/$BRANCH/$CVSREPOSITORY login fi DEFAULTVERSION="" if [ ! "$VERSIONS" = "" ]; then echo "" echo "More then one version is avalible. Your options are: " for ITEM in $VERSIONS; do if [ "$DEFAULTVERSION" = "" ]; then DEFAULTVERSION=$ITEM fi echo " $ITEM" done echo -n "Enter your choice [$DEFAULTVERSION]: " read INPUT for ITEM in $VERSIONS; do if [ $ITEM = $INPUT ]; then DEFAULTVERSION=$ITEM fi done fi if [ "$DEFAULTVERSION" = "" ]; then echo "Installing HEAD branch of $PROJECT_NAME from $BRANCH/$CVSREPOSITORY" cvs -d:pserver:$LOGIN_NAME@$SERVER:/cvsroot/$BRANCH/$CVSREPOSITORY co $PROJECT_NAME else echo "Installing $DEFAULTVERSION branch of $PROJECT_NAME from $BRANCH/$CVSREPOSITORY" cvs -d:pserver:$LOGIN_NAME@$SERVER:/cvsroot/$BRANCH/$CVSREPOSITORY co -r $DEFAULTVERSION $PROJECT_NAME fi if [ -d $PROJECT_NAME ]; then cd $PROJECT_NAME if [ -f ./Install ] && [ -x ./Install ]; then echo "" echo "" echo -n "Found an install script. Should I run it? [Y]/N: " read RUNINSTALL if [ "$RUNINSTALL" = "Y" ]||[ "$RUNINSTALL" = "y" ]||[ "$RUNINSTALL" = "" ]; then ./Install fi fi else echo "Failed for some reason." fi