diff --git a/.travis.yml b/.travis.yml index 07c8d56c..966c2d6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/dbench b/dbench index ceb3433e..34bcd6a8 100644 --- a/dbench +++ b/dbench @@ -1,13 +1,14 @@ #!/bin/bash function usage { - echo "Usage: dbench [-hda [sitename] | --init [-ed] [sitename] | --setup ] [\"\"]" + echo "Usage: dbench [-hda [sitename] | --init [-ed] [sitename] | --setup | --start] [\"\"]" 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