added help to dbench, and updated readme

This commit is contained in:
chabad360 2018-10-05 22:05:26 +00:00 committed by Mendel Greenberg
parent 0618f89c5c
commit ac6756c30a
No known key found for this signature in database
GPG key ID: B26A7D2DF7DC6EF7
2 changed files with 29 additions and 16 deletions

View file

@ -94,7 +94,7 @@ Express dependency between services, which has two effects:
It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones
the bench-repo from [here](https://github.com/frappe/bench) the bench-repo from [here](https://github.com/frappe/bench)
docker-compose up -d ./dbench setup docker
Note: Please do not remove the bench-repo directory the above commands will create Note: Please do not remove the bench-repo directory the above commands will create
@ -106,19 +106,15 @@ Express dependency between services, which has two effects:
./dbench init ./dbench init
2. Command to start all the containers 2. Command to be executed everytime after starting your containers
docker-compose start ./dbench setup hosts
3. Command to be executed everytime after starting your containers 3. Command to enter your container
./dbench -s ./dbench
4. Command to enter your container 4. All bench commands can also be directly run from the host machine by using dbench. For instance ```bench start``` can be executed by running ```./dbench start```. Just preface the option with **`./dbench`**. For more information on dbench run the command ```./dbench -h```.
docker exec -it frappe bash
5. All bench commands can also be directly run from the host machine by using dbench. For instance ```bench start``` can be executed by running ```./dbench -c start```. Just preface the option with <b>./dbench -c</b>. For more information on dbench run the command ```./dbench -h```.
For more info on how to build this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image) For more info on how to build this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image)

21
dbench
View file

@ -4,7 +4,7 @@ if [[ $# -eq 0 ]]; then
docker exec -it frappe bash docker exec -it frappe bash
elif [ "$1" == 'init' ]; then elif [ "$1" == 'init' ]; then
docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation" docker exec -i frappe bash -c "cd .. && bench init $2 --ignore-exist --skip-redis-config-generation"
docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" docker exec -i frappe bash -c "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 elif [ "$1" == 'setup' ]; then
if [ "$2" == 'docker' ]; then if [ "$2" == 'docker' ]; then
@ -18,7 +18,7 @@ elif [ "$1" == 'setup' ]; then
a="${a//$'\n'/ }" a="${a//$'\n'/ }"
a=$(echo $a | tr -d / ) a=$(echo $a | tr -d / )
result="127.0.0.1 ${a}" result="127.0.0.1 ${a}"
sudo echo $result >> /etc/hosts echo $result | sudo tee -a /etc/hosts
docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts"
docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
fi fi
@ -27,6 +27,23 @@ elif [ "$1" == '-c' ]; then
user=$1 user=$1
shift shift
docker exec -iu "$user" frappe bash -c "$@" docker exec -iu "$user" frappe bash -c "$@"
elif [ "$1" == '-h' ]; then
echo "$0 [-h] | [ -c frappe | root <command to run in frappe container, under selceted user> ] [ command to send to bench ]"
echo ""
echo "$0 extends the Frappe Bench tool, and is used like it. However, it extends the tool in a few places."
echo "Usage:"
echo " $0"
echo " Launches you into an interactive shell in the container as user frappe"
echo " $0 init [bench folder name]"
echo " Runs \"bench init\" along with some other commands"
echo " $0 setup docker"
echo " starts docker using \"docker-compose up -d\""
echo " $0 setup hosts"
echo " adds all sites to the hosts file, run with sudo"
echo " $0 -c frappe | root <command to run>"
echo " Runs a command in the container, as the selected user"
echo " $0 [ command to send to bench ]"
echo " Runs a command in bench, i.e. $0 new-site site1.local = bench new-site site1.local"
else else
IFS=" " IFS=" "
docker exec -it frappe bash -c "bench $*" docker exec -it frappe bash -c "bench $*"