File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212$ dbUser = $ _ENV ['DB_USERNAME ' ];
1313$ dbPass = $ _ENV ['DB_PASSWORD ' ];
1414
15- // User details (replace these with actual user data)
16- $ email = 'admin@example.com ' ; // Replace with admin email
17- $ newPW = 'admin_password ' ; // Replace with admin password
18- $ username = 'admin ' ; // Replace with admin username
15+ // Retrieve admin details from environment variables
16+ $ email = getenv ('PANEL_EMAIL ' );
17+ $ newPW = getenv ('PANEL_PASSWORD ' );
18+ $ username = getenv ('PANEL_USERNAME ' ) ?: 'admin ' ;
19+
20+ if ($ email === false || $ email === '' ) {
21+ die ("PANEL_EMAIL is required. " . PHP_EOL );
22+ }
23+
24+ if ($ newPW === false || $ newPW === '' ) {
25+ die ("PANEL_PASSWORD is required. " . PHP_EOL );
26+ }
27+
28+ if (!filter_var ($ email , FILTER_VALIDATE_EMAIL )) {
29+ die ("Invalid admin email address. " . PHP_EOL );
30+ }
1931
2032// Hash the password
2133$ options = [
Original file line number Diff line number Diff line change @@ -534,11 +534,10 @@ systemctl enable redis-server
534534systemctl start redis-server
535535
536536echo " Configuring control panel admin."
537- PANEL_EMAIL_SED=$( escape_sed_replacement " $PANEL_EMAIL " )
538- PANEL_PASSWORD_PHP=$( escape_php_single_quoted " $PANEL_PASSWORD " )
539- PANEL_PASSWORD_PHP_SED=$( escape_sed_replacement " $PANEL_PASSWORD_PHP " )
540- sed -i " s|\$ email = 'admin@example.com';|\$ email = '$PANEL_EMAIL_SED ';|g" /var/www/cp/bin/create_admin_user.php
541- sed -i " s|\$ newPW = 'admin_password';|\$ newPW = '$PANEL_PASSWORD_PHP_SED ';|g" /var/www/cp/bin/create_admin_user.php
537+
538+ PANEL_EMAIL=" $PANEL_EMAIL " \
539+ PANEL_PASSWORD=" $PANEL_PASSWORD " \
540+ PANEL_USERNAME=" admin" \
542541php /var/www/cp/bin/create_admin_user.php
543542
544543echo " Downloading initial data."
You can’t perform that action at this time.
0 commit comments