@@ -41,28 +41,17 @@ function exceptionHandler($exception) {
4141 exit (1 );
4242 }
4343
44- // Check if the data directory is available and the server is installed
45- $ dataDirectory = $ config ->getSystemValueString ('datadirectory ' , \OC ::$ SERVERROOT . '/data ' );
46- if ($ config ->getSystemValueBool ('installed ' , false ) && !is_dir ($ dataDirectory )) {
47- echo "Data directory ( " . $ dataDirectory . ") not found " . PHP_EOL ;
44+ $ user = posix_getuid ();
45+ $ configUser = fileowner (OC ::$ configDir . 'config.php ' );
46+ if ($ user !== $ configUser ) {
47+ echo "Console has to be executed with the user that owns the file config/config.php " . PHP_EOL ;
48+ echo "Current user id: " . $ user . PHP_EOL ;
49+ echo "Owner id of config.php: " . $ configUser . PHP_EOL ;
50+ echo "Try adding 'sudo -u # " . $ configUser . "' to the beginning of the command (without the single quotes) " . PHP_EOL ;
51+ echo "If running with 'docker exec' try adding the option '-u " . $ configUser . "' to the docker command (without the single quotes) " . PHP_EOL ;
4852 exit (1 );
4953 }
5054
51- // Check if the user running the console is the same as the user that owns the data directory
52- // If the data directory does not exist, the server is not setup yet and we can skip.
53- if (is_dir ($ dataDirectory )) {
54- $ user = posix_getuid ();
55- $ dataDirectoryUser = fileowner ($ dataDirectory );
56- if ($ user !== $ dataDirectoryUser ) {
57- echo "Console has to be executed with the user that owns the data directory " . PHP_EOL ;
58- echo "Current user id: " . $ user . PHP_EOL ;
59- echo "Owner id of the data directory: " . $ dataDirectoryUser . PHP_EOL ;
60- echo "Try adding 'sudo -u # " . $ dataDirectoryUser . "' to the beginning of the command (without the single quotes) " . PHP_EOL ;
61- echo "If running with 'docker exec' try adding the option '-u " . $ dataDirectoryUser . "' to the docker command (without the single quotes) " . PHP_EOL ;
62- exit (1 );
63- }
64- }
65-
6655 $ oldWorkingDir = getcwd ();
6756 if ($ oldWorkingDir === false ) {
6857 echo "This script can be run from the Nextcloud root directory only. " . PHP_EOL ;
0 commit comments