mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-22 15:55:09 +00:00
trashing getopt found a better way
This commit is contained in:
parent
ea945b6917
commit
48e98086f3
1 changed files with 39 additions and 33 deletions
72
dbench
72
dbench
|
|
@ -1,22 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if ! options=$(getopt -o hdaceumb --long add,help,developer,setup,start,init -- "$@")
|
|
||||||
then
|
|
||||||
echo "entering container"
|
|
||||||
docker exec -it frappe bash
|
|
||||||
fi
|
|
||||||
|
|
||||||
add=0
|
|
||||||
setup=0
|
|
||||||
d=0
|
|
||||||
start=0
|
|
||||||
init=0
|
|
||||||
dev=0
|
|
||||||
erp=0
|
|
||||||
mgr=0
|
|
||||||
site=0
|
|
||||||
bench=0
|
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage: dbench [ --setup [-d] | --init [-med] [sitename] | "
|
echo "Usage: dbench [ --setup [-d] | --init [-med] [sitename] | "
|
||||||
echo ''
|
echo ''
|
||||||
|
|
@ -47,9 +30,25 @@ function frappe_installer {
|
||||||
echo "$1 added"
|
echo "$1 added"
|
||||||
}
|
}
|
||||||
|
|
||||||
eval set -- "$options"
|
|
||||||
while true; do
|
add=0
|
||||||
case "$1" in
|
setup=0
|
||||||
|
d=0
|
||||||
|
start=0
|
||||||
|
init=0
|
||||||
|
dev=0
|
||||||
|
erp=0
|
||||||
|
mgr=0
|
||||||
|
site=0
|
||||||
|
bench=0
|
||||||
|
cmd=0
|
||||||
|
|
||||||
|
positional=()
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case "key" in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -58,13 +57,10 @@ while true; do
|
||||||
add=1
|
add=1
|
||||||
;;
|
;;
|
||||||
-d | --developer)
|
-d | --developer)
|
||||||
shift; # The arg is next in position args
|
|
||||||
dev=1
|
dev=1
|
||||||
site="$1"
|
|
||||||
;;
|
;;
|
||||||
-c)
|
-c)
|
||||||
shift
|
cmd=1
|
||||||
docker exec -it frappe bash -c "bench $*"
|
|
||||||
;;
|
;;
|
||||||
-u)
|
-u)
|
||||||
d=1
|
d=1
|
||||||
|
|
@ -84,16 +80,14 @@ while true; do
|
||||||
--start)
|
--start)
|
||||||
start=1
|
start=1
|
||||||
;;
|
;;
|
||||||
--)
|
*)
|
||||||
break
|
positional+="$key"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
set -- "${POSITIONAL[@]}"
|
||||||
if [ $site == "" ]; then
|
site="$1"
|
||||||
site=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $setup == 1 ]; then
|
if [ $setup == 1 ]; then
|
||||||
docker-compose build
|
docker-compose build
|
||||||
|
|
@ -106,9 +100,6 @@ if [ $setup == 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $init == 1 ]; then
|
if [ $init == 1 ]; then
|
||||||
if [ "$site" == 0 ] || [ "$site" == "" ]; then
|
|
||||||
site="site1.local"
|
|
||||||
fi
|
|
||||||
|
|
||||||
frappe_installer $site
|
frappe_installer $site
|
||||||
|
|
||||||
|
|
@ -152,4 +143,19 @@ if [ $d == 1 ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $cmd == 1 ]; then
|
||||||
|
docker exec -it frappe bash -c "bench $*"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $add == 1 ]; then
|
||||||
|
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"
|
||||||
|
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
Loading…
Reference in a new issue