From 9097cf2d4235eed4830c19c8dc82fcf11b7599bf Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 12 May 2021 13:57:33 +0545 Subject: [PATCH 1/4] unattended installl --- app/tasks/install.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index b1b882a215..db858743eb 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -8,11 +8,15 @@ use Utopia\Analytics\GoogleAnalytics; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\View; +use Utopia\Validator\Text; $cli ->task('install') ->desc('Install Appwrite') - ->action(function () { + ->param('httpPort', '', new Text(4), 'Server HTTP port', true) + ->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) + ->param('unattended','N', new Text(1), 'A secure encryption key, make sure to make a backup of your key in a secure location') + ->action(function ($httpPort, $httpsPort, $unattended) { /** * 1. Start - DONE * 2. Check for older setup and get older version - DONE @@ -108,16 +112,20 @@ $cli } } - $httpPort = Console::confirm('Choose your server HTTP port: (default: '.$defaultHTTPPort.')'); - $httpPort = ($httpPort) ? $httpPort : $defaultHTTPPort; + if(empty($httpPort)) { + $httpPort = Console::confirm('Choose your server HTTP port: (default: '.$defaultHTTPPort.')'); + $httpPort = ($httpPort) ? $httpPort : $defaultHTTPPort; + } - $httpsPort = Console::confirm('Choose your server HTTPS port: (default: '.$defaultHTTPSPort.')'); - $httpsPort = ($httpsPort) ? $httpsPort : $defaultHTTPSPort; + if(empty($httpsPort)) { + $httpsPort = Console::confirm('Choose your server HTTPS port: (default: '.$defaultHTTPSPort.')'); + $httpsPort = ($httpsPort) ? $httpsPort : $defaultHTTPSPort; + } $input = []; foreach($vars as $key => $var) { - if(!$var['required']) { + if(!$var['required'] || $unattended === 'Y') { $input[$var['name']] = $var['default']; continue; } From d198977e5da8342a3b4f0429b5935f2af1e40fa5 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 12 May 2021 16:39:14 +0545 Subject: [PATCH 2/4] check interactive with a param --- app/tasks/install.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index db858743eb..34cd6c4dfa 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -15,8 +15,8 @@ $cli ->desc('Install Appwrite') ->param('httpPort', '', new Text(4), 'Server HTTP port', true) ->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) - ->param('unattended','N', new Text(1), 'A secure encryption key, make sure to make a backup of your key in a secure location') - ->action(function ($httpPort, $httpsPort, $unattended) { + ->param('interactive','Y', new Text(1), 'A secure encryption key, make sure to make a backup of your key in a secure location') + ->action(function ($httpPort, $httpsPort, $interactive) { /** * 1. Start - DONE * 2. Check for older setup and get older version - DONE @@ -125,7 +125,7 @@ $cli $input = []; foreach($vars as $key => $var) { - if(!$var['required'] || $unattended === 'Y') { + if(!$var['required'] || !Console::isInteractive() || $interactive !== 'Y') { $input[$var['name']] = $var['default']; continue; } From bb39d90da6099d6895142df5f34018e09c48c033 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 14 May 2021 11:43:45 +0545 Subject: [PATCH 3/4] updating description for param --- app/tasks/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index 34cd6c4dfa..cb70e090e6 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -15,7 +15,7 @@ $cli ->desc('Install Appwrite') ->param('httpPort', '', new Text(4), 'Server HTTP port', true) ->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) - ->param('interactive','Y', new Text(1), 'A secure encryption key, make sure to make a backup of your key in a secure location') + ->param('interactive','Y', new Text(1), 'Run a interactive session', true) ->action(function ($httpPort, $httpsPort, $interactive) { /** * 1. Start - DONE From 52dc0a9f17e4bf1ddb46477a0a8069d3279d6b2a Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Fri, 14 May 2021 09:58:18 +0300 Subject: [PATCH 4/4] Update app/tasks/install.php --- app/tasks/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index cb70e090e6..e2d141f6e4 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -15,7 +15,7 @@ $cli ->desc('Install Appwrite') ->param('httpPort', '', new Text(4), 'Server HTTP port', true) ->param('httpsPort', '', new Text(4), 'Server HTTPS port', true) - ->param('interactive','Y', new Text(1), 'Run a interactive session', true) + ->param('interactive','Y', new Text(1), 'Run an interactive session', true) ->action(function ($httpPort, $httpsPort, $interactive) { /** * 1. Start - DONE