-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart
More file actions
executable file
·139 lines (126 loc) · 3.67 KB
/
Copy pathstart
File metadata and controls
executable file
·139 lines (126 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
MYDIR="$(cd "$(dirname "$0")"; pwd)"
source "$MYDIR/config/shared_env" || exit 1
source "$MYDIR/src/functions.sh" || exit 1
source "$MYDIR/config/moodle.conf" || exit 1
SOPTS=rbDjK0a:dkn
LOPTS=help,build,remove,nuke,archive:,debug,no-cache,detach,stop,none
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
build=
build_args=()
remove=
nuke=
archive=
action=up
action_options=()
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
--help)
echo "\
$MYNAME: lancer moodle-dev
USAGE
$MYNAME [options...]
OPTIONS
-r, -b, --build
-D, --debug
-j, --no-cache
(re)construire l'image avant de lancer les containers
-K, --remove
supprimer les volumes et la configuration pour redémarrer à zéro
-0, --nuke
supprimer aussi le répertoire install/moodle
-a, --archive ARCHIVE
spécifier l'archive à utiliser dans le répertoire install e.g
./$MYNAME -rK0 -a moodle-latest-501.tgz
pour forcer l'installation de la version 5.1
-d, --detach
lancer les containers en tâche de fond
-k, --stop
arrêter les containers qui tournent en tâche de fond"
exit 0
;;
-r|-b|--build) build=1;;
-D|--debug) build_args+=(--progress plain);;
-j|--no-cache) build_args+=(--no-cache);;
-K|--remove) remove=1;;
-0|--nuke) nuke=1;;
-a|--archive) shift; archive="$1";;
-d|--detach) action=up; action_options+=(--detach);;
-k|--stop) action=down;;
-n|--none) action=none;;
*) die "$1: option non configurée";;
esac
shift
done
cd "$MYDIR"
if [ -n "$remove" ]; then
docker compose down -v
if [ -n "$nuke" ]; then
rm -rf install/moodle
else
rm -f install/moodle/config.php
fi
fi
cd "$MYDIR/install"
if [ ! -d moosh ]; then
eval "files=($(ls -r moosh_*.zip 2>/dev/null))"
[ ${#files[*]} -gt 0 ] || die "Impossible de trouver l'archive moosh"
moosh="${files[0]}"
echo "... décompression de $moosh"
unzip "$moosh" || die
fi
set_supportv51=none
if [ ! -d moodle ]; then
if [ -n "$archive" ]; then
moodle="$(basename "$archive")"
[ -f "$moodle" ] || die "$archive: fichier introuvable"
else
eval "files=($(ls -r moodle-*.tgz moodle-*.zip 2>/dev/null))"
[ ${#files[*]} -gt 0 ] || die "Impossible de trouver l'archive moodle"
moodle="${files[0]}"
fi
echo "... décompression de $moodle"
case "$moodle" in
*.tgz) tar xzf "$moodle";;
*.zip) unzip "$moodle";;
esac || die
set_supportv51 "$moodle"
set_supportv51="$supportv51"
fi
source "$MYDIR/src/setup.sh" || exit 1
cd "$MYDIR"
eval "srcs=($(find -type f -name "*.in"))"
rebuild=
for src in "${srcs[@]}"; do
dest="${src%.in}"
if [ -n "$build" ]; then regen=1
elif [ ! -f "$dest" ]; then regen=1
elif [ "$src" -nt "$dest" ]; then regen=1
else regen=
fi
if [ -n "$regen" ]; then
sed <"$src" >"$dest" "
s|@@moodleroot@@|$moodleroot|
s|@@supportv51@@|$set_supportv51|"
rebuild=1
fi
done
[ -n "$rebuild" -a "$action" != none ] && build=1
if [ -n "$build" ]; then
echo "... construction des images"
if [ -n "$supportv51" ]; then
echo "INFO: support Moodle 5.1+"
else
echo "INFO: support Moodle 4.5 - 5.0 uniquement"
fi
docker compose build "${build_args[@]}" || exit 1
fi
if [ "$action" != none ]; then
case "$action" in
up) echo "... démarrage des containers";;
down) echo "... arrêt des containers";;
esac
exec docker compose "$action" "${action_options[@]}"
fi