diff --git a/plugins/pgadmin/index.py b/plugins/pgadmin/index.py index 95f7ca092..df1d6dcfa 100755 --- a/plugins/pgadmin/index.py +++ b/plugins/pgadmin/index.py @@ -203,10 +203,16 @@ def initReplace(): setCfg('password', password) mw.writeFile(pass_path, pass_cmd) + # pg_conf = getCfg() judge_file = getServerDir()+'/data/pgadmin4/pgadmin4.db' if not os.path.exists(judge_file): pg_init_bash = getPluginDir()+'/pg_init.sh' - t = mw.execShell("bash "+pg_init_bash) + pg_rand = mw.getRandomString(8) + pg_username = "mw."+pg_rand+"@gmail.com" + setCfg('web_pg_password', pg_username) + pg_password = mw.getRandomString(10) + setCfg('web_pg_password', pg_password) + t = mw.execShell("bash "+ pg_init_bash + " " + pg_username + " " + pg_password) # print(t) # systemd diff --git a/plugins/pgadmin/pg_init.sh b/plugins/pgadmin/pg_init.sh index 4253a0c66..31c9dd6bb 100644 --- a/plugins/pgadmin/pg_init.sh +++ b/plugins/pgadmin/pg_init.sh @@ -2,6 +2,9 @@ python_ver=`ls /www/server/pgadmin/run/lib/ | grep python | cut -d \ -f 1 | awk 'END {print}'` +email=$1 +email_pwd=$2 + expect <<-EOF set time 10 spawn gunicorn --bind unix:/tmp/pgadmin4.sock \ @@ -9,9 +12,9 @@ spawn gunicorn --bind unix:/tmp/pgadmin4.sock \ --threads=25 \ --chdir /www/server/pgadmin/run/lib/${python_ver}/site-packages/pgadmin4 pgAdmin4:app expect { - "Email address:" { send "mdserver-web@gmail.com\r"; exp_continue } - "Password" { send "123123\r"; exp_continue } - "Retype password" { send "123123\r" } + "Email address:" { send "${email}\r"; exp_continue } + "Password" { send "${email_pwd}\r"; exp_continue } + "Retype password" { send "${email_pwd}\r" } } expect eof EOF