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