@@ -61,6 +61,7 @@ public function __construct($name, $structureTemplate)
61
61
->addOption ('scheduler-locks-path ' , null , InputOption::VALUE_OPTIONAL , 'Path to scheduler-locks repository ' , __DIR__ . '/../../../../../tmp/locks ' )
62
62
->addOption ('worker-tmp-files ' , null , InputOption::VALUE_OPTIONAL , 'Path to worker-tmp-files repository ' , __DIR__ . '/../../../../../tmp ' )
63
63
->addOption ('yes ' , 'y ' , InputOption::VALUE_NONE , 'Answer yes to all questions ' )
64
+ ->addOption ('force ' , 'f ' , InputOption::VALUE_NONE , 'force to continue installation ' )
64
65
->setHelp ("Phraseanet can only be installed on 64 bits PHP. " );
65
66
;
66
67
@@ -93,32 +94,9 @@ protected function doExecute(InputInterface $input, OutputInterface $output)
93
94
/** @var DialogHelper $dialog */
94
95
$ dialog = $ this ->getHelperSet ()->get ('dialog ' );
95
96
96
- $ output ->writeln ("<comment>
97
- ,-._.-._.-._.-._.-.
98
- `-. ,-'
99
- .----------------------------------------------. | |
100
- | | | |
101
- | Hello ! | | |
102
- | | | |
103
- | You are on your way to install Phraseanet, | ,'; \".________.-.
104
- | You will need access to 2 MySQL databases. | ;';_' )]
105
- | | ; `-|
106
- | `. `T- |
107
- `----------------------------------------------._ \ | |
108
- `-; | |
109
- |..________..-|
110
- /\/ |________..|
111
- ,'`./ >,( |
112
- \_.-|_/,-/ ii | |
113
- `. \"' `-/ .- \"\"\"|| |
114
- /`^ \"-; | ||____|
115
- / / `.__/ | ||
116
- / | ||
117
- | ||
118
- </comment> "
119
- );
120
-
121
- if (!$ input ->getOption ('yes ' ) && !$ input ->getOption ('appbox ' )) {
97
+ $ output ->writeln ("<comment> --- You are on your way to install Phraseanet, You will need access to 2 MySQL databases. --- </comment> " );
98
+
99
+ if (!$ input ->getOption ('yes ' ) && !$ input ->getOption ('force ' ) && !$ input ->getOption ('appbox ' )) {
122
100
$ continue = $ dialog ->askConfirmation ($ output , 'Do you have these two DB handy ? (N/y) ' , false );
123
101
124
102
if (!$ continue ) {
@@ -130,16 +108,30 @@ protected function doExecute(InputInterface $input, OutputInterface $output)
130
108
131
109
$ serverName = $ this ->getServerName ($ input , $ output , $ dialog );
132
110
111
+ /** @var Connection $abConn */
133
112
$ abConn = $ this ->getABConn ($ input , $ output , $ dialog , $ serverName );
134
113
if (!$ abConn ) {
135
114
return 1 ; // no ab is fatal
136
115
}
137
116
117
+ if (!$ input ->getOption ('force ' ) && $ abConn ->getSchemaManager ()->tablesExist (['users ' ])) {
118
+ $ output ->writeln ("<error>(*) Database table already exist in appbox! installation abort</error> " );
119
+
120
+ return 1 ;
121
+ }
122
+
138
123
list ($ dbConn , $ templateName ) = $ this ->getDBConn ($ input , $ output , $ abConn , $ dialog );
124
+
125
+ if (!$ input ->getOption ('force ' ) && $ dbConn ->getSchemaManager ()->tablesExist (['record ' ])) {
126
+ $ output ->writeln ("<error>(*) Database table already exist in databox! installation abort</error> " );
127
+
128
+ return 1 ;
129
+ }
130
+
139
131
list ($ email , $ password ) = $ this ->getCredentials ($ input , $ output , $ dialog );
140
132
$ dataPath = $ this ->getDataPath ($ input , $ output , $ dialog );
141
133
142
- if (! $ input ->getOption ('yes ' )) {
134
+ if (!$ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' )) {
143
135
$ output ->writeln ("<info>--- ElasticSearch connection settings ---</info> " );
144
136
}
145
137
@@ -154,7 +146,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output)
154
146
155
147
$ output ->writeln ('' );
156
148
157
- if (!$ input ->getOption ('yes ' )) {
149
+ if (!$ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' ) ) {
158
150
$ continue = $ dialog ->askConfirmation ($ output , "<question>Phraseanet is going to be installed, continue ? (N/y)</question> " , false );
159
151
160
152
if (!$ continue ) {
@@ -341,7 +333,7 @@ private function getDataPath(InputInterface $input, OutputInterface $output, Dia
341
333
{
342
334
$ dataPath = $ input ->getOption ('data-path ' );
343
335
344
- if (!$ input ->getOption ('yes ' )) {
336
+ if (!$ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' ) ) {
345
337
$ continue = $ dialog ->askConfirmation ($ output , 'Would you like to change default data-path ? (N/y) ' , false );
346
338
347
339
if ($ continue ) {
@@ -362,7 +354,7 @@ private function getServerName(InputInterface $input, OutputInterface $output, D
362
354
{
363
355
$ serverName = $ input ->getOption ('server-name ' );
364
356
365
- if (!$ serverName && !$ input ->getOption ('yes ' )) {
357
+ if (!$ serverName && !$ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' ) ) {
366
358
do {
367
359
$ serverName = $ dialog ->ask ($ output , 'Please provide the server name : ' , null );
368
360
} while (!$ serverName );
@@ -380,7 +372,7 @@ private function getESHost(InputInterface $input, OutputInterface $output, Dialo
380
372
$ host = $ input ->getOption ('es-host ' );
381
373
$ port = (int ) $ input ->getOption ('es-port ' );
382
374
383
- if (! $ input ->getOption ('yes ' )) {
375
+ if (! $ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' ) ) {
384
376
while (! $ host ) {
385
377
$ host = $ dialog ->ask ($ output , 'ElasticSearch server host : ' , null );
386
378
};
@@ -397,7 +389,7 @@ private function getESIndexName(InputInterface $input, OutputInterface $output,
397
389
{
398
390
$ index = $ input ->getOption ('es-index ' );
399
391
400
- if (! $ input ->getOption ('yes ' )) {
392
+ if (!$ input ->getOption ('yes ' ) && ! $ input -> getOption ( ' force ' )) {
401
393
$ index = $ dialog ->ask ($ output , 'ElasticSearch server index name (blank to autogenerate) : ' , null );
402
394
}
403
395
0 commit comments