From 891592e04e6198976871594f24d1b4a37b669ce4 Mon Sep 17 00:00:00 2001 From: cubic Date: Wed, 12 Jan 2022 09:52:50 +0800 Subject: [PATCH] fix(Deploy Script): fix setting bugs --- env.template.yaml | 1 + git-storage/hooks/main | 17 ++++++++++++----- misc/install.sh | 4 ---- misc/modify_authorized_keys.php | 2 +- misc/php.ini-template | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/env.template.yaml b/env.template.yaml index 9092056..c47a3f6 100755 --- a/env.template.yaml +++ b/env.template.yaml @@ -40,5 +40,6 @@ users: # gateway gateway: token: + hooks: http://127.0.0.1/apiv1/internal/hooks authHTTP: http://127.0.0.1/apiv1/internal/authHTTP authSSH: http://127.0.0.1/apiv1/internal/authSSH diff --git a/git-storage/hooks/main b/git-storage/hooks/main index 477951d..c693f76 100755 --- a/git-storage/hooks/main +++ b/git-storage/hooks/main @@ -9,10 +9,17 @@ if (!$action) { exit(255); } -$config = [ - 'endpoint' => 'http://cc.pgyer.appxia.cn/apiv1/internal/hooks', - 'token' => 'codefever_community_api_token' -]; +$config = yaml_parse_file(dirname(__FILE__, 4) . '/env.yaml'); + +if ($config['gateway'] && $config['gateway']['token'] && $config['gateway']['hooks']) { + $config = [ + 'endpoint' => $config['gateway']['hooks'], + 'token' => $config['gateway']['token'] + ]; +} else { + echo '[CodeFever Community]: Bad configuration, Contact site administrator if operation rejected!.'; + exit(255); +} $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $config['endpoint']); @@ -54,7 +61,7 @@ if ($result) { echo 'Request-ID: ' . $result['request-id'] . "\n"; } } else { - echo 'Contact service@pgyer.com if operation rejected!'; + echo 'Contact site administrator if operation rejected!'; } exit(255); diff --git a/misc/install.sh b/misc/install.sh index 4d354ef..2435a36 100644 --- a/misc/install.sh +++ b/misc/install.sh @@ -56,10 +56,6 @@ cd - echo 'Composer libraries loaded!' -echo 'export PATH=$PATH:/usr/local/git/bin' >> /home/git/.bash_profile - -echo 'Enviroment variable set!' - service codefever start service php-fpm start service nginx start diff --git a/misc/modify_authorized_keys.php b/misc/modify_authorized_keys.php index fca6328..4575336 100755 --- a/misc/modify_authorized_keys.php +++ b/misc/modify_authorized_keys.php @@ -111,7 +111,7 @@ function addAuthorizedKey(array $data) $sshGateway = dirname(BASE_PATH) . '/ssh-gateway/shell/main'; $authorized = [ - "command=\"{$sshGateway} \$SSH_ORIGINAL_COMMAND {$data['user']}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty", + "command=\"PATH=\$PATH:/usr/local/git/bin && {$sshGateway} \$SSH_ORIGINAL_COMMAND {$data['user']}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty", $data['type'], $data['key'], $data['name'], diff --git a/misc/php.ini-template b/misc/php.ini-template index 9ddf516..29b7d87 100644 --- a/misc/php.ini-template +++ b/misc/php.ini-template @@ -911,7 +911,7 @@ default_socket_timeout = 60 ; Be sure to appropriately set the extension_dir directive. ; ;extension=bz2 -;extension=curl +extension=curl ;extension=ffi ;extension=ftp ;extension=fileinfo