My following script is producing an error (it complains about expecting ‘then’ keyword before the file exits. I can’t locate the error. Please help if you have the time.
Thank you,
Yucca
#!/bin/sh
#Makes the /usr/lib/jvm in case...
sudo mkdir -p /usr/lib/jvm;
sudo mkdir /org-thejarbar-work-dir;
cd /org-thejarbar-work-dir;
#Update this line to reflect newer versions of JDK...
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.tar.gz;
#Extract the download
tar -xvf ./*gz;
#Move it to where it can be found...
sudo mv ./* /usr/lib/jvm/;
sudo ln -s /usr/lib/jvm/jdk1*/bin/java /usr/bin/;
sudo rm -rf /org-thejarbar-work-dir;
#Makes the /usr/lib/maven in case...
sudo mkdir -p /usr/lib/maven;
sudo mkdir /org-thejarbar-work-dir;
cd /org-thejarbar-work-dir;
#Update this line to reflect newer versions of maven
wget http://mirrors.powertech.no/www.apache.org/dist//maven/binaries/apache-maven-3.0.3-bin.tar.gz;
tar -xvf ./*gz;
#Move it to a more logical location
sudo mv ./* /usr/lib/maven/;
#If you have Maven on Windows and use VirtualBox, you can set up the maven to be a virtualbox shared folder.
#The name must match the name used below (ignore if irrelevant to you).
sudo mount -t vboxsf maven /usr/lib/maven;
#Link the new Maven to the bin...
sudo ln -s /usr/lib/maven/apache-maven-*/bin/mvn /usr/bin/;
sudo rm -rf /org-thejarbar-work-dir;
sudo mkdir /org-thejarbar-work-dir;
cd /org-thejarbar-work-dir;
#Update this line to reflect newer versions of Netbeans or replace 'javase' with 'javaee' or add Java EE manually via
#Netbeans 'plugins as needed.
wget http://download.netbeans.org/netbeans/7.0.1/final/bundles/netbeans-7.0.1-ml-javase-linux.sh;
sh //*sh;
sudo mv ./* /usr/lib/ide/;
#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
sudo ln -s /usr/lib/ide/netbeans-7*/bin/netbeans /usr/bin/;
#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'NetBeansProjects' Remove this if you don't need...
if [ ! -d "~/NetBeansProjects" ]; then
sudo mkdir ~/NetBeansProjects;
fi
sudo mount -t vboxsf NetBeansProjects ~/NetBeansProjects;
sudo rm -rf /org-thejarbar-work-dir;
sudo mkdir /org-thejarbar-work-dir;
cd /org-thejarbar-work-dir;
#Update this line to reflect newer versions of Netbeans or replace 'javase' with 'javaee' or add Java EE manually via
#Netbeans 'plugins as needed.
wget http://download.netbeans.org/netbeans/7.0.1/final/bundles/netbeans-7.0.1-ml-javase-linux.sh;
sh //*sh;
sudo mv ./* /usr/lib/ide/;
#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
sudo ln -s /usr/lib/ide/netbeans-7*/bin/netbeans /usr/bin/;
#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'NetBeansProjects' Remove this if you don't need...
if [ ! -d "~/NetBeansProjects" ]; then
sudo mkdir ~/NetBeansProjects;
fi
sudo mount -t vboxsf NetBeansProjects ~/NetBeansProjects;
sudo rm -rf /org-thejarbar-work-dir;
sudo mkdir /org-thejarbar-work-dir;
cd /org-thejarbar-work-dir;
sudo wget http://download-ln.jetbrains.com/idea/ideaIC-11.tar.gz
sudo tar -zxvf ./*.gz;
#Move it to a better location...
sudo rm -rf /usr/lib/ide/idea-IC*;
sudo mv ./* /usr/lib/ide/;
#Add IDEA launcher to your PATH. Doing so allows you to run 'idea.sh' command from the terminal
rm /usr/bin/idea.sh;
sudo ln -s /usr/lib/ide/idea-IC*/bin/idea.sh /usr/bin/;
#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'IdeaProjects' Remove this if you don't need...
if [ ! -d "~/IdeaProjects" ]; then
sudo mkdir ~/IdeaProjects;
fi
sudo rm -rf /org-thejarbar-work-dir;
exit 0;
Note that the script works (does what is required), but the error is bothersome as I am working on sharing this script to others. I am trying to avoid the error.
First of all, that’s not a bash script right now – it’s a bourne shell script. If you want to use bash change the first line (the “shebang”) to use
/bin/bash. You showed with your comment that/bin/shis actuallydashin your system. dash is a minimal implementation of the bourne shell.You can debug a bash script by running it with
-x, as in:/bin/bash -x script.sh; or changing the shebang to#!/bin/bash -x(temporarily).As an aside, you’re testing for directories and creating them if they don’t exist. If that’s all you’re going to do inside the if clauses you can use a plain
mkdir -pso it doesn’t raise an error if the path already exists. Note it may not be available in all *nix systems, but it is in GNU/Linux.