forked from frappe/frappe_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbench
More file actions
executable file
·61 lines (59 loc) · 2.31 KB
/
dbench
File metadata and controls
executable file
·61 lines (59 loc) · 2.31 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
#!/bin/bash
function run () {
user=$1
shift
docker exec -itu "${user}" frappe bash -c "$@"
}
if [[ $# -eq 0 ]]; then
docker exec -it frappe bash
elif [[ "$1" == 'init' ]]; then
run root "chown -R frappe:frappe /home/frappe"
run frappe "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
run frappe "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb"
elif [[ "$1" == 'setup' ]]; then
if [[ "$2" == 'docker' ]]; then
if [[ "$3" == '--swarm-mode' ]]; then
echo "Docker swarm mode is not currently supported"
elif [[ "$3" == 'down' ]]; then
docker-compose down
elif [[ "$3" == 'stop' ]]; then
docker-compose stop
else
docker-compose up -d
fi
elif [[ "$2" == 'hosts' ]]; then
a=$(run frappe "ls sites/*/site_config.json | grep -o '/.\+/'")
a="${a//$'\n'/ }"
a=$(echo "$a" | tr -d / )
result="127.0.0.1 ${a}"
run root "echo ${result} | tee -a /etc/hosts"
else
IFS=" "
run frappe "bench $*"
fi
elif [[ "$1" == '-c' ]]; then
shift
user=$1
shift
run "$user" "$@"
elif [[ "$1" == '-h' ]]; then
echo "$0 [-h] | [-c frappe|root command] | [setup hosts|docker [stop|down]] | [bench_command]"
echo ""
echo "$0 is a wrapper for the Frappe Bench tool, and is used like it. However, it extends the tool in a few places."
echo "Usage:"
echo " $0 -h"
echo " Shows this help message"
echo " $0"
echo " Launches you into an interactive shell in the container as user frappe"
echo " $0 <command to send to bench>"
echo " Runs the bench command <command>, i.e. $0 new-site \"site1.local\" = bench new-site \"site1.local\""
echo " $0 setup docker [ stop | down ]"
echo " Builds and starts the docker containers using \"docker-compose up -d\""
echo " $0 setup hosts"
echo " Adds all site names to the containers hosts file"
echo " $0 -c frappe | root <command to run>"
echo " Runs a command in the container, as the selected user"
else
IFS=" "
run frappe "bench $*"
fi