2017-09-08 02:57:38 +00:00
|
|
|
#!/bin/bash
|
2017-10-02 04:02:03 +00:00
|
|
|
|
2017-08-28 10:11:09 +00:00
|
|
|
display_usage() {
|
|
|
|
echo "$(basename "$0") [-h] [-c \"<command to be executed inside container>\"]"
|
|
|
|
echo ''
|
|
|
|
echo 'where:'
|
2017-10-09 03:15:52 +00:00
|
|
|
echo ' -h show this help text'
|
|
|
|
echo ' -c execute a command inside docker using docker exec'
|
|
|
|
echo ' -s adds site-names to /etc/hosts file in the container to facilitate multisite access'
|
|
|
|
echo ' init initializes frappe-bench adds a new-site bench-manager.local and installs the bench_manager app
|
|
|
|
app onto it'
|
2017-08-28 10:11:09 +00:00
|
|
|
}
|
2017-10-02 04:02:03 +00:00
|
|
|
|
|
|
|
if [[ $# -eq 0 ]]; then
|
2017-08-28 10:11:09 +00:00
|
|
|
docker exec -it frappe bash
|
2017-10-09 03:15:52 +00:00
|
|
|
|
|
|
|
elif [ $1 == 'init' ]
|
|
|
|
then
|
|
|
|
docker exec -i -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
2018-02-27 09:47:40 +00:00
|
|
|
docker exec -it frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
|
2017-10-09 03:15:52 +00:00
|
|
|
docker exec -it frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
|
|
|
docker exec -it -u root frappe bash -c "apt-get install vim && apt-get install sudo && usermod -aG sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
|
|
|
docker exec -it frappe bash -c "bench set-mariadb-host mariadb"
|
2017-11-27 07:14:49 +00:00
|
|
|
docker exec -it frappe bash -c "bench new-site site1.local"
|
|
|
|
docker exec -it frappe bash -c "bench get-app erpnext"
|
|
|
|
docker exec -it frappe bash -c "bench --site site1.local install-app erpnext"
|
2017-10-09 03:15:52 +00:00
|
|
|
|
2017-10-02 04:02:03 +00:00
|
|
|
else
|
2017-09-08 02:57:38 +00:00
|
|
|
while getopts ':hsc:' option; do
|
2017-10-02 04:02:03 +00:00
|
|
|
case "$option" in
|
2017-08-28 10:11:09 +00:00
|
|
|
h)
|
|
|
|
display_usage
|
2017-10-02 04:02:03 +00:00
|
|
|
exit
|
|
|
|
;;
|
2017-08-28 10:11:09 +00:00
|
|
|
c)
|
2017-10-09 03:15:52 +00:00
|
|
|
docker exec -it frappe bash -c "bench $OPTARG"
|
2017-10-02 04:02:03 +00:00
|
|
|
;;
|
2017-09-08 02:57:38 +00:00
|
|
|
s)
|
|
|
|
a=$(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"
|
2017-10-09 03:15:52 +00:00
|
|
|
docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
2017-09-08 02:57:38 +00:00
|
|
|
;;
|
2017-08-28 10:11:09 +00:00
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
echo "Option -$OPTARG requires an argument." >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2017-10-02 04:02:03 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|