make the datadirectory more robust

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2021-12-04 11:01:38 +01:00
parent de61270ac3
commit 513e389a24
2 changed files with 7 additions and 1 deletions

View file

@ -10,6 +10,9 @@ print_green() {
if ! [ -a "/var/run/docker.sock" ]; then
echo "Docker socket is not available. Cannot continue."
exit 1
elif ! mountpoint -q "/mnt/docker-aio-config"; then
echo "/mnt/docker-aio-config is not a mountpoint. Cannot proceed!"
exit 1
elif ! sudo -u www-data test -r /var/run/docker.sock; then
echo "Trying to fix docker.sock permissions internally..."
GROUP="$(stat -c '%g' /var/run/docker.sock)"

View file

@ -193,9 +193,12 @@ class ConfigurationManager
$this->WriteConfig($config);
}
/**
* @throws InvalidSettingConfigurationException
*/
public function WriteConfig(array $config) : void {
if(!is_dir(DataConst::GetDataDirectory())) {
mkdir(DataConst::GetDataDirectory());
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!");
}
file_put_contents(DataConst::GetConfigFile(), json_encode($config));
}