LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Eclipse plugins installer (http://www.linuxquestions.org/questions/programming-9/eclipse-plugins-installer-725668/)

KaLPo 05-13-2009 06:25 AM

Eclipse plugins installer
 
Hello!!

I am trying to program a little eclipse installer. It is supposed to install eclipse in /etc/eclipse and change permissions, add into the menu a eclipse.desktop with an icon and all this stuff. This is the script I have.
Code:

#!/bin/bash

function UNINSTALL {

        echo "Removing /etc/eclipse"
        rm -R --interactive=never /etc/eclipse
        groupdel eclipse
        echo "Removing /usr/share/applications/eclipse.desktop"
        rm --interactive=never /usr/share/applications/eclipse.desktop
        echo "Removing /bin/eclipse"
        rm --interactive=never /bin/eclipse
        echo "Done !"
}
function INSTALL {

        echo "Installing"
        echo "Removing old data"
        UNISTALL
tar -zxvf eclipse.tar.gz
mv eclipse /etc
groupadd eclipse
chgrp eclipse /etc/eclipse
chmod ug+rwx /etc/eclipse -R
usermod -a -G $USER kalpo
cp eclipse.png /etc/eclipse
cat > /usr/share/applications/eclipse.desktop << EOF
[Desktop Entry]
Name=Eclipse
Exec=eclipse
Icon=/etc/eclipse/eclipse.png
Terminal=false
Type=Application
Categories=GNOME;GTK;Development;
EOF
cat > /bin/eclipse << EOF
/etc/eclipse/eclipse
EOF
chgrp eclipse /bin/eclipse
chmod a+rwx /bin/eclipse
echo "Done!!"
}

args=("$@")
i=0
USER="kalpo"
userLetter="-u"
UnInstallLetter="-U"
while [ $i -lt $# ]; do
        #echo ${args[${i}]}
        str=${args[${i}]}
        if [ $str = $userLetter ]; then
                TEMP_USER=${args[${i}+1]}
                if [ ${#TEMP_USER} -gt 0 ]; then
                        USER=$TEMP_USER
                        let i=i+1
                        echo "USER SET: '$USER'"       
                else
                        echo "BAD USER SETTING. USING DEFAULT: '$USER'"       
                fi
        elif [ $str = $UnInstallLetter ]; then
                echo "Uninstalling"       
                UNINSTALL
                exit 0;
        fi
        let i=i+1
done
INSTALL

It works all right but I want to improve it using other script for installing plugins.

It just have to untar the plugins and merge the plugins files in the eclipse folder.

My problem is that I don't know how to merge files in bash...

Can anyone help me?

thermite1033 05-13-2009 11:36 AM

A cp to <eclipse-dir>/dropins is enaugh, and add '-clean' to the eclipse.ini file. I can not think of any files that needs to be merged.

sidenote:

I recommend to install eclipse in /opt or in /usr/local instead of /etc.

KaLPo 05-13-2009 04:35 PM

I don't know the difference among /opt /usr/local and /etc. Sincerely, I use always /etc because the apache2 folder is there and as I thought in my starts that this was the folder for programs I got used to use it... Can you explain me what is de difference?

I have tried to use cp -r and it works fine, it overwrites the files with the same name but well, I don't really care about that now. I said merge because I need to put the same folders inside the same folders, so I thought the cp command would overwrite the entire folder without preserving the original content. I see I was wrong xDDDDD.

I will share the code when finish

Thank you!

bgeddy 05-13-2009 05:35 PM

Have a look at this page about the FHS - this may help. The Filesystem Heirarchy Standard. I wouldn't go putting application into /etc.

KaLPo 05-13-2009 06:19 PM

That link is amazing bgeddy, Thanks a lot!!!! and I will definitively change /etc for /opt.


All times are GMT -5. The time now is 08:52 PM.