Repository: frappe/frappe

Issue:
ask admin password to set on install



Discussion:

Resolving patch:
diff --git a/frappe/cli.py b/frappe/cli.py
--- a/frappe/cli.py
+++ b/frappe/cli.py
@@ -132,6 +132,7 @@ def setup_install(parser):
 		help="Make a new application with boilerplate")
 	parser.add_argument("--install", metavar="DB-NAME", nargs=1,
 		help="Install a new db")
+	parser.add_argument("--admin_password", metavar="ADMIN-PASSWD", help="Administrator password for site")
 	parser.add_argument("--root_password", metavar="ROOT-PASSWD",
 		help="MariaDB root password")
 	parser.add_argument("--sites_path", metavar="SITES_PATH", nargs=1,
@@ -323,7 +324,7 @@ def _install(db_name, root_login="root", root_password=None, source_sql=None,
 
 @cmd
 def install(db_name, root_login="root", root_password=None, source_sql=None,
-		admin_password = 'admin', force=False, site_config=None, reinstall=False, quiet=False, install_apps=None):
+		admin_password=None, force=False, site_config=None, reinstall=False, quiet=False, install_apps=None):
 	_install(db_name, root_login, root_password, source_sql, admin_password, force, site_config, reinstall, quiet, install_apps)
 	frappe.destroy()
 
diff --git a/frappe/installer.py b/frappe/installer.py
--- a/frappe/installer.py
+++ b/frappe/installer.py
@@ -16,7 +16,7 @@
 from frappe.website import render, statics
 
 def install_db(root_login="root", root_password=None, db_name=None, source_sql=None,
-	admin_password = 'admin', verbose=True, force=0, site_config=None, reinstall=False):
+	admin_password=None, verbose=True, force=0, site_config=None, reinstall=False):
 	frappe.flags.in_install_db = True
 	make_conf(db_name, site_config=site_config)
 	if reinstall:
@@ -29,7 +29,7 @@ def install_db(root_login="root", root_password=None, db_name=None, source_sql=N
 		frappe.local.session = frappe._dict({'user':'Administrator'})
 		create_database_and_user(force, verbose)
 
-	frappe.conf.admin_password = admin_password
+	frappe.conf.admin_password = frappe.conf.admin_password or admin_password
 
 	frappe.connect(db_name=db_name)
 	import_db_from_sql(source_sql, verbose)
diff --git a/frappe/utils/install.py b/frappe/utils/install.py
--- a/frappe/utils/install.py
+++ b/frappe/utils/install.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 
 import frappe
+import getpass
 
 def before_install():
 	frappe.reload_doc("core", "doctype", "docfield")
@@ -47,10 +48,25 @@ def after_install():
 
 	# update admin password
 	from frappe.auth import _update_password
-	_update_password("Administrator", frappe.conf.get("admin_password"))
+	_update_password("Administrator", get_admin_password())
 
 	frappe.db.commit()
 
+def get_admin_password():
+	def ask_admin_password():
+		admin_password = getpass.getpass("Set Administrator password: ")
+		admin_password2 = getpass.getpass("Re-enter Administrator password: ")
+		if not admin_password == admin_password2:
+			print "\nPasswords do not match"
+			return ask_admin_password()
+		return admin_password
+
+	admin_password = frappe.conf.get("admin_password")
+	if not admin_password:
+		return ask_admin_password()
+	return admin_password
+
+
 def before_tests():
 	frappe.db.sql("delete from `tabCustom Field`")
 	frappe.db.sql("delete from `tabEvent`")


Test patch:
diff --git a/test_sites/test_site/site_config.json b/test_sites/test_site/site_config.json
--- a/test_sites/test_site/site_config.json
+++ b/test_sites/test_site/site_config.json
@@ -1,5 +1,6 @@
 {
  "db_name": "test_frappe",
  "db_password": "test_frappe",
- "auto_email_id": "test@example.com"
+ "auto_email_id": "test@example.com",
+ "admin_password": "admin"
 }