What do you think of this script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What do you think of this script?
# 1  
Old 09-18-2013
What do you think of this script?

This script is for installing JIRA with Postgres as database. Also in the script is to make an automatic user and database to use this for Jira.
Code:
#!/bin/bash
############################################################
# Script om JIRA met optioneel Postgres te installeren
############################################################

prompt_ynq () {
   echo -e "\e[01;31m${1}\e[00m"
   PS3="Maak je keuze ('s' voor stop): "
   INSTALL=false
   select ANSWER in "ja" "nee"; do
        case ${ANSWER} in
         *    ) INSTALL=${ANSWER};  break;;
      esac
   done
   check_stop ${INSTALL}
}

prompt_list () {
# haal uit de argumenten de prompt en de keuzes
   ARRAY=("${@}")
   LEN=${#ARRAY[@]}
   PROMPT=${ARRAY[0]}
   CHOICES=${ARRAY[@]:1:$LEN}
#echo len: $LEN
#echo prompt: $PROMPT
#echo keuzes: $CHOICES
   echo -e "\e[01;31m${PROMPT}\e[00m"
   PS3="Maak je keuze ('s' voor stop): "
   CHOICE=false
   select ANSWER in ${CHOICES}; do
      case ${ANSWER} in
         *    ) CHOICE=${ANSWER};  break;;
      esac
   done
   check_stop ${CHOICE}
}

check_stop () {
   if [ -z ${1} ]
   then
       echo -e "\n\e[01;31mJe hebt er voor gekozen om te stoppen\e[00m\n"
       exit
   fi
}

echo -e "\e[01;31mInstallatie van JIRA\e[00m"
echo "--------------------------------------"
prompt_ynq "Wil je JIRA installeren?"
if [ ${INSTALL} = "ja" ]
then
        echo "--------------------------------------"
        prompt_list "Welke JIRA wil je installeren?" "atlassian-jira-6.0.6.tar.gz" "atlassian-jira-6.0.6-x64.bin"
        JIRA_OBJECT=${CHOICE}
        echo "--------------------------------------"   
        prompt_list "Waar wil je dat JIRA geinstalleerd wordt?" "/usr/local/jira" "/usr/lib/jira" "anders"
        if [ ${CHOICE} = "anders" ]
        then
            read -e -p "Vul zelf de locatie in: " -i "/usr/local/" CHOICE
        fi
        JIRA_INSTALL_FOLDER=${CHOICE}

        if [ ${JIRA_OBJECT} = "atlassian-jira-6.0.6.tar.gz" ]
        then
            echo "JIRA wordt geinstalleerd"
            echo "--------------------------------------"
            mkdir -p ${JIRA_INSTALL_FOLDER}
            cd ${JIRA_INSTALL_FOLDER}
            mv -f /data/scripts/jirainstall/atlassian-jira-6.0.6.tar.gz ${JIRA_INSTALL_FOLDER}
            tar -xzf ${IRA_OBJECT}
            chown -R root:root ${JIRA_OBJECT}

        elif [ ${JIRA_OBJECT} = "atlassian-jira-6.0.6-x64.bin" ]
        then
            echo "JIRA wordt geinstalleerd"
            echo "--------------------------------------"
            mkdir -p ${JIRA_INSTALL_FOLDER}
            cd ${JIRA_INSTALL_FOLDER}
            mv -f /data/scripts/jirainstall/atlassian-jira-6.0.6-x64.bin ${JIRA_INSTALL_FOLDER}
            chmod +x ${JIRA_OBJECT}
            ./${JIRA_OBJECT}

        else
            echo "--------------------------------------"
            echo "Installatie mislukt"
            echo "--------------------------------------"
            exit
        fi

fi

############################################################
# Postgres als bijbehorende database installeren met JIRA
############################################################

echo "--------------------------------------"
prompt_ynq "Wil je Postgres als database installeren voor JIRA?"
echo "--------------------------------------"
if [ ${INSTALL} = "ja" ]
then
        echo "--------------------------------------"
        prompt_list "Welke postgres wil je installeren?" "postgresql-8.4.17-1-linux-x64.run" "postgresql-9.2.4-1-linux-x64.run"
        POSTGRES_OBJECT=${CHOICE}
        echo "--------------------------------------"
        prompt_list "Waar wil je dat postgres geinstalleerd wordt?" "/usr/local/postgres" "/usr/lib/postgres" "anders"
        if [ ${CHOICE} = "anders" ]
        then
              read -e -p "Vul zelf de locatie in" -i "/usr/local/" CHOICE
        fi
        POSTGRES_INSTALL_FOLDER=${CHOICE}

        if [ ${POSTGRES_OBJECT} = "postgresql-8.4.17-1-linux-x64.run" ]
        then
             echo "POSTGRES 8.4 wordt geinstalleerd"
             echo "--------------------------------------"
             mkdir -p ${POSTGRES_INSTALL_FOLDER}
             cd ${POSTGRES_INSTALL_FOLDER}
             mv -f /data/scripts/postgresinstall/postgresql-8.4.17-1-linux-x64.run ${POSTGRES_INSTALL_FOLDER}
             chmod +x ${POSTGRES_OBJECT}
             ./${POSTGRES_OBJECT}

        elif [ ${POSTGRES_OBJECT} = "postgresql-9.2.4-1-linux-x64.run" ]
        then
             echo "POSTGRES 9.2 wordt geinstalleerd"
             echo "--------------------------------------"
             mkdir -p ${POSTGRES_INSTALL_FOLDER}
             cd ${POSTGRES_INSTALL_FOLDER}
             mv -f /data/scripts/postgresinstall/postgresql-9.2.4-1-linux-x64.run ${POSTGRES_INSTALL_FOLDER}
             chmod +x ${POSTGRES_OBJECT}
             ./${POSTGRES_OBJECT}

        else
             echo "--------------------------------------"
             echo "Installatie mislukt"
             echo "--------------------------------------"
             exit
        fi

fi


Last edited by vbe; 09-18-2013 at 09:17 AM.. Reason: code tags... more indent...
# 2  
Old 09-18-2013
I would add a test to ensure that only root can run the script.
# 3  
Old 09-19-2013
I would like to test it, but on my test server i have already installed postgres and i think it will get problems if they both be installed. I will make a Virtual Ubuntu and will test there the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question