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

CLI

parent eb8a21ba
Branches
No related tags found
No related merge requests found
doli 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 "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 "mysql_init"
echo -e "\tpopulate LabNbook database (Docker only)"
echo "restart"
echo -e "\t restart the docker stack or apache2"
echo "shell"
echo -e "\trun a php shell, same as $0 artisan tinker"
echo "up"
echo -e "\t starts the docker stack"
}
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)"
cmdrestart="docker-compose restart"
cmdup="docker-compose up"
cmddown="docker-compose down"
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
shift
# Keep actions sorted
case $action in
"bash")
$cmd bash
;;
"down")
$cmddown
;;
"help")
usage
;;
"mysql")
set -x
$cmdmy $mysql
set +x
;;
"mysql_init")
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
;;
[Nn]* )
exit
;;
* )
echo "Please answer yes or no.";;
esac
;;
"restart")
$cmdrestart $@
;;
"shell")
if [ $(is_docker) -eq 1 ]; then
docker cp doli_shell.php $(docker-compose ps -q dolibarr):/var/www
fi
$cmd php -a -d auto_prepend_file=/var/www/doli_shell.php
;;
"up")
$cmdup $@
;;
*)
echo "ERROR: No command given"
usage
exit 1
;;
esac
<?php
/**
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file scripts/user/sync_groups_dolibarr2ldap.php
* \ingroup ldap core
* \brief Script de mise a jour des groupes dans LDAP depuis base Dolibarr
*/
if (!defined('NOSESSION')) {
define('NOSESSION', '1');
}
function dd($data) {
echo json_encode($data, JSON_PRETTY_PRINT);
}
function query($raw) {
global $db;
return $db->query($raw);
}
function fetch($raw) {
global $db;
$resql = query($raw);
if ($resql) {
return $db->fetch_object($resql);
}
return null;
}
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = __DIR__.'/';
include "/var/www/dolibarr/htdocs/master.inc.php";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment