going back because of getopts

This commit is contained in:
chabad360 2018-08-02 14:51:57 -07:00
parent 0f33cfdb4f
commit 18dffdd563

42
dbench
View file

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/bash
function usage { function usage {
echo "Usage: dbench [-had [sitename] | --init [-ed] [sitename] | --setup [-d] | --start [-b] | -c \"<command to be executed on bench inside container>\"]" echo "Usage: dbench [-hda [sitename] | --init [-ed] [sitename] | --setup [-d] | --start [-b] | -c \"<command to be executed on bench inside container>\"]"
echo '' echo ''
echo 'where:' echo 'where:'
echo ' -h show this help text' echo ' -h show this help text'
echo ' -c send a command to the frappe container'
echo ' -d [sitename] enables developer mode for specified site' 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 ' -a adds site-names to /etc/hosts file in the container to facilitate multisite access'
echo ' -c send a command to the frappe container'
echo ' --setup [-d] builds docker containers, NOTE: assumes you have docker installed' echo ' --setup [-d] builds docker containers, NOTE: assumes you have docker installed'
echo ' -d start up docker containers as well' echo ' -d start up docker containers as well'
echo ' --start [-b] starts frappe docker' echo ' --start [-b] starts frappe docker'
echo ' -b starts bench as well' echo ' -b starts bench as well'
echo ' --init [-ed] [sitename] initializes frappe-bench in docker and adds a site "sitename" (if not specified, it will default to site1.local)' 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 ' -e initializes frappe-bench and installs erpnext'
echo ' -d initializes frappe-bench and enables developer mode' echo ' -d initializes frappe-bench and enables developer mode'
} }
@ -35,7 +35,7 @@ if [[ $# -eq 0 ]]; then
echo "entering container" echo "entering container"
docker exec -it frappe bash docker exec -it frappe bash
elif [ "$1" == '--init' ]; then elif [ $1 == '--init' ]; then
site=$3 site=$3
if [ -z "$3" ]; then if [ -z "$3" ]; then
site="site1.local" site="site1.local"
@ -46,25 +46,21 @@ elif [ "$1" == '--init' ]; then
site=$2 site=$2
fi fi
echo "$site" echo "$site"
frappe_installer $site frappe_installer "$site"
while getopts :ed: option; do if [ "$2" == '-e' ]; then
case "$option" in echo "installing erpnext"
e) docker exec -it frappe bash -c "bench get-app erpnext"
echo "installing erpnext" docker exec -it frappe bash -c "bench --site $site install-app erpnext"
docker exec -it frappe bash -c "bench get-app erpnext" echo "finished"
docker exec -it frappe bash -c "bench --site $site install-app erpnext" elif [ "$2" == '-d' ]; then
echo "finished" docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
;; elif [ "$2" == '-ed' ]; then
d) echo "installing erpnext"
docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache" docker exec -it frappe bash -c "bench get-app erpnext"
;; docker exec -it frappe bash -c "bench --site $site install-app erpnext"
*) docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
echo "Invalid option: -$OPTARG" >&2 echo "finished"
usage fi
exit 1
;;
esac
done
elif [ "$1" == '--setup' ]; then elif [ "$1" == '--setup' ]; then
docker-compose build docker-compose build