Add local.settings.php to every instance
This commit adds a new file 'local.settings.php' to each distillery instance. This file can be used to automatically edit global distillery settings.
This commit is contained in:
parent
6eab3ac311
commit
24ff81f7cd
13 changed files with 98 additions and 42 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
)
|
||||
|
||||
|
|
@ -41,6 +42,8 @@ var (
|
|||
errFailedInstallDistillerySettings = errors.New("failed to install distillery settings")
|
||||
)
|
||||
|
||||
// SetTrustedDomain configures the trusted domain setting for the given instance.
|
||||
// Note that this removes any installed distillery settings.
|
||||
func (settings *Settings) SetTrustedDomain(ctx context.Context, server *phpx.Server, domain string) error {
|
||||
var ok bool
|
||||
|
||||
|
|
@ -51,14 +54,12 @@ func (settings *Settings) SetTrustedDomain(ctx context.Context, server *phpx.Ser
|
|||
return err
|
||||
}
|
||||
|
||||
// GlobalSettingsPath is the global path to distillery settings
|
||||
const GlobalSettingsPath = "/distillery_settings.php"
|
||||
|
||||
func (settings *Settings) InstallDistillerySettings(ctx context.Context, server *phpx.Server) error {
|
||||
var ok bool
|
||||
|
||||
err := settings.dependencies.PHP.ExecScript(ctx, server, &ok, settingsPHP, "install_settings_include", []string{
|
||||
GlobalSettingsPath,
|
||||
barrel.LocalSettingsPath,
|
||||
barrel.GlobalSettingsPath,
|
||||
})
|
||||
if err == nil && !ok {
|
||||
err = errFailedInstallDistillerySettings
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ function set_setting(string $name, mixed $value): bool {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// reset the file mode
|
||||
return chmod($filename, $old);
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ function install_settings_include(array $paths): bool {
|
|||
// add code to include the file if it exists
|
||||
$code = $code . 'if (file_exists(' . $the_path . ')) { include_once ' . $the_path . '; }' . "\n";
|
||||
}
|
||||
$code = $code . "// </distillery-settings-include>";
|
||||
$code = $code . "// </distillery-settings-include>\n";
|
||||
|
||||
// and store the settings
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue