Skip to content

Commit

Permalink
Changes for #929
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Nov 20, 2023
1 parent 87381e2 commit 6552a93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions integrations/nextcloud/snappymail/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ Then, enable the SnappyMail plugin that is in the "Social & communication" secti
After a quick wait, SnappyMail is installed. Even if it is really attractive, it is too soon to click on the newly appeared "Email" icon in the apps list. You should configure SnappyMail before using it (which makes some sense, doesn'it): go to Nextcloud admin panel (upper-right corner dropdown menu) and go to "Additionnal settings". There click on the "Go to SnappyMail Webmail admin panel".
In the SnappyMail admin prompt, the default login is "admin" and the default password will be generated in "[nextcloud-data]/app_snappymail/_data_/_default_/admin_password.txt". No need to advise you to change it once in the admin panel!
This is it, you are now free to configure SnappyMail as you wish. One important point is the Domains section when you will set up the IMAP/SMTP parameters that shall be associated with the email adresses of your users.

STUCK IN MAINTENANCE:
https://github.com/the-djmaze/snappymail/issues/929
17 changes: 16 additions & 1 deletion integrations/nextcloud/snappymail/lib/Migration/InstallStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ public function getName() {

public function run(IOutput $output) {

$output->info('clearstatcache');
\clearstatcache();
\clearstatcache(true);
$output->info('opcache_reset');
// opcache_reset is a terrible solution, but certain Nextcloud setups have issues
\is_callable('opcache_reset') && \opcache_reset();

$output->info('Load App');
\OCA\SnappyMail\Util\SnappyMailHelper::loadApp();

$output->info('Fix permissions');
\SnappyMail\Upgrade::fixPermissions();

$app_dir = \dirname(\dirname(__DIR__)) . '/app';
Expand All @@ -48,11 +52,13 @@ public function run(IOutput $output) {
$bSave = false;

if (!$oConfig->Get('webmail', 'app_path')) {
$output->info('Set config [webmail]app_path');
$oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/');
$bSave = true;
}

if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) {
$output->info('Install extension: nextcloud');
\SnappyMail\Repository::installPackage('plugin', 'nextcloud');
$oConfig->Set('plugins', 'enable', true);
$aList = \SnappyMail\Repository::getEnabledPackagesNames();
Expand All @@ -64,6 +70,7 @@ public function run(IOutput $output) {

$sPassword = $oConfig->Get('security', 'admin_password');
if ('12345' == $sPassword || !$sPassword) {
$output->info('Generate admin password');
$sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12);
$oConfig->SetPassword($sPassword);
\RainLoop\Utils::saveFile(APP_PRIVATE_DATA . 'admin_password.txt', $sPassword . "\n");
Expand All @@ -74,6 +81,7 @@ public function run(IOutput $output) {
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
$oDomain = $oProvider->Load('nextcloud');
if (!$oDomain) {
$output->info('Add nextcloud as domain');
// $oDomain = \RainLoop\Model\Domain::fromIniArray('nextcloud', []);
$oDomain = new \RainLoop\Model\Domain('nextcloud');
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
Expand All @@ -89,7 +97,13 @@ public function run(IOutput $output) {
}
}

$bSave && $oConfig->Save();
if ($bSave) {
$oConfig->Save()
? $output->info('Config saved')
: $output->info('Config failed');
} else {
$output->info('Config not changed');
}

// check if admins provided additional/custom initial config file
// https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#setting-a-single-configuration-value
Expand All @@ -100,6 +114,7 @@ public function run(IOutput $output) {
$ncConfig = \OC::$server->get(IConfig::class);
$customConfigFile = $ncConfig->getAppValue(Application::APP_ID, 'custom_config_file');
if ($customConfigFile) {
$output->info("Load custom config: {$customConfigFile}");
if (!\str_contains($customConfigFile, ':') && \is_readable($customConfigFile)) {
require $customConfigFile;
} else {
Expand Down

0 comments on commit 6552a93

Please sign in to comment.