added dbench start

This commit is contained in:
chabad360 2018-08-01 22:01:33 -07:00
parent e7c3b14435
commit 2be7fbb508
2 changed files with 14 additions and 1 deletions

View file

@ -21,6 +21,7 @@ before_install:
install:
- ./dbench --setup
- ./dbench --init
- ./dbench --start
- pip install --upgrade virtualenv
- virtualenv -p python3 testenv
- source testenv/bin/activate

14
dbench
View file

@ -1,13 +1,14 @@
#!/bin/bash
function usage {
echo "Usage: dbench [-hda [sitename] | --init [-ed] [sitename] | --setup ] [\"<command to be executed on bench inside container>\"]"
echo "Usage: dbench [-hda [sitename] | --init [-ed] [sitename] | --setup | --start] [\"<command to be executed on bench inside container>\"]"
echo ''
echo 'where:'
echo ' -h show this help text'
echo ' -d [sitename] enables developer mode for specified site'
echo ' -a adds site-names to /etc/hosts file in the container to facilitate multisite access'
echo ' --setup starts up and builds docker, NOTE: assumes you have docker installed'
echo ' --start starts frappe docker'
echo ' --init [-e | -d] [sitename] initializes frappe-bench in docker and adds a site "sitename" (if not specified, it will default to site1.local)'
echo ' -e initializes frappe-bench and installs erpnext'
echo ' -d initializes frappe-bench and enables developer mode'
@ -61,6 +62,17 @@ elif [ $1 == '--init' ]; then
elif [ "$1" == '--setup' ]; then
docker-compose build
docker-compose up -d
elif [ "$1" == '--start' ]; then
docker-compose start
a=$(docker exec -i frappe bash -c "cd ~/frappe-bench && ls sites/*/site_config.json" | grep -o '/.\+/')
a="${a//$'\n'/ }"
a=$(echo $a | tr -d / )
result="127.0.0.1 ${a}"
echo $result
docker exec -u root -i 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"
else
while getopts ':had:' option; do
case "$option" in