Skip to content
Snippets Groups Projects
Verified Commit 04658160 authored by David Beniamine's avatar David Beniamine
Browse files

CLI

parent e8628bbb
Branches
No related tags found
No related merge requests found
glpi 0 → 100755
#!/bin/bash
is_docker() {
if [ ! -z "$(which docker-compose 2>/dev/null)" ];
then
echo "1"
else
echo "0"
fi
}
usage() {
echo -e "Usage $0 <command> [args]\n"
echo -e "COMMANDS\n"
echo "bash"
echo -e "\topens a bash terminal in front container or just run bash"
echo "cache"
echo -e "\t clears all the caches and update assets_hashes"
echo "console"
echo -e "\t run artisan, argument are passed to artisan"
echo "down"
echo -e "\t stops the docker stack"
echo "help"
echo -e "\t displays this messages and exit"
echo "mysql"
echo -e "\topen a mysql prompt in LNB database"
echo "restart"
echo -e "\t restart the docker stack or apache2"
echo "up"
echo -e "\t starts the stack"
}
if [ "$(is_docker)" -eq 1 ]; then
cmd="docker-compose exec glpi"
cmdmy="docker-compose exec db"
cmdmyInput="docker exec -i $(docker-compose ps -q db)"
cmdrestart="docker-compose restart"
cmdup="docker-compose up"
cmddown="docker-compose down"
else
cmdrestart="apache2ctl restart"
fi
user=$(awk -F '=' '/MYSQL_USER/{print $2}' .env)
db=$(awk -F '=' '/MYSQL_DATABASE/{print $2}' .env)
pass=$(awk -F '=' '/MYSQL_PASSWORD/{print $2}' .env)
mysql="mysql -u $user $db -p$pass"
DIR="$(dirname $0)"
action=$1
shift
# Keep actions sorted
case $action in
"bash")
$cmd bash
;;
"cache")
$0 console cache:clear
;;
"console")
$cmd php bin/console $@
;;
"down")
$cmddown
;;
"help")
usage
;;
"mysql")
$cmdmy $mysql
;;
"restart")
$cmdrestart $@
;;
"up")
$cmdup $@
;;
*)
echo "ERROR: No command given"
usage
exit 1
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment