Create bash script to install package in ubuntu

Posted By : Raman Joshi | 30-Sep-2015

In this blog we all see that how we can create a shell script to install jar package from tar.gz file. Below is the steps we need to follow for package jar file into tar.gz.

Step 1 : First we need put all required jar files and .desktop file and other related file like icon and images required in one folder.

Step 2 : Then compress folder to create .tar.gz.

Step 3 : Now create the bash script which extract tar.gz file and install it in one specified location. Below is the script which is used in my case.

 #!/bin/bash
if which java >/dev/null; then
sudo tar xvfz CaptionLabs.tar.gz -C /opt #(Path for Extract Files)
mkdir ~/.local/share/applications/
sudo tar xvfz CaptionLabs.tar.gz -C ~/.local/share/applications
sudo cp ~/.local/share/applications/CaptionLabs/CaptionLabs.desktop ~/Desktop/CaptionLabs.desktop
sudo chmod 777 ~/Desktop/CaptionLabs.desktop
echo "Program installed.!"
else
echo "JRE Not Installed..!"
fi
read
exit
 

Step 4 : At last you need to change chmod +x of script to make it executable and run it.

This will create the .desktop file in desktop and you can run the application by double click on that icon.

 

THANKS

About Author

Author Image
Raman Joshi

Raman is a bright web app developer with experience in Java , Groovy and Grails frameworks

Request for Proposal

Name is required

Comment is required

Sending message..