Hey all. Hopefully someone can help me out with this one. Im writing a bash script to run through some install processes, but I'm caught on how to properly set this up. What I wan done is to ask the user for Y/N input. If Y then install the rpm, if no. Goto the next Y/N question.

Mild example.

Would you like to install john the ripper? Y/N? (Yes is default)

if y do yum install -y john
if n goto next question

Hope this kind of make sense?!

I got the read input down, but its also being picky about what case the input is. I would like to have it take lower and upper.

I got the y/n input working, but I'm scratching my head on this one part.

Im asking the user to specify if they want to be prompted to install a tool on an individual basis, or as a group. The group install is the first option and the tool by tool is the second, but I want it to completely skip the second part if the do the group install.

well... that would be covered by an if/then/else...
you might be missing the logic in an if statement....
if the first condition is met... it executes that code block, and ignores the else portion....
if the first condition is NOT met... that code block is skipped and the else portion is executed instead...

so let's say you had this code:

Code:

if [[ "$a" == "1" ]]then echo "1"else echo "2"fi

Ex 1: a=1
the output would be "1"

Ex 2: a=0
the output would be "2"

in neither example is more than one thing echoed. that's because only ONE thing can execute in this if/then/else code block

please read my intermediate tutorial here... it goes over if/then concepts and case/esac... i think it's right up your alley right now

Thanks for the help. I apologize for sounding like a simpleton. I had the the magical "POP" of my head coming out of my butt when I was putting the key in the car on the drive home and figured out how to structure it.

echo "P0f v2 is a versatile passive OS fingerprinting tool. P0f can identify the system on machines that talk thru or near your box. p0f will also check masquerading and firewall presence, the distance to the remote system and its uptime, other guy's network hookup (DSL, OC3, avian carriers) and his ISP."
echo ""
echo ""
echo "Would you like to install p0f? n/Y?"
read a
if [[ $b == "N" || $b == "n" ]]; then

echo "p0f will not be installed."
else
echo "Installing p0f"

echo "NBTscan is a program for scanning IP networks for NetBIOS name information. It sends a NetBIOS status query to each address in supplied range and lists received information in human readable form. "
echo ""
echo ""
echo "Would you like to install Nbtscan n/Y"
read a
if [[ $a == "N" || $a == "n" ]]; then
echo "Nbtscan will not be installed."
else
echo "Installing Nbtscan"

i believe you are forgetting to close some of your if statements... try putting some "fi" in the right places... they have to be in the right places to do what you are looking for.... but i think you are on the right track

yeah, I got the fi's figured out. My major problem is that i have 96 tools(at this moment, more coming) to install. Which means I have 96 if statements to create, and then close. I tested with 10 and got everything working properly. Im guessing having that many fi's at the end are going to be a head scratcher to try and troubleshoot. I was thinking about a for loop with the y/n input in it, etc. But I'm so far into at this point, I really dont want to try and re-invent the weel.

I will probably kick myself in the rear for that when I actually have to start troubleshooting.

you wouldn't want all the fi's at the end i don't think... that would mean that all the functions are embedded into the else of the top-most if/then...
if i were you... (because the list of tools seems so long) i would make a list of the tools in a file... and loop through the file asking to install each...
that way you just have one loop... one if/then...

Yeah, the menu would be a pain to go through, simply due to the number of tools (96) (and that number is and will grow over time). Thanks for the post though!

I really liked the idea of the loop, but after some consideration I went with the "One script to rule them all" policy. I'm going to end up passing it out to other team members, so I wanted to keep it as simple for "user troubleshooting" as possible.

I have run a test through 26 of the 96 installs and everything is working great. I just have 96 fi's at the end of the install portion. Which looks really bad, but it gets the job done right? (I think im about ready to breach 2000+ lines of code in its entirety (rev 1). So i was just really trying to keep things as slim as possible. But, nothing but time ahead of me so I can always optimize later!

echo "P0f v2 is a versatile passive OS fingerprinting tool. P0f can identify the system on machines that talk thru or near your box. p0f will also check masquerading and firewall presence, the distance to the remote system and its uptime, other guy's network hookup (DSL, OC3, avian carriers) and his ISP."
echo ""
echo ""
echo "Would you like to install p0f? n/Y?"
read a
if [[ $a == "Y" || $a == "y" || $a = "" ]];then

echo "Installing p0f"

yum install -y p0f
else

clear

echo "NBTscan is a program for scanning IP networks for NetBIOS name information. It sends a NetBIOS status query to each address in supplied range and lists received information in human readable form. "
echo ""
echo ""
echo "Would you like to install Nbtscan n/Y"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Nbtscan"

yum install -y nbtscan

else

clear

echo "While Wine is usually thought of as a Windows(TM) emulator, the Wine developers would prefer that users thought of Wine as a Windows compatibility layer for UNIX. This package includes a program loader, which allows unmodified Windows 3.x/9x/NT binaries to run on x86 and x86_64 Unixes. Wine does not require MS Windows, but it can use native system .dll files if they are available."
echo ""
echo ""
echo "Would you like to install Wine, n/Y?"

echo "AirSnort is a wireless LAN (WLAN) tool which recovers encryption keys. AirSnort operates by passively monitoring transmissions, computing the encryption key when enough packets have been gathered."
echo ""
echo "802.11b, using the Wired Equivalent Protocol (WEP), is crippled with numerous security flaws. Most damning of these is the weakness described in Weaknesses in the Key Scheduling Algorithm of RC4 by Scott Fluhrer, Itsik Mantin and Adi Shamir. Adam Stubblefield was the first to implement this attack, but he has not made his software public. AirSnort, along with WEPCrack, which was released about the same time as AirSnort, are the first publicly available implementaions of this attack."
echo ""
echo "AirSnort requires approximately 5-10 million encrypted packets to be gathered. Once enough packets have been gathered, AirSnort can guess the encryption password in under a second."
echo ""
echo ""
echo "Would you like to install Airsnort, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Aircrack"

yum install -y airsnort
else

clear

echo "Firewall Builder consists of a GUI and set of policy compilers for various firewall platforms. It helps users maintain a database of objects and allows policy editing using simple drag-and-drop operations. GUI generates firewall description in the form of XML file, which compilers then interpret and generate platform-specific code. Several algorithms are provided for automated network objects discovery and bulk import of data. The GUI and policy compilers are completely independent, this provides for a consistent abstract model and the same GUI for different firewall platforms. "
echo ""
echo ""
echo "Would you like to install Firewall Builder, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Firewall Builder"

yum install -y fwbuilder

else

clear

echo "GNOME Sensors Applet is an applet for the GNOME Panel to display readings from hardware sensors, including CPU and system temperatures, fan speeds and voltage readings under Linux. Can interface via the Linux kernel i2c modules, or the i8k kernel module (for Dell Inspirion 8000 Laptops). Includes a simple, yet highly customizable display and intuitive user-interface. Alarms can be set for each sensor to notify the user once a certain value has been reached, and can be configured to execute a given command at given repeated intervals. GNOME HIG v2.0 compliant."
echo ""
echo ""
echo "Would you like to install Gnome Sensors Applet, n/Y?"

read a
if [[ $a == "y" || $a == "Y" ]]; then

echo "Installing GNOME Sensors Applet"

yum install -y gnome-applet-sensors

else

clear

echo "GParted stands for Gnome Partition Editor and is a graphical frontend to libparted. Among other features it supports creating, resizing, moving and copying of partitions. Also several (optional) filesystem tools provide support for filesystems not included in libparted. These optional packages will be detected at runtime and don't require a rebuild of GParted."
echo ""
echo ""
echo "Would you like to install GParted, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing GParted"

yum install -y gparted

else

clear

echo "GQ is a graphical browser for LDAP directories and schemas. Using GQ, an administrator can search through a directory and modify objects stored in that directory."
echo ""
echo ""
echo "Would you like to install GQ?, n/Y?"

read a
if [[ $a == "y" || $a == "Y" ]]; then

echo "Installing GQ"

yum install -y gq

else
clear

echo "K3b provides a comfortable user interface to perform most CD/DVD burning tasks. While the experienced user can take influence in all steps of the burning process the beginner may find comfort in the automatic settings and the reasonable k3b defaults which allow a quick start."
echo ""
echo ""
echo "Would you like to install K3b, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing K3b"

yum install -y k3b
else
clear

echo "KSensors is a nice lm-sensors frontend for the K Desktop Environment. Install the hddtemp package if you wish to monitor hard disk temperatures with KSensors."
echo ""
echo ""
echo "Would you like to install KSensors, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing KSensors"

yum install -y ksensors

else
clear

echo "Lynx is a text-based Web browser. Lynx does not display any images, but it does support frames, tables, and most other HTML tags. One advantage Lynx has over graphical browsers is speed; Lynx starts and exits quickly and swiftly displays webpages."
echo ""
echo ""
echo "Would you like to install Lynx, n/Y?"
read a

if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Lynx"

yum install -y lynx

else
clear

echo "GNOME MPlayer is a simple GUI for MPlayer. It is intended to be a nice tight player and provide a simple and clean interface to MPlayer. GNOME MPlayer has a rich API that is exposed via DBus. Using DBus you can control a single or multiple instances of GNOME MPlayer from a single command."
echo ""
echo ""
echo "Would you like to install GNOME MPlayer, n/Y?"

read a
if [[ $a == "y" || $a == "Y" ]]; then

echo "Installing GNOME MPlayer"

yum install -y mplayer
else
clear

echo "This MPLayer-Gui package contains a GUI for MPlayer and a default skin for it."
echo ""
echo ""
echo "Would you like to install the GUI for MPlayer, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing GNOME MPlayer GUI"

yum install -y mplayer-gui

else
clear

echo "MySQL is a multi-user, multi-threaded SQL database server. MySQL is a client/server implementation consisting of a server daemon (mysqld) and many different client programs and libraries. This package contains the MySQL server and some accompanying files and directories."
echo ""
echo ""
echo "Would you like to install MySQL, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing MySQL"

yum install -y mysql-server

else
clear

echo "Nikto is a web server scanner which performs comprehensive tests against web servers for multiple items, including over 3300 potentially dangerous files/CGIs, versions on over 625 servers, and version specific problems on over 230 servers. Scan items and plugins are frequently updated and can be automatically updated (if desired)."
echo ""
echo ""
echo "Would you like to install Nikto, n/Y?"

echo "This package includes zenmap, a GTK+ frontend for nmap. The nmap package must be installed before installing nmap-frontend."
echo ""
echo ""
echo "Would you like to install Nmap-Frontend, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Nmap-Frontend"

yum install -y nmap-frontend

else
clear

echo "This module implements a interface to the information contained in an nmap scan. It is implemented by parsing the xml scan data that is generated by nmap. This will enable anyone who utilizes nmap to quickly create fast and robust security scripts that utilize the powerful port scanning abilities of nmap."
echo ""
echo ""
echo "Would you like to install Perl-Nmap-Parser, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing Perl-Nmap-Parser"

yum install -y perl-Nmap-Parser

else
clear

echo "Client for the proprietary Microsoft Point-to-Point Tunneling Protocol, PPTP. Allows connection to a PPTP based VPN as used by employers and some cable and ADSL service providers."
echo ""
echo ""
echo "Would you like to install PPTP, n/Y?"

read a
if [[ $a == "y" || $a == "Y" || $a = "" ]]; then

echo "Installing PPTP"

yum install -y pptp

else
clear

echo "tsclient is a frontend that makes it easy to use rdesktop and vncviewer. You will need to install rdesktop or vnc in addition to tsclient."
echo ""
echo ""
echo "Would you like to install TSCleint, n/Y?"

here's an example of the way i was talking about... with the file and the loop... first... you need a file with the list of tools and their descriptions (make sure the name of the package is what you would use to call yum with... and that you use a | to separate the name of the package with the description) :

tools.lst wrote:

p0f|P0f v2 is a versatile passive OS fingerprinting tool. P0f can identify the system on machines that talk thru or near your box. p0f will also check masquerading and firewall presence, the distance to the remote system and its uptime, other guy's network hookup (DSL, OC3, avian carriers) and his ISP.nbtscan|NBTscan is a program for scanning IP networks for NetBIOS name information. It sends a NetBIOS status query to each address in supplied range and lists received information in human readable form.

now the list above we would call "tools.lst" and have it in the same directory as the script. the format of the list would be: package name|description
the online time you press enter when filling out that list would be when you were going on to the next tool

Who is online

Users browsing this forum: No registered users and 5 guests

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