Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117893091
D5058.1775366775.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
13 KB
Referenced Files
None
Subscribers
None
D5058.1775366775.diff
View Options
diff --git a/config.prod/src/database/seeds/AdminSeeder.php b/config.prod/src/database/seeds/AdminSeeder.php
--- a/config.prod/src/database/seeds/AdminSeeder.php
+++ b/config.prod/src/database/seeds/AdminSeeder.php
@@ -141,7 +141,7 @@
foreach ($skus as $sku) {
// Check existence because migration might have added this already
- if (!Sku::where('title', $sku['title'])->where('tenant_id', \config('app.tenant_id'))->first()) {
+ if (!Sku::where('title', $sku['title'])->where('tenant_id', \config('app.tenant_id'))->exists()) {
Sku::create($sku);
}
}
@@ -152,74 +152,79 @@
$skuStorage = Sku::where(['title' => 'storage', 'tenant_id' => \config('app.tenant_id')])->first();
// $skuGroup = Sku::where(['title' => 'group', 'tenant_id' => \config('app.tenant_id')])->first();
- $userPackage = Package::create(
- [
- 'title' => 'kolab',
- 'name' => 'Groupware Account',
- 'description' => 'A fully functional groupware account.',
- 'discount_rate' => 0,
- ]
- );
-
- $userPackage->skus()->saveMany([
- $skuMailbox,
- $skuGroupware,
- $skuStorage
- ]);
-
- // This package contains 2 units of the storage SKU, which just so happens to also
- // be the number of SKU free units.
- $userPackage->skus()->updateExistingPivot(
- $skuStorage,
- ['qty' => 5],
- false
- );
+ if (!Package::where('title', 'kolab')->exists()) {
+ $userPackage = Package::create(
+ [
+ 'title' => 'kolab',
+ 'name' => 'Groupware Account',
+ 'description' => 'A fully functional groupware account.',
+ 'discount_rate' => 0,
+ ]
+ );
+
+ $userPackage->skus()->saveMany([
+ $skuMailbox,
+ $skuGroupware,
+ $skuStorage
+ ]);
+
+ // This package contains 2 units of the storage SKU, which just so happens to also
+ // be the number of SKU free units.
+ $userPackage->skus()->updateExistingPivot(
+ $skuStorage,
+ ['qty' => 5],
+ false
+ );
+ }
//Create admin user
- $admin = User::create(
- [
- 'email' => 'admin@' . \config('app.domain'),
- 'password' => \App\Utils::generatePassphrase()
- ]
- );
-
- $admin->setSettings(
- [
- 'first_name' => 'Admin',
- ]
- );
- $admin->role = 'admin';
-
- $admin->assignPackage($userPackage);
-
- //Create a default file collection
- $item = $admin->fsItems()->create(['type' => \App\Fs\Item::TYPE_COLLECTION]);
- $item->setProperties([
- 'name' => "Files",
- ]);
-
+ if (!User::where('email', 'admin@' . \config('app.domain'))->exists()) {
+ $admin = User::create(
+ [
+ 'email' => 'admin@' . \config('app.domain'),
+ 'password' => \App\Utils::generatePassphrase()
+ ]
+ );
+
+ $admin->setSettings(
+ [
+ 'first_name' => 'Admin',
+ ]
+ );
+ $admin->role = 'admin';
+
+ $admin->assignPackage($userPackage);
+
+ //Create a default file collection
+ $item = $admin->fsItems()->create(['type' => \App\Fs\Item::TYPE_COLLECTION]);
+ $item->setProperties([
+ 'name' => "Files",
+ ]);
+ }
//Create primary domain
- $domain = Domain::create(
- [
- 'namespace' => \config('app.domain'),
- 'status' => DOMAIN::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_EXTERNAL,
- ]
- );
-
- $domainPackage = Package::create(
- [
- 'title' => 'domain',
- 'name' => 'Domain',
- 'description' => 'Domain.',
- 'discount_rate' => 0,
- ]
- );
- $domainPackage->skus()->saveMany([$skuDomain]);
-
- $domain->assignPackage($domainPackage, $admin);
+ if (!Domain::where('namespace', \config('app.domain'))->exists()) {
+ $domain = Domain::create(
+ [
+ 'namespace' => \config('app.domain'),
+ 'status' => DOMAIN::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
+ 'type' => Domain::TYPE_EXTERNAL,
+ ]
+ );
+
+ $domainPackage = Package::create(
+ [
+ 'title' => 'domain',
+ 'name' => 'Domain',
+ 'description' => 'Domain.',
+ 'discount_rate' => 0,
+ ]
+ );
+ $domainPackage->skus()->saveMany([$skuDomain]);
+
+ $domain->assignPackage($domainPackage, $admin);
+ }
}
}
diff --git a/config.prod/src/database/seeds/ImapAdminSeeder.php b/config.prod/src/database/seeds/ImapAdminSeeder.php
--- a/config.prod/src/database/seeds/ImapAdminSeeder.php
+++ b/config.prod/src/database/seeds/ImapAdminSeeder.php
@@ -16,10 +16,17 @@
*/
public function run()
{
- $user = new \App\User();
- $user->email = \config('services.imap.admin_login');
- $user->password = \config('services.imap.admin_password');
- $user->role = \App\User::ROLE_SERVICE;
- $user->save();
+ $user = User::where(['email' => \config('services.imap.admin_login')])->first();
+ if (!$user) {
+ $user = new \App\User();
+ $user->email = \config('services.imap.admin_login');
+ $user->password = \config('services.imap.admin_password');
+ $user->role = \App\User::ROLE_SERVICE;
+ $user->save();
+ } else {
+ $user->password = \config('services.imap.admin_password');
+ $user->role = \App\User::ROLE_SERVICE;
+ $user->update();
+ }
}
}
diff --git a/config.prod/src/database/seeds/NoreplySeeder.php b/config.prod/src/database/seeds/NoreplySeeder.php
--- a/config.prod/src/database/seeds/NoreplySeeder.php
+++ b/config.prod/src/database/seeds/NoreplySeeder.php
@@ -17,12 +17,14 @@
public function run()
{
if (!empty(\config('mail.mailers.smtp.username'))) {
- User::create(
- [
- 'email' => \config('mail.mailers.smtp.username'),
- 'password' => \config('mail.mailers.smtp.password')
- ]
- );
+ if (!User::where(['email' => \config('mail.mailers.smtp.username')])->exists()) {
+ User::create(
+ [
+ 'email' => \config('mail.mailers.smtp.username'),
+ 'password' => \config('mail.mailers.smtp.password')
+ ]
+ );
+ }
}
}
}
diff --git a/config.prod/src/database/seeds/PassportSeeder.php b/config.prod/src/database/seeds/PassportSeeder.php
--- a/config.prod/src/database/seeds/PassportSeeder.php
+++ b/config.prod/src/database/seeds/PassportSeeder.php
@@ -18,47 +18,53 @@
public function run()
{
//Create a password grant client for the webapp
- $client = Passport::client()->forceFill([
- 'user_id' => null,
- 'name' => "Kolab Password Grant Client",
- 'secret' => \config('auth.proxy.client_secret'),
- 'provider' => 'users',
- 'redirect' => 'https://' . \config('app.website_domain'),
- 'personal_access_client' => 0,
- 'password_client' => 1,
- 'revoked' => false,
- ]);
- $client->id = \config('auth.proxy.client_id');
- $client->save();
+ if (!empty(\config('auth.proxy.client_secret')) && !Passport::client()->where('name', 'Kolab Password Grant Client')->exists()) {
+ $client = Passport::client()->forceFill([
+ 'user_id' => null,
+ 'name' => "Kolab Password Grant Client",
+ 'secret' => \config('auth.proxy.client_secret'),
+ 'provider' => 'users',
+ 'redirect' => 'https://' . \config('app.website_domain'),
+ 'personal_access_client' => 0,
+ 'password_client' => 1,
+ 'revoked' => false,
+ ]);
+ $client->id = \config('auth.proxy.client_id');
+ $client->save();
+ }
// Create a client for Webmail SSO
- $client = Passport::client()->forceFill([
- 'user_id' => null,
- 'name' => 'Webmail SSO client',
- 'secret' => \config('auth.sso.client_secret'),
- 'provider' => 'users',
- 'redirect' => (str_starts_with(\config('app.webmail_url'), 'http') ? '' : 'https://' . \config('app.website_domain')) . \config('app.webmail_url') . 'index.php/login/oauth',
- 'personal_access_client' => 0,
- 'password_client' => 0,
- 'revoked' => false,
- 'allowed_scopes' => ['email', 'auth.token'],
- ]);
- $client->id = \config('auth.sso.client_id');
- $client->save();
+ if (!empty(\config('auth.sso.client_secret')) && !Passport::client()->where('name', 'Webmail SSO client')->exists()) {
+ $client = Passport::client()->forceFill([
+ 'user_id' => null,
+ 'name' => 'Webmail SSO client',
+ 'secret' => \config('auth.sso.client_secret'),
+ 'provider' => 'users',
+ 'redirect' => (str_starts_with(\config('app.webmail_url'), 'http') ? '' : 'https://' . \config('app.website_domain')) . \config('app.webmail_url') . 'index.php/login/oauth',
+ 'personal_access_client' => 0,
+ 'password_client' => 0,
+ 'revoked' => false,
+ 'allowed_scopes' => ['email', 'auth.token'],
+ ]);
+ $client->id = \config('auth.sso.client_id');
+ $client->save();
+ }
// Create a client for synapse oauth
- $client = Passport::client()->forceFill([
- 'user_id' => null,
- 'name' => "Synapse oauth client",
- 'secret' => \config('auth.synapse.client_secret'),
- 'provider' => 'users',
- 'redirect' => 'https://' . \config('app.website_domain') . "/_synapse/client/oidc/callback",
- 'personal_access_client' => 0,
- 'password_client' => 0,
- 'revoked' => false,
- 'allowed_scopes' => ['email'],
- ]);
- $client->id = \config('auth.synapse.client_id');
- $client->save();
+ if (!empty(\config('auth.synapse.client_secret')) && !Passport::client()->where('name', 'Synapse oauth client')->exists()) {
+ $client = Passport::client()->forceFill([
+ 'user_id' => null,
+ 'name' => "Synapse oauth client",
+ 'secret' => \config('auth.synapse.client_secret'),
+ 'provider' => 'users',
+ 'redirect' => 'https://' . \config('app.website_domain') . "/_synapse/client/oidc/callback",
+ 'personal_access_client' => 0,
+ 'password_client' => 0,
+ 'revoked' => false,
+ 'allowed_scopes' => ['email'],
+ ]);
+ $client->id = \config('auth.synapse.client_id');
+ $client->save();
+ }
}
}
diff --git a/config.prod/src/database/seeds/PowerDNSSeeder.php b/config.prod/src/database/seeds/PowerDNSSeeder.php
--- a/config.prod/src/database/seeds/PowerDNSSeeder.php
+++ b/config.prod/src/database/seeds/PowerDNSSeeder.php
@@ -2,7 +2,6 @@
namespace Database\Seeds;
-use App\Domain;
use Illuminate\Database\Seeder;
class PowerDNSSeeder extends Seeder
@@ -14,10 +13,12 @@
*/
public function run()
{
- $domain = \App\PowerDNS\Domain::create(
- [
- 'name' => '_woat.' . \config('app.domain')
- ]
- );
+ if (!\App\PowerDNS\Domain::where(['name' => '_woat.' . \config('app.domain')])->exists()) {
+ \App\PowerDNS\Domain::create(
+ [
+ 'name' => '_woat.' . \config('app.domain')
+ ]
+ );
+ }
}
}
diff --git a/config.prod/src/database/seeds/TenantSeeder.php b/config.prod/src/database/seeds/TenantSeeder.php
--- a/config.prod/src/database/seeds/TenantSeeder.php
+++ b/config.prod/src/database/seeds/TenantSeeder.php
@@ -15,8 +15,7 @@
public function run()
{
if ($tenantId = \config('app.tenant_id')) {
- $tenant = Tenant::where(['id' => $tenantId])->first();
- if (!$tenant) {
+ if (!Tenant::where(['id' => $tenantId])->exists()) {
Tenant::create(['title' => 'Default Tenant', 'id' => $tenantId]);
}
}
diff --git a/docker/webapp/init.sh b/docker/webapp/init.sh
--- a/docker/webapp/init.sh
+++ b/docker/webapp/init.sh
@@ -47,6 +47,7 @@
echo "----> Running migrations"
php -dmemory_limit=512M ./artisan migrate --force || :
+ php -dmemory_limit=512M ./artisan db:seed --force
echo "----> Starting horizon"
exec ./artisan horizon
;;
@@ -82,6 +83,7 @@
else
echo "----> Running migrations"
php -dmemory_limit=512M ./artisan migrate --force
+ php -dmemory_limit=512M ./artisan db:seed --force
fi
nohup ./artisan horizon 2>&1 &
exec ./artisan octane:start --host=$(env | grep OCTANE_HTTP_HOST | tail -n1 | sed "s/OCTANE_HTTP_HOST=//")
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 5:26 AM (6 h, 40 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832483
Default Alt Text
D5058.1775366775.diff (13 KB)
Attached To
Mode
D5058: Always run the seeder when horizon starts
Attached
Detach File
Event Timeline