@@ -33,7 +33,14 @@ class UpdateEnvironment extends Command
3333 *
3434 * @var string
3535 */
36- protected $ signature = 'pterodactyl:env ' ;
36+ protected $ signature = 'pterodactyl:env
37+ {--dbhost=}
38+ {--dbport=}
39+ {--dbname=}
40+ {--dbuser=}
41+ {--dbpass=}
42+ {--url=}
43+ {--timezone=} ' ;
3744
3845 /**
3946 * The console command description.
@@ -69,40 +76,54 @@ public function handle()
6976
7077 $ envContents = file_get_contents ($ file );
7178
79+ $ this ->info ('Simply leave blank and press enter to fields that you do not wish to update. ' );
7280 if (!env ('SERVICE_AUTHOR ' , false )) {
7381 $ this ->info ('No service author set, setting one now. ' );
7482 $ variables ['SERVICE_AUTHOR ' ] = env ('SERVICE_AUTHOR ' , (string ) Uuid::generate (4 ));
7583 }
7684
77- // DB info
78- if ($ this ->confirm ('Update database host? [ ' . env ('DB_HOST ' ) . '] ' )) {
79- $ variables ['DB_HOST ' ] = $ this ->anticipate ('Database Host (usually \'localhost \' or \'127.0.0.1 \') ' , [ 'localhost ' , '127.0.0.1 ' , env ('DB_HOST ' ) ]);
85+ if (is_null ($ this ->option ('dbhost ' ))) {
86+ $ variables ['DB_HOST ' ] = $ this ->anticipate ('Database Host ' , [ 'localhost ' , '127.0.0.1 ' , env ('DB_HOST ' ) ], env ('DB_HOST ' ));
87+ } else {
88+ $ variables ['DB_HOST ' ] = $ this ->option ('dbhost ' );
8089 }
8190
82- if ($ this ->confirm ('Update database port? [ ' . env ('DB_PORT ' ) . '] ' )) {
83- $ variables ['DB_PORT ' ] = $ this ->anticipate ('Database Port ' , [ 3306 , env ('DB_PORT ' ) ]);
91+ if (is_null ($ this ->option ('dbport ' ))) {
92+ $ variables ['DB_PORT ' ] = $ this ->anticipate ('Database Port ' , [ 3306 , env ('DB_PORT ' ) ], env ('DB_PORT ' ));
93+ } else {
94+ $ variables ['DB_PORT ' ] = $ this ->option ('dbport ' );
8495 }
8596
86- if ($ this ->confirm ('Update database name? [ ' . env ('DB_DATABASE ' ) . '] ' )) {
87- $ variables ['DB_DATABASE ' ] = $ this ->anticipate ('Database Name ' , [ 'pterodactyl ' , 'homestead ' , ENV ('DB_DATABASE ' ) ]);
97+ if (is_null ($ this ->option ('dbname ' ))) {
98+ $ variables ['DB_DATABASE ' ] = $ this ->anticipate ('Database Name ' , [ 'pterodactyl ' , 'homestead ' , ENV ('DB_DATABASE ' ) ], env ('DB_DATABASE ' ));
99+ } else {
100+ $ variables ['DB_DATABASE ' ] = $ this ->option ('dbname ' );
88101 }
89102
90- if ($ this ->confirm ('Update database username? [ ' . env ('DB_USERNAME ' ) . '] ' )) {
91- $ variables ['DB_USERNAME ' ] = $ this ->anticipate ('Database Username ' , [ env ('DB_USERNAME ' ) ]);
103+ if (is_null ($ this ->option ('dbuser ' ))) {
104+ $ variables ['DB_USERNAME ' ] = $ this ->anticipate ('Database Username ' , [ ENV ('DB_DATABASE ' ) ], env ('DB_USERNAME ' ));
105+ } else {
106+ $ variables ['DB_USERNAME ' ] = $ this ->option ('dbuser ' );
92107 }
93108
94- if ($ this ->confirm ('Update database password? ' )) {
95- $ variables ['DB_PASSWORD ' ] = $ this ->secret ('Database User \'s Password ' );
109+ if (is_null ($ this ->option ('dbpass ' ))) {
110+ $ this ->line ('The Database Password field is required; you cannot hit enter and use a default value. ' );
111+ $ variables ['DB_PASSWORD ' ] = $ this ->secret ('Database User Password ' );
112+ } else {
113+ $ variables ['DB_PASSWORD ' ] = $ this ->option ('dbpass ' );
96114 }
97115
98- // Other Basic Information
99- if ($ this ->confirm ('Update panel URL? [ ' . env ('APP_URL ' ) . '] ' )) {
100- $ variables ['APP_URL ' ] = $ this ->anticipate ('Enter your current panel URL (include http or https). ' , [ env ('APP_URL ' , 'http://localhost ' ) ]);
116+ if (is_null ($ this ->option ('url ' ))) {
117+ $ variables ['APP_URL ' ] = $ this ->ask ('Panel URL ' , env ('APP_URL ' ));
118+ } else {
119+ $ variables ['APP_URL ' ] = $ this ->option ('url ' );
101120 }
102121
103- if ( $ this ->confirm ( ' Update panel timezone? [ ' . env ( ' APP_TIMEZONE ' ) . ' ] ' )) {
122+ if ( is_null ( $ this ->option ( ' timezone ' ) )) {
104123 $ this ->line ('The timezone should match one of the supported timezones according to http://php.net/manual/en/timezones.php ' );
105- $ variables ['APP_TIMEZONE ' ] = $ this ->anticipate ('Enter the timezone for this panel to run with ' , \DateTimeZone::listIdentifiers (\DateTimeZone::ALL ));
124+ $ variables ['APP_TIMEZONE ' ] = $ this ->anticipate ('Panel Timezone ' , \DateTimeZone::listIdentifiers (\DateTimeZone::ALL ), env ('APP_TIMEZONE ' ));
125+ } else {
126+ $ variables ['APP_TIMEZONE ' ] = $ this ->option ('timezone ' );
106127 }
107128
108129 $ bar = $ this ->output ->createProgressBar (count ($ variables ));
0 commit comments