From a09316965001fdc2ebb5499098e7ec22cea2ea28 Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 24 Dec 2021 23:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=91=BD=E4=BB=A4=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BC=BA=E5=88=B6=E8=A6=86=E7=9B=96=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/command/Install.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/common/command/Install.php b/app/common/command/Install.php index a9d386c..0b41f21 100644 --- a/app/common/command/Install.php +++ b/app/common/command/Install.php @@ -25,6 +25,7 @@ class Install extends Command $this->setName('install') ->addOption('adminname', 'u', Option::VALUE_OPTIONAL, '管理员账号') ->addOption('password', 'p', Option::VALUE_OPTIONAL, '管理员密码') + ->addOption('force', 'f', Option::VALUE_OPTIONAL, '强制安装') ->setDescription('安装数据库'); $this->installLockPath = App::getRootPath() . '/config/install/lock/install.lock'; @@ -36,15 +37,18 @@ class Install extends Command { // 指令输出 - $install_lock_path = $this->installLockPath; + $force = $input->getOption('force'); - if (is_file($install_lock_path)) { - $errorInfo = '已安装系统,如需重新安装请删除文件:/config/install/lock/install.lock'; - $output->writeln($errorInfo); - return false; + if (is_null($force)) { + $install_lock_path = $this->installLockPath; + + if (is_file($install_lock_path)) { + $errorInfo = '已安装系统,如需重新安装,可以添加 -f 1 参数或删除文件:/config/install/lock/install.lock'; + $output->writeln($errorInfo); + return false; + } } - if (!$this->checkConnect()) { $output->writeln('数据库连接失败,请检查数据库配置'); }