Jump to content
Sign in to follow this  
Johnny Mercy

[Bash] Easy XAMPP Manager - Linux

Recommended Posts

Johnny Mercy

Boas pessoal.

Como voces sabem, fazer as tarefas mais comuns do XAMPP nas plataformas Linux é um pouco mais dificil do que no Windows e para utilizadores que não percebam de Shell Script pode ser um verdadeiro quebra cabeças.

Com este pequeno programinha, venho facilitar a vida de todos pois é bastante intuitivo e prático.

screenshotun.png

#!/bin/bash
#----------------------------------
#Note:
#You may need to change the path variable if your XAMPP instalation folder isn't the default one.
#Path variable:
path="/opt/lampp/lampp"
#----------------------------------
if [ -e $path ]; then
    echo "SUCESS"
else
    echo "ERROR: File missing."
    echo "The path variable is wrong."
    echo "Plase check it by editing this file (line 6)."
    echo "-------------------------------------"
    echo "Press any key to exit.."
    read
    exit
fi
clear
function showCommands {
    echo ""
    echo "	start        Start XAMPP (Apache, MySQL and eventually others)"
    echo "	startapache  Start only Apache"
    echo "	startssl     Start only SSL support"
    echo "	startmysql   Start only MySQL"
    echo "	startftp     Start only ProFTPD"
    $iswebmin && echo "	startwebmin  Start only Webmin"
    echo ""
    echo "	stop         Stop XAMPP (Apache, MySQL and eventually others)"
    echo "	stopapache   Stop only Apache"
    echo "	stopssl      Stop only SSL support"
    echo "	stopmysql    Stop only MySQL"
    echo "	stopftp      Stop only ProFTPD"
    $iswebmin && echo "	stopwebmin   Stop only Webmin"
    echo ""
    echo "	reload       Reload XAMPP (Apache, MySQL and eventually others)"
    echo "	reloadapache Reload only Apache"
    echo "	reloadmysql  Reload only MySQL"
    echo "	reloadftp    Reload only ProFTPD"
    echo ""
    echo "	restart      Stop and start XAMPP"
    echo "	security     Check XAMPP's security"
    echo ""
    echo "	php5         Activate PHP5"
    ##echo "	php4         Activate PHP4"
    echo "	phpstatus    Which version of PHP is active?"
    echo ""
    echo "	backup       Make backup file of your XAMPP config, log and data files"
    echo "	panel        Starts graphical XAMPP control panel"
    echo ""
}
function showMenu {
    clear
    echo "+------------------------------------+"
    echo "| Easy XAMPP Manager by Johnny Mercy |"
    echo "+------------------------------------+"
    echo "| Menu                               |"
    echo "+------------------------------------+"
    echo "+------------------------+"
    echo "| Basic                  |"
    echo "+------------------------+"
    echo "1 - Start XAMPP"
    echo "2 - Restart XAMPP"
    echo "3 - Stop XAMPP"
    echo "4 - Password Management"
    echo "+------------------------+"
    echo "| Advanced               |"
    echo "+------------------------+"
    echo "7 - All Commands"
    echo "+------------------------+"
    echo "| Misc                   |"
    echo "+------------------------+"
    echo "8 - Exit Manager"
    echo "-------------------------------------"
    echo "Type the number of the option you want and press enter"
}
echo "This bash program may require full previleges."
echo "Do you want acess in root mode now? (y/n)"
read answer
if [ $answer == "y" ]; then
  sudo -l
fi
until [ $x -eq 8 ]; do
showMenu
read x
if [ $x -eq 1 ]; then
    clear
    sudo $path start
elif [ $x -eq 2 ]; then
    clear
    sudo $path restart;
elif [ $x -eq 3 ]; then
    clear
    sudo $path stop;
elif [ $x -eq 4 ]; then
    clear
    sudo $path security;
elif [ $x -eq 7 ]; then
    clear
    echo "+------------------------+"
    echo "| Quick Help             |"
    echo "+------------------------+"
    echo "There are a lot more of commands that you can use in XAMPP, you can see them in the lampp file located in $path"
    echo "The list bellow have all the commands you can use:"
    showCommands
    echo "Insert Command:"
    read command
    sudo $path $command
fi
if [ $x != 8 ]; then
    echo "-------------------------------------"
    echo "Press any key to continue.."
    read
fi 
done
exit

Como correr o programa?

Simples, faça download do programa e clique duas vezes nele.

Vai aparecer uma caixa de texto em que devem escolher "Run in terminal" ou "Correr no terminal" de acoordo a linguagem do vosso sistema operativo.

Notas

Este código foi optimizado para Ubuntu.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.