Register
It is currently Mon Nov 24, 2014 2:04 pm

my tlm-project seed-server script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 11 posts ] 
Author Message
 PostPosted: Mon Dec 12, 2005 12:12 pm   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
http://www.bashscripts.org/downloads/Sc ... eed.tar.gz
It works fine but there is a messy bit I would like to change:
There is a section in the script that tries to work out if they have a few programs or not.
Is there anyway I could use the if command to determine if they have a certain command?
Thanks, Rob.


Top
 Profile WWW  
 PostPosted: Fri Dec 16, 2005 9:10 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
if [[ -e `which <command>` ]]
then
echo "they have it"
else
echo "they don't have it"
fi


Top
 Profile  
 PostPosted: Fri Dec 16, 2005 10:03 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
thnks jbsnake, I got the following code off crouse which works just as well:
Code:
which command &>/dev/null
if [ $? != "0" ];
then
echo  -e "command is not installed";
read -p "press enter to exit" var;
exit;
echo ""
fi


Top
 Profile WWW  
 PostPosted: Sun Dec 18, 2005 7:45 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
it is now complete and working, here is the code:
Code:
#!/bin/bash
###########################################
#This script was written by rob newland   #
#and is free (as in speech) for all uses. #
#it may be modified or have anything done #
#to it as long as this notice remains.    #
# Contact: robnewland@gmail.com           #
# Or : Find me on USALUG.org :D under     #
#the username crudball.                   #
###########################################
checkforroot ()
{
clear
echo "Robs tlm-project.org seed-server install script"
echo ""
echo "This script needs to be run as root."
echo "Now checking for root permissions"
sleep 1
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo ""
echo "**************** ERROR !! **************"
echo "You must be logged in as root to run this script"
echo "Please log in as root and re-run this script."
echo "**************** ERROR !! **************"
exit
fi
echo "You are running as root.. good .. moving along now ;) "
sleep 2
}
checkforroot
echo you need 1.Bittorrent installed 2.cron 3.rsync to run a seed server.
read -p "press enter to start" enter
echo ""
echo checking for bittorrent
which btlaunchmanycurses.py &>/dev/null
if [ $? != "0" ];
then
echo -e "bittorrent -- NOT INSTALLED";
read -p "hit return to continue" var
exit;
   echo ""
fi
echo bittorrent is installed
echo ""
echo checking for cron
if [[ -d /etc/cron.hourly ]]
then
echo "cron is installed"
else
echo "You do not have cron. Installation will now quit"; sleep 3; exit 0
fi
echo ""
echo checking for rsync...
which rsync &>/dev/null
if [ $? != "0" ];
then
echo -e "rsync -- NOT INSTALLED";
read -p "hit return to continue" var
exit;
   echo ""
fi
echo rsync is installed.
echo
echo making directories.
mkdir /home/$USER/data
mkdir /home/$USER/torrents
read -p "how many torrents would you like to seed? - type 5, 10, 15 or 20 : " [b]torrents[/b]
cp $torrents /etc/cron.hourly/torrents
chmod 777 /etc/cron.hourly/torrents
cp torrentserver /sbin/torrentserver
chmod 777 /sbin/torrentserver
read -p "press enter to run the server or type exit to quit" comm
$comm
cd /etc/cron.hourly/
./torrents
torrentserver

The variable torrents which is in bold, refers to the rsync files - named 5, 10, 15 and 20 which get the approprate amount of torrents - download it from
http://www.bashscripts.org/downloads/Sc ... eed.tar.gz to see what I mean.


Top
 Profile WWW  
 PostPosted: Thu Apr 06, 2006 9:41 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Ok I have updated it - the installer now has a menu which gives you the options to install, check dependencies or install them if they are missing.
install
Code:
#!/bin/bash
###########################################
#This script was written by rob newland   #
#and is free (as in speech) for all uses. #
#it may be modified or have anything done #
#to it as long as this notice remains.    #
# Contact: robnewland@gmail.com           #
# Or : Find me on USALUG.org :D under     #
#the username crudball.                   #
###########################################
function inst ()
{
install2
}
function checkdeps ()
{
echo checking for bittorrent
which launchmany-curses.py &>/dev/null
if [ $? != "0" ];
then
echo -e "bittorrent is either not installed or the required scripts" ;
echo "are not installed. Run instdeps from the menu. "
read -p "hit return to continue" var
else
   echo "Bittorrent is installed" ;
fi
echo ""
echo checking for cron
if [[ -d /etc/cron.hourly ]]
then
echo "cron is installed" ;
else
echo "You do not have cron." ;
fi
echo ""
echo checking for rsync...
which rsync &>/dev/null
if [ $? != "0" ];
then
echo -e "rsync is not installed. Run instdeps from the menu." ;
read -p "hit return to continue" var ;
else
   echo "Rsync is installed" ;
fi
}
function instdeps ()
{
echo checking for bittorrent
which launchmany-curses.py &>/dev/null
if [ $? != "0" ];
then
echo -e "bittorrent -- NOT INSTALLED";
cd /home/$USER ;
echo "Downloading bittorrent" ;
sleep 1 ;
wget http://download.bittorrent.com/dl/BitTorrent-4.4.0.tar.gz ;
tar -zxvf BitTorrent-4.4.0.tar.gz ;
cd BitTorrent-4.4.0 ;
echo "
#!/bin/bash
cd /home/$USER/BitTorrent-4.4.0 && ./launchmany-curses.py --torrent_dir /home/$USER/torrents --save_in /home/$USER/data --max_upload_rate 200
"  >> /usr/bin/launchmany-curses.py ;
chmod 777 /usr/bin/launchmany-curses.py ;
   echo ""
fi
echo bittorrent is installed
echo ""
echo checking for cron
if [[ -d /etc/cron.hourly ]]
then
echo "cron is installed"
else
echo "You do not have crond. Please find a way to install it. "
fi
echo ""
echo checking for rsync...
which rsync &>/dev/null
if [ $? != "0" ];
then
echo "rsync -- NOT INSTALLED" ;
wget http://samba.anu.edu.au/ftp/rsync/rsync-2.6.7.tar.gz
tar -zxvf rsync-2.6.7.tar.gz
cd rsync*
./configure && make & make install
read -p "hit return to continue" var
   echo ""
fi
echo rsync is installed.
}
function menu ()
{
clear
echo "Robs Seed script. Menu"
echo "Type inst to install."
echo "Type checkdeps to check dependencies"
echo "Type instdeps to install dependencies"
read -p ": " option
$option
}
checkforroot ()
{
clear
echo "Robs tlm-project.org seed-server install script"
echo ""
echo "This script needs to be run as root."
echo "Now checking for root permissions"
sleep 1
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo ""
echo "**************** ERROR !! **************"
echo "You must be logged in as root to run this script"
echo "Please log in as root and re-run this script."
echo "**************** ERROR !! **************"
exit
fi
echo "You are running as root.. good .. moving along now "
sleep 2
}
checkforroot
function install2 ()
{
echo you need 1.Bittorrent installed 2.cron 3.rsync to run a seed server.
read -p "press enter to start" enter
echo ""
echo checking for bittorrent
which launchmany-curses.py &>/dev/null
if [ $? != "0" ];
then
echo -e "bittorrent -- NOT INSTALLED";
read -p "hit return to continue" var
exit;
   echo ""
fi
echo bittorrent is installed
echo ""
echo checking for cron
if [[ -d /etc/cron.hourly ]]
then
echo "cron is installed"
else
echo "You do not have cron. Installation will now quit"; sleep 3; exit 0
fi
echo ""
echo checking for rsync...
which rsync &>/dev/null
if [ $? != "0" ];
then
echo -e "rsync -- NOT INSTALLED";
read -p "hit return to continue" var
exit;
   echo ""
fi
echo rsync is installed.
echo
echo making directories.
mkdir /home/$USER/data
mkdir /home/$USER/torrents
read -p "how many torrents would you like to seed? - type 5, 10, 15 or 20 : " torrents
cp $torrents /etc/cron.hourly/torrents
chmod 777 /etc/cron.hourly/torrents
cp torrentserver /usr/bin/torrentserver
chmod 777 /usr/bin/torrentserver
read -p "press enter to run the server or type exit to quit" comm
$comm
cd /etc/cron.hourly/
./torrents
torrentserver
}
menu
exit

The other scripts are the same as before. If you run this script you can see that the menu is kinda rubbish so if anyone can give me some tips onto how to make a good one like I have seen in some of the scripts here it would be appreciated.


Top
 Profile WWW  
 PostPosted: Thu Apr 06, 2006 11:43 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
I modified the code quite a bit..... added the menu, etc .....

Code:
#!/bin/bash
###########################################
#This script was written by rob newland   #
#and is free (as in speech) for all uses. #
#it may be modified or have anything done #
#to it as long as this notice remains.    #
# Contact: robnewland@gmail.com           #
# Or : Find me on USALUG.org :D under     #
#the username crudball.                   #
###########################################

############# FUNCTIONS #############


# echo "Robs tlm-project.org seed-server install script"
# Script modified by Dave Crouse 04-09-2006

checkforroot ()
{
# Proceeds silently if running as root.
ROOT_UID=0
   if [ "$UID" -ne "$ROOT_UID" ]
     then
      echo "********ERROR********"
      echo "You must be logged in as root to run this script"
      echo "Please log in as root and re-run this script."
      echo "Aborting installation."
      echo "********ERROR********"
      exit
   fi
}




function checkdeps ()
{
checkforroot
echo "Checking for bittorrent"
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
     then
      echo -e "ERROR: bittorrent is either not installed or the required scripts are not installed." ;
      echo "";echo "Please choose menu option #2 Install Dependencies" ; echo ""
      read -p "Hit Enter to continue" var
   else
      echo "Bittorrent is installed" ;
   fi

echo ""
echo "Checking for cron"
   if [[ -d /etc/cron.hourly ]]
    then
      echo "cron is installed" ;
    else
      echo "You do not have cron." ;
   fi

echo ""
echo "checking for rsync"
which rsync &>/dev/null
   if [ $? != "0" ];
     then
      echo -e "rsync is not installed. Run instdeps from the menu." ;
      read -p "hit return to continue" var ;
   else
      echo "rsync is installed" ;
   fi
}




function instdeps ()
{
checkforroot
echo checking for bittorrent
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
     then
      echo -e "bittorrent -- NOT INSTALLED";
      cd /home/$USER ;
      echo "Downloading bittorrent" ;
      sleep 1 ;
      wget http://download.bittorrent.com/dl/BitTorrent-4.4.0.tar.gz ;
      tar -zxvf BitTorrent-4.4.0.tar.gz ;
      cd BitTorrent-4.4.0 ;
      echo "#!/bin/bash"  >> /usr/bin/launchmany-curses.py ;
      echo "cd /home/$USER/BitTorrent-4.4.0 && ./launchmany-curses.py --torrent_dir /home/$USER/torrents --save_in /home/$USER/data --max_upload_rate 200"  >> /usr/bin/launchmany-curses.py ;
      chmod 777 /usr/bin/launchmany-curses.py ;
         echo ""
   fi
echo "Bittorrent is installed"
echo ""

echo checking for cron
   if [[ -d /etc/cron.hourly ]]
     then
      echo "cron is installed"
     else
      echo "You do not have crond. Please find a way to install it. "
   fi

echo ""
echo checking for rsync...
which rsync &>/dev/null
   if [ $? != "0" ];
     then
      echo "rsync -- NOT INSTALLED" ;
      wget http://samba.anu.edu.au/ftp/rsync/rsync-2.6.7.tar.gz
      tar -zxvf rsync-2.6.7.tar.gz
      cd rsync*
      /configure && make & make install
      read -p "hit return to continue" var
      echo ""
   fi

echo "rsync is installed."
}



function installandcheck ()
{
checkforroot
echo "You need the following installed to run a seed server."
echo "1. bittorrent"
echo "2. cron"
echo "3. rsync "
echo ""
read -p "Press ENTER to start" enter
echo ""
echo "Checking for bittorrent"
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
     then
      echo -e "bittorrent -- NOT INSTALLED";
      read -p "hit return to continue" var
      exit;
   fi
echo bittorrent is installed
echo ""

echo checking for cron
   if [[ -d /etc/cron.hourly ]]
     then
      echo "cron is installed"
     else
      echo "You do not have cron. Installation will now quit"; sleep 3; exit 0
   fi
echo ""

echo checking for rsync...
which rsync &>/dev/null
   if [ $? != "0" ];
     then
      echo -e "rsync -- NOT INSTALLED";
      read -p "Hit Enter to continue" var
      exit;
   fi
echo "rsync is installed."
echo ""

echo "Making directories."
mkdir /home/$USER/data
mkdir /home/$USER/torrents
read -p "How many torrents would you like to seed? - CHOOSE 5, 10, 15 or 20 : " torrents
cp $torrents /etc/cron.hourly/torrents
chmod 777 /etc/cron.hourly/torrents
cp torrentserver /usr/bin/torrentserver
chmod 777 /usr/bin/torrentserver
read -p "Press ENTER to run the server or type exit to quit" comm
$comm
cd /etc/cron.hourly/
./torrents
torrentserver
}


Main_Menu ()
{
mainmenu="\t1)\tCheck for installed programs\n\t2)\tInstall Dependencies\n\t3)\tSetup and run torrent server\n\t0)\tExit"
clear
echo "        ---------- Seed Server Installation Program -----------";
echo "";
echo -e "$mainmenu"
echo "";
read -p "Please choose one of the options above : " option ;

while true
do
   case $option in
      1)   checkdeps;
         ;;
      2)   instdeps;
         ;;
      3)   installandcheck;
         ;;
      0)   option="";
         exit;
         ;;
      *)   echo "That choice was invalid!!";
         ;;
   esac
clear
   echo "        ---------- Seed Server Installation Program -----------";
   echo "";
   echo -e "$mainmenu"
   echo "";   
   read -p "Please choose one of the options above : " option ;
done

}


#Program run starts here
Main_Menu
exit


Top
 Profile WWW  
 PostPosted: Fri Apr 07, 2006 8:54 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Thanks crouse :) :) :)
Btw I added a
Code:
sleep 5

at the end of the check dependencies section because otherwise you cannot see the results without scrolling back up.
I also added a little thankyou in the bit at the top :D


Top
 Profile WWW  
 PostPosted: Fri Apr 07, 2006 10:16 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
i'd have to say... the best improvements were the indentations :wink:


Top
 Profile  
 PostPosted: Fri Apr 07, 2006 10:24 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
:lol: :lol: :lol: Figured you'd notice that :D


Top
 Profile WWW  
 PostPosted: Sun Apr 09, 2006 8:41 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
New version - but all I added to this one was a short intro kinda thing using some of the stuff from jbsnakes rat project (note: some of it).
It's a long script now so it may take a bit of reading...
run the script to see what the intro is...
Oh and before you say anything crouse - I am not advertising another forum, just putting their site in their as they are who it is made for.
Oh and if you want to use it, this script alone will not suffice - please download the script from http://www.bashscripts.org/downloads/Sc ... eed.tar.gz
Code:
#!/bin/bash
###########################################
#This script was written by rob newland   #
#and is free (as in speech) for all uses. #
#it may be modified or have anything done #
#to it as long as this notice remains.    #
# Contact: robnewland@gmail.com           #
# Or : Find me on USALUG.org :D under     #
#the username crudball.                   #
#Also a thanks goes out to Dave Crouse    #
#who is also known as crouse on usalug.org#
#and bashscripts.org for helping with some#
#code.                                    #
###########################################

############# FUNCTIONS #############
     delay1='sleep .08'
   wipescreen='echo -ne \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'
-nointro ()
{
Main_Menu
}
checkforroot ()
{
# Proceeds silently if running as root.
ROOT_UID=0
   if [ "$UID" -ne "$ROOT_UID" ]
     then
      echo "********ERROR********"
      echo "You must be logged in as root to run this script"
      echo "Please log in as root and re-run this script."
      echo "Aborting installation."
      echo "********ERROR********"
      exit
   fi
}

function checkdeps ()
{
checkforroot
echo "Checking for bittorrent"
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
      then
      echo -e "ERROR: bittorrent is either not installed or the required scripts are not installed." ;
      echo "";echo "Please choose menu option #2 Install Dependencies" ; echo ""
      read -p "Hit Enter to continue" var
   else
      echo "Bittorrent is installed" ;
   fi

echo ""
echo "Checking for cron"
   if [[ -d /etc/cron.hourly ]]
    then
      echo "cron is installed" ;
    else
      echo "You do not have cron." ;
   fi

echo ""
echo "checking for rsync"
which rsync &>/dev/null
    if [ $? != "0" ];
      then
      echo -e "rsync is not installed. Run instdeps from the menu." ;
      read -p "hit return to continue" var ;
   else
      echo "rsync is installed" ;
   fi
sleep 5
}

function instdeps ()
{
checkforroot
echo checking for bittorrent
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
      then
      echo -e "bittorrent -- NOT INSTALLED";
      cd /home/$USER ;
      echo "Downloading bittorrent" ;
      sleep 1 ;
      wget http://download.bittorrent.com/dl/BitTorrent-4.4.0.tar.gz ;
      tar -zxvf BitTorrent-4.4.0.tar.gz ;
      cd BitTorrent-4.4.0 ;
      echo "#!/bin/bash"  >> /usr/bin/launchmany-curses.py ;
      echo "cd /home/$USER/BitTorrent-4.4.0 && ./launchmany-curses.py --torrent_dir /home/$USER/torrents --save_in /home/$USER/data --max_upload_rate 200"  >> /usr/bin/launchmany-curses.py ;
      chmod 777 /usr/bin/launchmany-curses.py ;
         echo ""
   fi
echo "Bittorrent is installed"
echo ""

echo checking for cron
   if [[ -d /etc/cron.hourly ]]
     then
      echo "cron is installed"
     else
      echo "You do not have crond. Please find a way to install it. "
   fi

echo ""
echo checking for rsync...
which rsync &>/dev/null
   if [ $? != "0" ];
     then
      echo "rsync -- NOT INSTALLED" ;
      wget http://samba.anu.edu.au/ftp/rsync/rsync-2.6.7.tar.gz
      tar -zxvf rsync-2.6.7.tar.gz
      cd rsync*
      /configure && make & make install
      read -p "hit return to continue" var
      echo ""
   fi

echo "rsync is installed."
}

function installandcheck ()
{
checkforroot
echo "You need the following installed to run a seed server."
echo "1. bittorrent"
echo "2. cron"
echo "3. rsync "
echo ""
read -p "Press ENTER to start" enter
echo ""
echo "Checking for bittorrent"
which launchmany-curses.py &>/dev/null
   if [ $? != "0" ];
      then
      echo -e "bittorrent -- NOT INSTALLED";
      read -p "hit return to continue" var
      exit;
   fi
echo bittorrent is installed
echo ""

echo checking for cron
   if [[ -d /etc/cron.hourly ]]
     then
      echo "cron is installed"
     else
      echo "You do not have cron. Installation will now quit"; sleep 3; exit 0
   fi
echo ""

echo checking for rsync...
which rsync &>/dev/null
   if [ $? != "0" ];
      then
      echo -e "rsync -- NOT INSTALLED";
      read -p "Hit Enter to continue" var
      exit;
   fi
echo "rsync is installed."
echo ""

echo "Making directories."
mkdir /home/$USER/data
mkdir /home/$USER/torrents
read -p "How many torrents would you like to seed? - CHOOSE 5, 10, 15 or 20 : " torrents
cp $torrents /etc/cron.hourly/torrents
chmod 777 /etc/cron.hourly/torrents
cp torrentserver /usr/bin/torrentserver
chmod 777 /usr/bin/torrentserver
read -p "Press ENTER to run the server or type exit to quit" comm
$comm
cd /etc/cron.hourly/
./torrents
torrentserver
}

Main_Menu ()
{
mainmenu="\t1)\tCheck for installed programs\n\t2)\tInstall Dependencies\n\t3)\tSetup and run torrent server\n\t0)\tExit"
clear
echo "        ---------- Seed Server Installation Program -----------";
echo "";
echo -e "$mainmenu"
echo "";
read -p "Please choose one of the options above : " option ;

while true
do
   case $option in
      1)   checkdeps;
         ;;
      2)   instdeps;
         ;;
      3)   installandcheck;
         ;;
      0)   option="";
         exit;
         ;;
      *)   echo "That choice was invalid!!";
         ;;
   esac
clear
   echo "        ---------- Seed Server Installation Program -----------";
   echo "";
   echo -e "$mainmenu"
   echo "";
   read -p "Please choose one of the options above : " option ;
done

}


function G ()
{
echo -e "   ________ "; $delay1;$wipescreen
echo -e "  |  ______|"; $delay1;$wipescreen
echo -e "  |  | ____"; $delay1;$wipescreen
echo -e "  |  ||__  |"; $delay1;$wipescreen
echo -e "  |  |___| |"; $delay1;$wipescreen
echo -e "  |________|"; $delay1;$wipescreen
}

function dot
{
echo "" ;
echo " " ;
echo "/ \ " ;
echo "\_/ " ;
}

function C ()
{
echo -e "   _______ "; $delay1;$wipescreen
echo -e "  |  _____|"; $delay1;$wipescreen
echo -e "  |  |     "; $delay1;$wipescreen
echo -e "  |  |____ "; $delay1;$wipescreen
echo -e "  |_______|"; $delay1;$wipescreen
}

function E ()
{
echo -e "   _______"; $delay1;$wipescreen
echo -e "  |  _____|"; $delay1;$wipescreen
echo -e "  |  |____ "; $delay1;$wipescreen
echo -e "  |   ____|"; $delay1;$wipescreen
echo -e "  |  |____"; $delay1;$wipescreen
echo -e "  |_______|"; $delay1;$wipescreen
}

function J ()
{
echo -e "   ________"; $delay1;$wipescreen
echo -e "  |___  ___|"; $delay1;$wipescreen
echo -e "     |  |"; $delay1;$wipescreen
echo -e "   _ /  /"; $delay1;$wipescreen
echo -e "  |____/"; $delay1;$wipescreen
}

function O ()
{
echo -e "   _______"; $delay1;$wipescreen
echo -e "  /   _   \ "; $delay1;$wipescreen
echo -e "  |  | |  |"; $delay1;$wipescreen
echo -e "  |  |_|  |"; $delay1;$wipescreen
echo -e "  \_______/"; $delay1;$wipescreen
}

function R ()
{
echo -e "   _____"; $delay1;$wipescreen
echo -e "  |  _  |"; $delay1;$wipescreen
echo -e "  | |_| |"; $delay1;$wipescreen
echo -e "  |  \  \ "; $delay1;$wipescreen
echo -e "  |__|\__\ "; $delay1;$wipescreen
}

function P ()
{
echo -e "   ________"; $delay1;$wipescreen
echo -e "  |  ____  |"; $delay1;$wipescreen
echo -e "  | |____| |"; $delay1;$wipescreen
echo -e "  |  ______|"; $delay1;$wipescreen
echo -e "  |__|"; $delay1;$wipescreen
}

function dash ()
{
echo -e " "; $delay1;$wipescreen
echo -e "  _________"; $delay1;$wipescreen
echo -e " |_________| "; $delay1;$wipescreen
echo -e " "; $delay1;$wipescreen
}

function M ()
{
echo -e "    __  __"; $delay1;$wipescreen
echo -e "   /  \/  \ "; $delay1;$wipescreen
echo -e "  / /\  /\ \  "; $delay1;$wipescreen
echo -e " /_/  \/  \_\ "; $delay1;$wipescreen
}

function L ()
{
echo -e "      ___"; $delay1;$wipescreen
echo -e "     |   |"; $delay1;$wipescreen
echo -e "     |   |"; $delay1;$wipescreen
echo -e "     |   |___"; $delay1;$wipescreen
echo -e "     |_______|"; $delay1;$wipescreen
}

function T ()
{
echo -e "   ________"; $delay1;$wipescreen
echo -e "  |___  ___|"; $delay1;$wipescreen
echo -e "     |  |"; $delay1;$wipescreen
echo -e "     |  |"; $delay1;$wipescreen
echo -e "     |__|"; $delay1;$wipescreen
}

function intro ()
{
clear
T
clear
L
clear
M
clear
dash
clear
P
clear
R
clear
O
clear
J
clear
E
clear
C
clear
T
clear
dot
clear
O
clear
R
clear
G
clear
echo "To skip the intro next time - run $0 -nointro"
sleep 2
}
########## END OF FUNCTIONS #########
############## PROGRAM ##############
$1
intro
Main_Menu
exit

Phew.... :lol:


Top
 Profile WWW  
 PostPosted: Tue Apr 01, 2008 11:45 am   

Joined: Tue Apr 01, 2008 10:19 am
Posts: 49
crudball wrote:
Is there anyway I could use the if command to determine if they have a certain command?



I know this has been answered already, but I think my version is a little cleaner.

Code:
have ()
{
    type "$1" >&/dev/null
}


Usage:
Code:
if have foobar; then
  echo "Has foobar"
fi

have foobar && echo "Has foobar"


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP