- Added print statements - Added questions so user could import only what they want
148 lines
5.2 KiB
PHP
Executable File
148 lines
5.2 KiB
PHP
Executable File
#!/usr/local/bin/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;
|
|
`COMPOSE_ALLOW_SUPERUSER=1 composer update`;
|
|
`symfony console asset-map:compile`;
|
|
|
|
if ($getCreds) {
|
|
print "Creating database schema".PHP_EOL;
|
|
`symfony console doctrine:database:create`;
|
|
}
|
|
|
|
print "Updating migrations and setting permissions for data folder".PHP_EOL;
|
|
`symfony console doctrine:migrations:migrate --no-interaction`;
|
|
|
|
if (isset($cmd['sqlite'])) {
|
|
`chown -R www-data:www-data /data`;
|
|
}
|
|
|
|
// import reference material
|
|
|
|
print "Importing Bible and Eccumenical Creeds".PHP_EOL;
|
|
`symfony console app:ingest-bible /var/www/html/reference/esv-bible`;
|
|
`symfony console app:import-ref /var/www/html/references/creeds/Apostles 'Apostles Creed' creed apc`;
|
|
`symfony console app:import-ref /var/www/html/references/creeds/Athanasian 'Athanasian Creed' creed ath`;
|
|
`symfony console app:import-ref /var/www/html/references/creeds/Chalcedon 'Definition of Chalcedon' creed dc`;
|
|
`symfony console app:import-ref /var/www/html/references/creeds/French 'French Confession' creed fc`;
|
|
`symfony console app:import-ref /var/www/html/references/creeds/Nicene 'Nicene Creed' creed nc`;
|
|
|
|
$dutchStandards = (
|
|
strtolower(
|
|
readline("Do you want to import the Dutch standards (Belgic Confession, Heidelberg Catechism, Canons of Dort) (y/n)? ")
|
|
) == 'y'
|
|
);
|
|
|
|
if ($dutchStandards) {
|
|
print "Importing Dutch Standards".PHP_EOL;
|
|
`symfony console app:import-ref /var/www/html/references/bc Belgic belgic BC{\$ndx}`;
|
|
`symfony console app:import-heidelberg`;
|
|
`symfony console app:import-canons-of-dort`;
|
|
}
|
|
|
|
$westminsterStandards = (
|
|
strtolower(
|
|
readline("Do you want to import the Westminster Standards (y/n)? ")
|
|
) == 'y'
|
|
);
|
|
|
|
if ($westminsterStandards) {
|
|
print "Importing Westminster Standards".PHP_EOL;
|
|
`symfony console app:import-ref /var/www/html/references/wcf 'Westminster Confession' wcf WCF{\$ndx}`;
|
|
`symfony console app:import-ref /var/www/html/references/wsc 'Westminster Shorter' wsc WSC{\$ndx}`;
|
|
`symfony console app:import-wlc /var/www/html/references/wlc 'Westminster Larger' wlc WLC{\$ndx}`;
|
|
}
|
|
|
|
$helviticConfessions = (
|
|
strtolower(
|
|
readline("Do you want to import the Helvetic Confessions (1st & 2nd) (y/n)? ")
|
|
) == 'y'
|
|
);
|
|
|
|
if ($helviticConfessions) {
|
|
print "Importing Helvitic standards".PHP_EOL;
|
|
`symfony console app:import-ref /var/www/html/references/fhc 'First Helvetic Confession' 1hc 1HC{\$ndx}`;
|
|
`symfony console app:import-ref /var/www/html/references/shc 'Second Helvetic Confession' 2hc 2HC{\$ndx}`;
|
|
}
|
|
|
|
$miscStandards = (
|
|
strtolower(
|
|
readline("Do you want to import the misc other standards (39 Articles, Augsberg Confession, London Baptist Confession, Luther's Small and Large Catechism, and Savoy Declaration) (y/n)? ")
|
|
) == 'y'
|
|
);
|
|
|
|
if ($miscStandards) {
|
|
print "Importing misc standards".PHP_EOL;
|
|
`symfony console app:import-ref /var/www/html/references/39a 'Thirty-Nine Articles' 39a 39A{\$ndx}`;
|
|
`symfony console app:import-ref /var/www/html/references/ac 'Augsberg Confession' agc AGC{\$ndx}`;
|
|
`symfony console app:import-ref /var/www/html/references/lbc 'London Baptist Confession' lbc LBC{\$ndx}`;
|
|
`symfony console app:import-ref /var/www/html/references/lsc 'Luther\'s Small Catechism' lsc LSC`;
|
|
`symfony console app:import-ref /var/www/html/references/llc 'Luther\'s Large Catechism' llc LLC`;
|
|
`symfony console app:import-ref /var/www/html/references/sd 'Savoy Declaration' sd SD{\$ndx}`;
|
|
}
|
|
|
|
print "Sermon Notes Ready".PHP_EOL.PHP_EOL;
|