Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dolibarr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NoCloud
docker
Dolibarr
Commits
ea9e2cc6
Commit
ea9e2cc6
authored
2 weeks ago
by
David Beniamine
Browse files
Options
Downloads
Plain Diff
Merge branch 'doli-script-update' into 'master'
Doli script update See merge request
!6
parents
cf2964d9
5cd6b306
Branches
master
No related tags found
1 merge request
!6
Doli script update
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
doli
+143
-136
143 additions, 136 deletions
doli
with
143 additions
and
136 deletions
doli
+
143
−
136
View file @
ea9e2cc6
...
@@ -21,83 +21,13 @@ is_docker() {
...
@@ -21,83 +21,13 @@ is_docker() {
fi
fi
}
}
usage
()
{
info
(){
echo
-e
"Usage
$0
<command> [args]
\n
"
echo
-e
"COMMANDS
\n
"
echo
"bash"
echo
-e
"
\t
opens 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
"logs"
echo
-e
"
\t
Follow all useful logs"
echo
"logs <term1> <term2> ..."
echo
-e
"
\t
Follow all useful logs and highlight terms"
echo
"mysql"
echo
-e
"
\t
pen a mysql prompt in LNB database"
echo
"mysql_dump"
echo
-e
"
\t
creates a database dump"
echo
"mysql_init"
echo
-e
"
\t
populate LabNbook database (Docker only)"
echo
"mysql_restore"
echo
-e
"
\t
restores database from a dump"
echo
"perms"
echo
-e
"
\t
sets default files permissions"
echo
"restart"
echo
-e
"
\t
restart the docker stack or apache2"
echo
"shell"
echo
-e
"
\t
run a php shell, same as
$0
artisan tinker"
echo
"up"
echo
-e
"
\t
starts the docker stack"
echo
"tags"
echo
-e
"
\t
generate ctags"
echo
"fail2ban"
echo
-e
"
\t
root only - put fail2ban jail and filter in good directory with good log path"
}
if
[
"
$(
is_docker
)
"
-eq
1
]
;
then
if
[
-z
"
$(
which docker-compose
)
"
]
;
then
compose
=
"docker compose"
else
compose
=
"docker-compose"
fi
cmd
=
"
$compose
exec
$APP_SERVICE
"
cmdmy
=
"
$compose
exec
$DB_SERVICE
"
cmdmyInput
=
"docker exec -i
$(
$compose
ps
-q
$DB_SERVICE
)
"
cmdrestart
=
"
$compose
restart"
cmdup
=
"
$compose
up"
cmddown
=
"
$compose
down"
else
cmdrestart
=
"apache2ctl restart"
fi
if
[
!
-z
"
$(
which ccze
)
"
]
;
then
reader
=
"ccze -A"
else
reader
=
"tee"
fi
pass
=
$(
get_conf_val main_db_pass
)
mysql
=
"mariadb -u
$user
$db
-p
$pass
"
DIR
=
"
$(
dirname
$0
)
"
action
=
$1
shift
# Keep actions sorted
case
$action
in
"bash"
)
$cmd
bash
;;
"down"
)
$cmddown
;;
"help"
)
usage
;;
"info"
)
echo
"** Info about your Dolibarr instance **"
echo
"** Info about your Dolibarr instance **"
# Colors for output
GREEN
=
'\033[0;32m'
YELLOW
=
'\033[1;33m'
RED
=
'\033[0;31m'
NC
=
'\033[0m'
# Date and time
# Date and time
timestamp
=
$(
date
'+%Y-%m-%d %H:%M:%S'
)
timestamp
=
$(
date
'+%Y-%m-%d %H:%M:%S'
)
...
@@ -109,14 +39,11 @@ case $action in
...
@@ -109,14 +39,11 @@ case $action in
instance_path
=
$(
realpath
dolibarr_src/.. 2>/dev/null
)
instance_path
=
$(
realpath
dolibarr_src/.. 2>/dev/null
)
instance_name
=
$(
basename
"
$instance_path
"
)
instance_name
=
$(
basename
"
$instance_path
"
)
echo
-e
"Generated at:
$timestamp
"
echo
-e
"Generated at:
$timestamp
"
echo
-e
"Machine:
$host
"
echo
-e
"Machine:
$host
"
echo
-e
"Instance:
$instance_name
"
echo
-e
"Instance:
$instance_name
"
echo
-e
"Instance path:
$instance_path
\n
"
echo
-e
"Instance path:
$instance_path
\n
"
## Docker deployment
## Docker deployment
if
[
"
$(
is_docker
)
"
-eq
1
]
;
then
if
[
"
$(
is_docker
)
"
-eq
1
]
;
then
echo
"Docker deployment detected."
echo
"Docker deployment detected."
...
@@ -150,11 +77,6 @@ case $action in
...
@@ -150,11 +77,6 @@ case $action in
if
[
-d
"dolibarr_src/.git"
]
;
then
if
[
-d
"dolibarr_src/.git"
]
;
then
cd
dolibarr_src
||
exit
cd
dolibarr_src
||
exit
GREEN
=
'\033[0;32m'
YELLOW
=
'\033[1;33m'
RED
=
'\033[0;31m'
NC
=
'\033[0m'
branch
=
$(
git rev-parse
--abbrev-ref
HEAD 2>/dev/null
)
branch
=
$(
git rev-parse
--abbrev-ref
HEAD 2>/dev/null
)
upstream
=
$(
git rev-parse
--abbrev-ref
--symbolic-full-name
"@{u}"
2>/dev/null
)
upstream
=
$(
git rev-parse
--abbrev-ref
--symbolic-full-name
"@{u}"
2>/dev/null
)
...
@@ -166,9 +88,9 @@ case $action in
...
@@ -166,9 +88,9 @@ case $action in
behind
=
$(
git rev-list
--count
HEAD..
"
$upstream
"
2>/dev/null
)
behind
=
$(
git rev-list
--count
HEAD..
"
$upstream
"
2>/dev/null
)
if
[
"
$behind
"
-gt
0
]
;
then
if
[
"
$behind
"
-gt
0
]
;
then
status
=
"
${
YELLOW
}
Pull needed
${
NC
}
"
status
=
"
${
YELLOW
}
NOT UP TO DATE
${
NC
}
"
else
else
status
=
"
${
GREEN
}
U
p to date
${
NC
}
"
status
=
"
${
GREEN
}
U
P TO DATE
${
NC
}
"
fi
fi
fi
fi
...
@@ -179,24 +101,24 @@ case $action in
...
@@ -179,24 +101,24 @@ case $action in
echo
"Dolibarr source directory is not a Git repository."
echo
"Dolibarr source directory is not a Git repository."
fi
fi
## Modules
## Modules
BASE_DIR
=
"dolibarr_src/htdocs/custom"
BASE_DIR
=
"dolibarr_src/htdocs/custom"
if
[
-d
"
$BASE_DIR
"
]
;
then
if
[
-d
"
$BASE_DIR
"
]
;
then
echo
-e
"
\n
Custom modules directory:
$BASE_DIR
\n
"
echo
-e
"
\n
Custom modules directory:
$BASE_DIR
\n
"
echo
"Modules in custom directory:"
echo
"Modules in custom directory:"
printf
"%-
45
s | %-
20
s | %-1
2
s | %-
10
s | %s
\n
"
"Module"
"Git Branch"
"Last Commit"
"Commit ID"
"Up to date"
printf
"%-
30
s | %-
15
s | %-1
1
s | %-
9
s | %s
\n
"
"Module"
"Git Branch"
"Last Commit"
"Commit ID"
"Up to date"
printf
"%-
45
s-+-%-
20
s-+-%-1
2
s-+-%-
10
s-+-%s
\n
"
\
printf
"%-
30
s-+-%-
15
s-+-%-1
1
s-+-%-
9
s-+-%s
\n
"
\
"
$(
printf
'%.0s-'
{
1..
45
}
)
"
"
$(
printf
'%.0s-'
{
1..
20
}
)
"
\
"
$(
printf
'%.0s-'
{
1..
30
}
)
"
"
$(
printf
'%.0s-'
{
1..
15
}
)
"
\
"
$(
printf
'%.0s-'
{
1..1
2
}
)
"
"
$(
printf
'%.0s-'
{
1..
10
}
)
"
"
$(
printf
'%.0s-'
{
1..6
}
)
"
"
$(
printf
'%.0s-'
{
1..1
1
}
)
"
"
$(
printf
'%.0s-'
{
1..
9
}
)
"
"
$(
printf
'%.0s-'
{
1..6
}
)
"
find
"
$BASE_DIR
"
-maxdepth
1
-mindepth
1
-type
d
!
-name
'.*'
|
sort
|
while
read
-r
dir
;
do
find
"
$BASE_DIR
"
-maxdepth
1
-mindepth
1
-type
d
!
-name
'.*'
|
sort
|
while
read
-r
dir
;
do
module_name
=
$(
basename
"
$dir
"
)
module_name
=
$(
basename
"
$dir
"
)
module_name_short
=
$(
printf
"%-30.30s"
"
$module_name
"
)
if
[
-d
"
$dir
/.git"
]
;
then
if
[
-d
"
$dir
/.git"
]
;
then
branch
=
$(
git
-C
"
$dir
"
rev-parse
--abbrev-ref
HEAD 2>/dev/null
)
branch
=
$(
git
-C
"
$dir
"
rev-parse
--abbrev-ref
HEAD 2>/dev/null
)
branch
=
${
branch
:-
"—"
}
branch
=
${
branch
:-
"—"
}
branch_short
=
$(
printf
"%-
20.20
s"
"
$branch
"
)
branch_short
=
$(
printf
"%-
15.15
s"
"
$branch
"
)
commit_date
=
$(
git
-C
"
$dir
"
log
-1
--format
=
"%cd"
--date
=
short 2>/dev/null
)
commit_date
=
$(
git
-C
"
$dir
"
log
-1
--format
=
"%cd"
--date
=
short 2>/dev/null
)
commit_date
=
${
commit_date
:-
"—"
}
commit_date
=
${
commit_date
:-
"—"
}
...
@@ -209,28 +131,113 @@ case $action in
...
@@ -209,28 +131,113 @@ case $action in
git
-C
"
$dir
"
fetch
--quiet
2>/dev/null
git
-C
"
$dir
"
fetch
--quiet
2>/dev/null
behind
=
$(
git
-C
"
$dir
"
rev-list
--count
HEAD..
"
$upstream
"
2>/dev/null
)
behind
=
$(
git
-C
"
$dir
"
rev-list
--count
HEAD..
"
$upstream
"
2>/dev/null
)
if
[
"
$behind
"
-gt
0
]
;
then
if
[
"
$behind
"
-gt
0
]
;
then
pull_status
=
"
${
YELLOW
}
Pull needed
${
NC
}
"
pull_status
=
"
${
YELLOW
}
NOT UP TO DATE
${
NC
}
"
else
else
pull_status
=
"
${
GREEN
}
U
p to date
${
NC
}
"
pull_status
=
"
${
GREEN
}
U
P TO DATE
${
NC
}
"
fi
fi
else
else
pull_status
=
"
${
RED
}
N
o upstream
${
NC
}
"
pull_status
=
"
${
RED
}
N
O UPSTREAM
${
NC
}
"
fi
fi
printf
"%-
45
s | %-
20
s | %-1
2
s | %-
10
s | %b
\n
"
\
printf
"%-
30
s | %-
15
s | %-1
1
s | %-
9
s | %b
\n
"
\
"
$module_name
"
"
$branch_short
"
"
$commit_date
"
"
$commit_id
"
"
$pull_status
"
"
$module_name
_short
"
"
$branch_short
"
"
$commit_date
"
"
$commit_id
"
"
$pull_status
"
else
else
printf
"%-
45
s | %-
20
s | %-1
2
s | %-
10
s | %b
\n
"
\
printf
"%-
30
s | %-
15
s | %-1
1
s | %-
9
s | %b
\n
"
\
"
$module_name
"
"-"
"-"
"-"
"
${
RED
}
N
ot a Git repo
${
NC
}
"
"
$module_name
_short
"
"-"
"-"
"-"
"
${
RED
}
N
OT A GIT REPO
${
NC
}
"
fi
fi
done
done
else
else
echo
"❌ Custom modules directory not found:
$BASE_DIR
"
echo
"
${
RED
}
ERROR : Custom modules directory not found:
$BASE_DIR
"
fi
}
usage
()
{
echo
-e
"Usage
$0
<command> [args]
\n
"
echo
-e
"COMMANDS
\n
"
echo
"bash"
echo
-e
"
\t
opens 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
"info"
echo
-e
"
\t
displays information about your Dolibarr instance"
echo
"info_export"
echo
-e
"
\t
displays information about your Dolibarr instance and export to file"
echo
"logs"
echo
-e
"
\t
Follow all useful logs"
echo
"logs <term1> <term2> ..."
echo
-e
"
\t
Follow all useful logs and highlight terms"
echo
"mysql"
echo
-e
"
\t
pen a mysql prompt in Dolibarr database"
echo
"mysql_dump"
echo
-e
"
\t
creates a database dump"
echo
"mysql_init"
echo
-e
"
\t
populate Dolibarr database (Docker only)"
echo
"mysql_restore"
echo
-e
"
\t
restores database from a dump"
echo
"perms"
echo
-e
"
\t
sets default files permissions"
echo
"restart"
echo
-e
"
\t
restart the docker stack or apache2"
echo
"shell"
echo
-e
"
\t
run a php shell, same as
$0
artisan tinker"
echo
"up"
echo
-e
"
\t
starts the docker stack"
echo
"tags"
echo
-e
"
\t
generate ctags"
echo
"fail2ban"
echo
-e
"
\t
root only - put fail2ban jail and filter in good directory with good log path"
}
if
[
"
$(
is_docker
)
"
-eq
1
]
;
then
if
[
-z
"
$(
which docker-compose
)
"
]
;
then
compose
=
"docker compose"
else
compose
=
"docker-compose"
fi
cmd
=
"
$compose
exec
$APP_SERVICE
"
cmdmy
=
"
$compose
exec
$DB_SERVICE
"
cmdmyInput
=
"docker exec -i
$(
$compose
ps
-q
$DB_SERVICE
)
"
cmdrestart
=
"
$compose
restart"
cmdup
=
"
$compose
up"
cmddown
=
"
$compose
down"
else
cmdrestart
=
"apache2ctl restart"
fi
fi
if
[
!
-z
"
$(
which ccze
)
"
]
;
then
reader
=
"ccze -A"
else
reader
=
"tee"
fi
pass
=
$(
get_conf_val main_db_pass
)
mysql
=
"mariadb -u
$user
$db
-p
$pass
"
DIR
=
"
$(
dirname
$0
)
"
action
=
$1
shift
# Keep actions sorted
case
$action
in
"bash"
)
$cmd
bash
;;
"down"
)
$cmddown
;;
"help"
)
usage
;;
"info"
)
info
;;
"info_export"
)
# Run info command and export to file with date
current_date
=
$(
date
+%Y%m%d_%H%M%S
)
info
>
"dolibarr_info_
${
current_date
}
.txt"
echo
"Dolibarr info exported to dolibarr_info_
${
current_date
}
.txt"
;;
;;
"logs"
)
"logs"
)
set
-x
set
-x
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment