1.2 #23
72
install.php
72
install.php
@@ -2,83 +2,17 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!file_exists('/var/www/html/.env')) {
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cmd = getopt("", ["sqlite", "mysql", "mariadb", "pgsql"]);
|
|
||||||
|
|
||||||
$key = `openssl rand -base64 32 | tr -d '=' | tr -d '+' | tr -d '/' | tr -d ' '`;
|
|
||||||
$key = substr($key, 0, 32);
|
|
||||||
$database_url = null;
|
|
||||||
$getCreds = true;
|
|
||||||
$creds = null;
|
|
||||||
|
|
||||||
if (isset($cmd['sqlite'])) {
|
|
||||||
$database_url = "DATABASE_URL=\"sqlite:////data/data.db\"";
|
|
||||||
$getCreds = false;
|
|
||||||
} elseif (isset($cmd['mysql'])) {
|
|
||||||
$database_url = "DATABASE_URL=\"mysql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?charset=utf8&use_unicode=1\"";
|
|
||||||
} elseif (isset($cmd['mariadb'])) {
|
|
||||||
$database_url = "DATABASE_URL=\"mysql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?charset=utf8mb4\"";
|
|
||||||
} elseif (isset($cmd['pgsql'])) {
|
|
||||||
$database_url = "DATABASE_URL=\"postgresql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?sslmode=require\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_null($database_url)) {
|
|
||||||
$getCreds = false;
|
|
||||||
die("When calling this make sure that you enter a database type");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($getCreds) {
|
|
||||||
$db_host = readline("DB Host: ");
|
|
||||||
$db_port = readline("DB Port: ");
|
|
||||||
$db_name = readline("DB Schema: ");
|
|
||||||
$db_user = readline("DB User: ");
|
|
||||||
|
|
||||||
print "DB Password: ";
|
|
||||||
// Disable echoing of input characters
|
|
||||||
system('stty -echo');
|
|
||||||
// Read the password from standard input
|
|
||||||
$db_password = trim(fgets(STDIN));
|
|
||||||
// Re-enable echoing of input characters
|
|
||||||
system('stty echo');
|
|
||||||
$creds = <<<CREDS
|
|
||||||
DB_HOST=$db_host
|
|
||||||
DB_PORT=$db_port
|
|
||||||
DB_NAME=$db_name
|
|
||||||
DB_USER=$db_user
|
|
||||||
DB_PASS=$db_password
|
|
||||||
|
|
||||||
CREDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = <<<EOF
|
|
||||||
APP_ENV=prod
|
|
||||||
APP_DEBUG=0
|
|
||||||
APP_SECRET=$key
|
|
||||||
MESSAGENER_TRANSPORT_DSN=doctrine://default?auto_setup=0
|
|
||||||
$creds$database_url
|
|
||||||
|
|
||||||
EOF;
|
|
||||||
|
|
||||||
file_put_contents('/var/www/html/.env', $output);
|
|
||||||
|
|
||||||
print "Updating packages and compiling assets".PHP_EOL;
|
print "Updating packages and compiling assets".PHP_EOL;
|
||||||
`COMPOSE_ALLOW_SUPERUSER=1 composer update`;
|
`COMPOSE_ALLOW_SUPERUSER=1 composer update`;
|
||||||
`symfony console asset-map:compile`;
|
`symfony console asset-map:compile`;
|
||||||
|
|
||||||
if ($getCreds) {
|
print "Creating database schema".PHP_EOL;
|
||||||
print "Creating database schema".PHP_EOL;
|
`symfony console doctrine:database:create`;
|
||||||
`symfony console doctrine:database:create`;
|
|
||||||
}
|
|
||||||
|
|
||||||
print "Updating migrations and setting permissions for data folder".PHP_EOL;
|
print "Updating migrations and setting permissions for data folder".PHP_EOL;
|
||||||
`symfony console doctrine:migrations:migrate --no-interaction`;
|
`symfony console doctrine:migrations:migrate --no-interaction`;
|
||||||
|
|
||||||
if (isset($cmd['sqlite'])) {
|
`chown -R www-data:www-data /data`;
|
||||||
`chown -R www-data:www-data /data`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// import reference material
|
// import reference material
|
||||||
|
|
||||||
|
|||||||
94
setup.php
Executable file
94
setup.php
Executable file
@@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/local/bin/php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!file_exists('/var/www/html/.env')) {
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = getopt("", ["sqlite", "mysql", "mariadb", "pgsql", "shared"]);
|
||||||
|
|
||||||
|
$key = `openssl rand -base64 32 | tr -d '=' | tr -d '+' | tr -d '/' | tr -d ' '`;
|
||||||
|
$key = substr($key, 0, 32);
|
||||||
|
$database_url = null;
|
||||||
|
$getCreds = true;
|
||||||
|
$creds = null;
|
||||||
|
|
||||||
|
$http_port = readline("What port do you want the server to listen on (80)? ");
|
||||||
|
$http_port = (empty($http_port) ? 80 : $http_port);
|
||||||
|
|
||||||
|
if (isset($cmd['sqlite'])) {
|
||||||
|
$database_url = "DATABASE_URL=\"sqlite:////data/data.db\"";
|
||||||
|
$getCreds = false;
|
||||||
|
} elseif (isset($cmd['mysql'])) {
|
||||||
|
$database_url = "DATABASE_URL=\"mysql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?charset=utf8&use_unicode=1\"";
|
||||||
|
} elseif (isset($cmd['mariadb'])) {
|
||||||
|
$database_url = "DATABASE_URL=\"mysql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?charset=utf8mb4\"";
|
||||||
|
} elseif (isset($cmd['pgsql'])) {
|
||||||
|
$database_url = "DATABASE_URL=\"postgresql://\${DB_USER}:\${DB_PASS}@\${DB_HOST}:\${DB_PORT}/\${DB_NAME}?sslmode=require\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($database_url)) {
|
||||||
|
$getCreds = false;
|
||||||
|
die("When calling this make sure that you enter a database type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($getCreds) {
|
||||||
|
$dbInfo = null;
|
||||||
|
if (isset($cmd['shared'])) {
|
||||||
|
$db_host = readline("DB Host: ");
|
||||||
|
$db_port = readline("DB Port: ");
|
||||||
|
$db_name = readline("DB Schema: ");
|
||||||
|
$db_user = readline("DB User: ");
|
||||||
|
|
||||||
|
print "DB Password: ";
|
||||||
|
// Disable echoing of input characters
|
||||||
|
system('stty -echo');
|
||||||
|
// Read the password from standard input
|
||||||
|
$db_password = trim(fgets(STDIN));
|
||||||
|
// Re-enable echoing of input characters
|
||||||
|
system('stty echo');
|
||||||
|
} else {
|
||||||
|
$db_host = 'db';
|
||||||
|
$db_port = (isset($cmd['pgsql']) ? 5432 : 3306);
|
||||||
|
$db_name = 'sermon_notes';
|
||||||
|
$db_user = 'root';
|
||||||
|
$pwd = `openssl rand -base64 32 | tr -d '=' | tr -d '+' | tr -d '/' | tr -d ' '`;
|
||||||
|
$db_password = substr($pwd, 0, 32);
|
||||||
|
|
||||||
|
if (isset($cmd['pgsql'])) {
|
||||||
|
$dbInfo = <<<INFO
|
||||||
|
POSTGRES_USER=$db_user
|
||||||
|
POSTGRES_PASSWORD=$db_password
|
||||||
|
|
||||||
|
INFO;
|
||||||
|
} elseif (isset($cmd['mysql']) || isset($cmd['mariadb'])) {
|
||||||
|
$dbInfo = <<<INFO
|
||||||
|
MYSQL_ROOT_PASSWORD=$db_password
|
||||||
|
|
||||||
|
INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$creds = <<<CREDS
|
||||||
|
DB_HOST=$db_host
|
||||||
|
DB_PORT=$db_port
|
||||||
|
DB_NAME=$db_name
|
||||||
|
DB_USER=$db_user
|
||||||
|
DB_PASS=$db_password
|
||||||
|
$dbInfo
|
||||||
|
|
||||||
|
CREDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = <<<EOF
|
||||||
|
APP_ENV=prod
|
||||||
|
APP_DEBUG=0
|
||||||
|
APP_SECRET=$key
|
||||||
|
MESSAGENER_TRANSPORT_DSN=doctrine://default?auto_setup=0
|
||||||
|
HTTP_PORT=$http_port
|
||||||
|
$creds$database_url
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
file_put_contents('/var/www/html/.env', $output);
|
||||||
Reference in New Issue
Block a user