Skip to content

Commit 96aed5a

Browse files
committed
Installer fix
1 parent 226f672 commit 96aed5a

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

cp/bin/create_admin_user.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,22 @@
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 = [

docs/install.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,10 @@ systemctl enable redis-server
534534
systemctl start redis-server
535535

536536
echo "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" \
542541
php /var/www/cp/bin/create_admin_user.php
543542

544543
echo "Downloading initial data."

0 commit comments

Comments
 (0)