summaryrefslogtreecommitdiff
path: root/bin/setup.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-07-02 15:51:04 +0200
committerDaniel Weipert <code@drogueronin.de>2021-07-02 15:51:04 +0200
commiteddb042815eef3488e890468bc39507a375d1081 (patch)
treef3381910dc79e9ba76e5fb022b641e158b063975 /bin/setup.php
Initial commit
Diffstat (limited to 'bin/setup.php')
-rwxr-xr-xbin/setup.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/setup.php b/bin/setup.php
new file mode 100755
index 0000000..ade01c6
--- /dev/null
+++ b/bin/setup.php
@@ -0,0 +1,28 @@
+#!/usr/bin/env php
+
+<?php
+
+$rootDir = dirname(__DIR__);
+$buildDir = "$rootDir/build";
+
+// check if .env is propery set
+if (! file_exists("$buildDir/.env")) {
+ copy("$rootDir/.env.example", "$buildDir/.env");
+ exit('Adjust .env in build directory first.');
+}
+else if (strpos(file_get_contents("$buildDir/.env"), 'example.org') !== false) {
+ exit('Adjust .env in build directory first.');
+}
+
+// load .env
+$dotenv = \Dotenv\Dotenv::createImmutable($buildDir);
+$dotenv->load();
+
+// change to build dir
+chdir($buildDir);
+
+// create .env.production for mastodon setup
+exec("touch $buildDir/.env.production");
+
+// run mastodon:setup
+exec("docker-compose run --rm -v $buildDir/.env.production:/opt/mastodon/.env.production web bundle exec rake mastodon:setup");