2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

pass admin-password and root password to new-site

This commit is contained in:
Pratik Vyas 2014-10-22 12:15:41 +05:30
parent 9cc8e0c432
commit 736d14f988
3 changed files with 31 additions and 12 deletions

View File

@ -83,10 +83,12 @@ def new_app(app_name):
_new_app(app_name) _new_app(app_name)
@click.command('new-site') @click.command('new-site')
@click.option('--mariadb-root-password', help="MariaDB root password")
@click.option('--admin-password', help="admin password to set for site")
@click.argument('site') @click.argument('site')
def new_site(site): def new_site(site, mariadb_root_password=None, admin_password=None):
"Create a new site in the bench" "Create a new site in the bench"
_new_site(site) _new_site(site, mariadb_root_password=mariadb_root_password, admin_password=admin_password)
#TODO: Not DRY #TODO: Not DRY
@click.command('update') @click.command('update')

View File

@ -71,9 +71,16 @@ def setup_procfile(bench='.'):
worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker' worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker'
workerbeat: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app beat -s scheduler.schedule'""") workerbeat: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app beat -s scheduler.schedule'""")
def new_site(site, bench='.'): def new_site(site, mariadb_root_password=None, admin_password=None, bench='.'):
logger.info('creating new site {}'.format(site)) logger.info('creating new site {}'.format(site))
exec_cmd("{frappe} --install {site} {site}".format(frappe=get_frappe(bench=bench), site=site), cwd=os.path.join(bench, 'sites')) mariadb_root_password_fragment = '--root_password {}'.format(mariadb_root_password) if mariadb_root_password else ''
admin_password_fragment = '--admin_password {}'.format(admin_password) if admin_password else ''
exec_cmd("{frappe} --install {site} {site} {mariadb_root_password_fragment} {admin_password_fragment}".format(
frappe=get_frappe(bench=bench),
site=site,
mariadb_root_password_fragment=mariadb_root_password_fragment,
admin_password_fragment=admin_password_fragment
), cwd=os.path.join(bench, 'sites'))
if len(get_sites(bench=bench)) == 1: if len(get_sites(bench=bench)) == 1:
exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench=bench), site=site), cwd=os.path.join(bench, 'sites')) exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench=bench), site=site), cwd=os.path.join(bench, 'sites'))

View File

@ -179,18 +179,26 @@ install_supervisor_centos6() {
### config ### config
get_mariadb_password() { get_mariadb_password() {
get_password "MariaDB root" MSQ_PASS
}
get_site_admin_password() {
get_password "Admin password" ADMIN_PASS
}
get_password() {
if [ -z "$MSQ_PASS" ]; then if [ -z "$MSQ_PASS" ]; then
read -t 1 -n 10000 discard || true read -t 1 -n 10000 discard || true
echo echo
read -p "Enter mysql root password to set:" -s MSQ_PASS1 read -p "Enter $1 password to set:" -s TMP_PASS1
echo echo
read -p "Re enter mysql root password to set:" -s MSQ_PASS2 read -p "Re enter $1 password to set:" -s TMP_PASS2
echo echo
if [ $MSQ_PASS1 == $MSQ_PASS2 ]; then if [ $TMP_PASS1 == $TMP_PASS2 ]; then
export MSQ_PASS=$MSQ_PASS1 export $2=$TMp_PASS1
else else
echo Passwords do not match echo Passwords do not match
get_mariadb_password get_password $1 $2
fi fi
fi fi
} }
@ -260,9 +268,11 @@ install_bench() {
setup_bench() { setup_bench() {
echo Installing frappe-bench echo Installing frappe-bench
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && bench init frappe-bench --apps_path https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json" run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && bench init frappe-bench --apps_path https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json"
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench new-site site1.local" echo Setting up first site
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app erpnext" get_site_admin_password
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app shopping_cart" run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench new-site site1.local --root-password $MSQ_PASS --admin_password $ADMIN_PASS"
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app erpnext"
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app shopping_cart"
} }
add_user() { add_user() {