2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-22 20:19:01 +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)
@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')
def new_site(site):
def new_site(site, mariadb_root_password=None, admin_password=None):
"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
@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'
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))
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:
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
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
read -t 1 -n 10000 discard || true
echo
read -p "Enter mysql root password to set:" -s MSQ_PASS1
read -p "Enter $1 password to set:" -s TMP_PASS1
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
if [ $MSQ_PASS1 == $MSQ_PASS2 ]; then
export MSQ_PASS=$MSQ_PASS1
if [ $TMP_PASS1 == $TMP_PASS2 ]; then
export $2=$TMp_PASS1
else
echo Passwords do not match
get_mariadb_password
get_password $1 $2
fi
fi
}
@ -260,9 +268,11 @@ install_bench() {
setup_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"
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench new-site site1.local"
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app erpnext"
sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app shopping_cart"
echo Setting up first site
get_site_admin_password
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() {