Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a piece of code that has some serious issues and I was hoping to get it solved soon but no one has offered any help. I thought I'd try some Ubuntu users since this is the OS running the script.

mc_addplugin() {
    if pgrep -u $USERNAME -f $SERVICE > /dev/null
    then
        echo "$SERVICE is running! Please stop the service before adding a plugin."
    else
        echo "Paste the URL to the .JAR Plugin..."
        read JARURL
        JARNAME=$(basename "$JARURL")
        if [ -d "$TEMPPLUGINS" ]
        then
            as_user "cd $PLUGINSPATH && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
        else
            as_user "cd $PLUGINSPATH && mkdir $TEMPPLUGINS && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
        fi
    if [ -f "$TMPDIR/$JARNAME" ]
    then
        if [ -f "$PLUGINSPATH/$JARNAME" ]
        then
            if `diff $PLUGINSPATH/$JARNAME $TMPDIR/$JARNAME >/dev/null`
            then 
                echo "You are already running the latest version of $JARNAME."
            else
                NOW=`date "+%Y-%m-%d_%Hh%M"`
                echo "Are you sure you want to overwrite this plugin? [Y/n]"
                echo "Note: Your old plugin will be moved to the "$TEMPPLUGINS" folder with todays date."
                select yn in "Yes" "No"; do
                    case $yn in
                        Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
                        No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
                            as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
                    esac
                done
                echo "Would you like to start the $SERVICE now? [Y/n]"
                select yn in "Yes" "No"; do
                    case $yn in
                        Yes ) mc_start; break;;
                        No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
                        esac
                done
            fi
        else
            echo "Are you sure you want to add this new plugin? [Y/n]"
            select yn in "Yes" "No"; do
                case $yn in
                    Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
                    No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
                        as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
                esac
            done
            echo "Would you like to start the $SERVICE now? [Y/n]?"
            select yn in "Yes" "No"; do
                case $yn in
                    Yes ) mc_start; break;;
                    No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
                esac
            done
        fi
    else
        echo "Failed to download the plugin from the URL you specified!"
        exit;
    fi
}

It throws it at the closing bracket at the end of the function.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You're missing a fi statement to close the first if/then/else conditional.

share|improve this answer
    
Really? I swear I looked. Lol –  WASasquatch Jul 9 '12 at 2:12
    
@WASasquatch: If this answer solves your problem, please mark it as answered by clicking the check mark to the left of the answer. –  Scott Severance Jul 10 '12 at 13:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.