Fixed initial setup not creating config files

This commit is contained in:
Daniel Winzen
2019-02-23 07:11:19 +01:00
parent a520c987e6
commit 31c6020608

View File

@ -140,7 +140,8 @@ if(!@$version=$db->query("SELECT value FROM settings WHERE setting='version';"))
} }
$stmt=$db->prepare("UPDATE settings SET value=? WHERE setting='version';"); $stmt=$db->prepare("UPDATE settings SET value=? WHERE setting='version';");
$stmt->execute([DBVERSION]); $stmt->execute([DBVERSION]);
foreach(PHP_VERSIONS as $version){ }
foreach(PHP_VERSIONS as $version){
if(!file_exists("/etc/php/$version/fpm/conf.d/")){ if(!file_exists("/etc/php/$version/fpm/conf.d/")){
mkdir("/etc/php/$version/fpm/conf.d/", 0755, true); mkdir("/etc/php/$version/fpm/conf.d/", 0755, true);
} }
@ -237,26 +238,25 @@ php_admin_value[open_basedir] = /usr/share/adminer:/tmp
} }
file_put_contents("/etc/php/$version/fpm/pool.d/www.conf", $pool_config); file_put_contents("/etc/php/$version/fpm/pool.d/www.conf", $pool_config);
exec("service php$version-fpm@default reload"); exec("service php$version-fpm@default reload");
} }
echo "Updating chroots, this might take a while…\n"; echo "Updating chroots, this might take a while…\n";
exec('/var/www/setup_chroot.sh /var/www'); exec('/var/www/setup_chroot.sh /var/www');
$stmt=$db->query('SELECT system_account FROM users;'); $stmt=$db->query('SELECT system_account FROM users;');
$shell = ENABLE_SHELL_ACCESS ? '/bin/bash' : '/usr/sbin/nologin'; $shell = ENABLE_SHELL_ACCESS ? '/bin/bash' : '/usr/sbin/nologin';
while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){ while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){
echo "Updating chroot for user $tmp[system_account]\n"; echo "Updating chroot for user $tmp[system_account]\n";
exec('usermod -s ' . escapeshellarg($shell) . ' ' . escapeshellarg($tmp['system_account'])); exec('usermod -s ' . escapeshellarg($shell) . ' ' . escapeshellarg($tmp['system_account']));
exec('/var/www/setup_chroot.sh ' . escapeshellarg('/home/'.$tmp['system_account'])); exec('/var/www/setup_chroot.sh ' . escapeshellarg('/home/'.$tmp['system_account']));
exec('grep ' . escapeshellarg($tmp['system_account']) . ' /etc/passwd >> ' . escapeshellarg("/home/$tmp[system_account]/etc/passwd")); exec('grep ' . escapeshellarg($tmp['system_account']) . ' /etc/passwd >> ' . escapeshellarg("/home/$tmp[system_account]/etc/passwd"));
} }
file_put_contents('/etc/nginx/sites-enabled/default', NGINX_DEFAULT); file_put_contents('/etc/nginx/sites-enabled/default', NGINX_DEFAULT);
if(!file_exists("/etc/nginx/streams-enabled/")){ if(!file_exists("/etc/nginx/streams-enabled/")){
mkdir("/etc/nginx/streams-enabled/", 0755, true); mkdir("/etc/nginx/streams-enabled/", 0755, true);
} }
file_put_contents('/etc/nginx/streams-enabled/default', "server { file_put_contents('/etc/nginx/streams-enabled/default', "server {
listen unix:/var/www/var/run/mysqld/mysqld.sock; listen unix:/var/www/var/run/mysqld/mysqld.sock;
proxy_pass unix:/var/run/mysqld/mysqld.sock; proxy_pass unix:/var/run/mysqld/mysqld.sock;
}"); }");
exec("service nginx reload"); exec("service nginx reload");
$db->exec('UPDATE service_instances SET reload=1;'); $db->exec('UPDATE service_instances SET reload=1;');
echo "Done - Database and files have been updated to the latest version :)\n"; echo "Done - Database and files have been updated to the latest version :)\n";
}