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

Several fixup and tags command

parent a9492056
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
APP_SERVICE="dolibarr"
DB_SERVICE="mariadb"
user=$APP_SERVICE
db=$APP_SERVICE
PASS_VARIABLE="PASS"
DUMP_PATH="dumps/internal.sql.gz"
is_docker() {
if [ ! -z "$(which docker-compose 2>/dev/null)" ];
then
......@@ -28,12 +35,14 @@ usage() {
echo -e "\trun a php shell, same as $0 artisan tinker"
echo "up"
echo -e "\t starts the docker stack"
echo "tags"
echo -e "\t generate ctags"
}
if [ "$(is_docker)" -eq 1 ]; then
cmd="docker-compose exec dolibarr"
cmdmy="docker-compose exec mariadb"
cmdmyInput="docker exec -i $(docker-compose ps -q mariadb)"
cmd="docker-compose exec $APP_SERVICE"
cmdmy="docker-compose exec $DB_SERVICE"
cmdmyInput="docker exec -i $(docker-compose ps -q $DB_SERVICE)"
cmdrestart="docker-compose restart"
cmdup="docker-compose up"
cmddown="docker-compose down"
......@@ -41,11 +50,8 @@ else
cmdrestart="apache2ctl restart"
fi
user=dolibarr
db=dolibarr
pass=$(awk -F '=' '/PASS/{print $2}' .env)
mysql="mysql -u $user $db -p$pass"
DIR="$(dirname $0)"
action=$1
......@@ -70,7 +76,7 @@ case $action in
read -p "Do you want to init your database with default data? This command will erase your current data. (y/n). " yn
case $yn in
[Yy]* )
zcat dumps/internal.sql.gz | $cmdmyInput $mysql
zcat $DUMP_PATH | $cmdmyInput $mysql
;;
[Nn]* )
exit
......@@ -84,13 +90,19 @@ case $action in
;;
"shell")
if [ $(is_docker) -eq 1 ]; then
docker cp doli_shell.php $(docker-compose ps -q dolibarr):/var/www
docker cp doli_shell.php $(docker-compose ps -q $APP_SERVICE):/var/www
fi
$cmd php -a -d auto_prepend_file=/var/www/doli_shell.php
;;
"up")
$cmdup $@
;;
"tags")
workdir=$PWD
cd $DIR/dolibarr_src
ctags -R --fields=+aimlS --languages=php
mv tags $workdir
;;
*)
echo "ERROR: No command given"
usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment