From 6d64401e225afe64200844eba42d6e6c8e3a41e8 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 8 Oct 2023 00:30:35 +0800 Subject: [PATCH] update --- plugins/mariadb/index.py | 7 +++++++ scripts/init.d/mw.tpl | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 20b284d1b..55111291a 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -755,6 +755,11 @@ def importDbBackup(): return mw.returnJson(True, 'ok') +def rootPwd(): + return pSqliteDb('config').where( + 'id=?', (1,)).getField('mysql_root') + + def importDbExternal(): args = getArgs() data = checkArgs(args, ['file', 'name']) @@ -2740,6 +2745,8 @@ if __name__ == "__main__": print(setMyPort()) elif func == 'init_pwd': print(initMysqlPwd()) + elif func == 'root_pwd': + print(rootPwd()) elif func == 'get_db_list': print(getDbList()) elif func == 'set_db_backup': diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index a0386a1a1..473c06dc0 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -366,11 +366,15 @@ mw_connect_mysql(){ INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]} CHOICE_DB=${DB_TYPE[$INPUT_KEY]} echo "login to ${CHOICE_DB}:" - pwd=$(python3 /www/server/mdserver-web/plugins/${CHOICE_DB}/index.py root_pwd) + pwd=$(cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/${CHOICE_DB}/index.py root_pwd) if [ "$CHOICE_DB" == "mysql" ];then ${ROOT_PATH}/mysql/bin/mysql -uroot -p"${pwd}" fi + if [ "$CHOICE_DB" == "mariadb" ];then + ${ROOT_PATH}/mariadb/bin/mysql -uroot -p"${pwd}" + fi + } case "$1" in