From 1e4db0be56e5bddf1fc1e158b3e0915bc57cfcee Mon Sep 17 00:00:00 2001 From: BrettonYe <867057410@qq.com> Date: Tue, 20 Jun 2023 00:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=89=E8=A3=85=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E9=94=99=E8=AF=AF=E6=97=B6=E7=9A=84=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/PanelInstallation.php | 7 +++++- install.sh | 27 ++++++++++------------ update.sh | 8 ++----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/app/Console/Commands/PanelInstallation.php b/app/Console/Commands/PanelInstallation.php index 1253e657..3712d9f4 100644 --- a/app/Console/Commands/PanelInstallation.php +++ b/app/Console/Commands/PanelInstallation.php @@ -67,7 +67,12 @@ class PanelInstallation extends Command // 初始化数据库 $this->line(' 导入数据库'); - Artisan::call('migrate --seed'); + try { + Artisan::call('migrate --seed'); + } catch (Exception $e) { + Artisan::call('db:wipe'); + abort(500, '导入数据库失败'.$e->getMessage()); + } $this->info('数据库导入完成'); $bar->advance(); diff --git a/install.sh b/install.sh index 6116faca..b190d4a9 100644 --- a/install.sh +++ b/install.sh @@ -55,13 +55,9 @@ check_sys() { #检查composer是否安装 check_composer() { if [ ! -f "/usr/bin/composer" ]; then - if [[ "${release}" == "centos" ]]; then - yum install -y composer - else - apt-get install -y composer - fi + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer else - if [[ $(composer --version | cut -d" " -f3) < 2.2.0 ]]; then + if [[ $(composer -n --version --no-ansi | cut -d" " -f3) < 2.2.0 ]]; then composer self-update fi fi @@ -98,15 +94,16 @@ set_horizon() { if [ ! -f /etc/supervisor/conf.d/horizon.conf ]; then echo " - [program:horizon] - process_name=%(program_name)s - command=php $PWD/artisan horizon - autostart=true - autorestart=true - user=www - redirect_stderr=true - stdout_logfile=$PWD/storage/logs/horizon.log - stopwaitsecs=3600" >>/etc/supervisor/conf.d/horizon.conf + [program:horizon] + process_name=%(program_name)s + command=php $PWD/artisan horizon + autostart=true + autorestart=true + user=www + redirect_stderr=true + stdout_logfile=$PWD/storage/logs/horizon.log + stopwaitsecs=3600" >>/etc/supervisor/conf.d/horizon.conf + supervisorctl reread supervisorctl update supervisorctl start horizon diff --git a/update.sh b/update.sh index 8fc6f89f..a434fa28 100644 --- a/update.sh +++ b/update.sh @@ -21,13 +21,9 @@ check_sys() { #检查composer是否安装 check_composer() { if [ ! -f "/usr/bin/composer" ]; then - if [[ "${release}" == "centos" ]]; then - yum install -y composer - else - apt-get install -y composer - fi + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer else - if [[ $(composer --version | cut -d" " -f3) < 2.2.0 ]]; then + if [[ $(composer -n --version --no-ansi | cut -d" " -f3) < 2.2.0 ]]; then composer self-update fi fi