@@ -65,28 +65,17 @@ function exceptionHandler($exception) {
6565 exit (1 );
6666 }
6767
68- // Check if the data directory is available and the server is installed
69- $ dataDirectory = $ config ->getSystemValueString ('datadirectory ' , \OC ::$ SERVERROOT . '/data ' );
70- if ($ config ->getSystemValueBool ('installed ' , false ) && !is_dir ($ dataDirectory )) {
71- echo "Data directory ( " . $ dataDirectory . ") not found " . PHP_EOL ;
68+ $ user = posix_getuid ();
69+ $ configUser = fileowner (OC ::$ configDir . 'config.php ' );
70+ if ($ user !== $ configUser ) {
71+ echo "Console has to be executed with the user that owns the file config/config.php " . PHP_EOL ;
72+ echo "Current user id: " . $ user . PHP_EOL ;
73+ echo "Owner id of config.php: " . $ configUser . PHP_EOL ;
74+ echo "Try adding 'sudo -u # " . $ configUser . "' to the beginning of the command (without the single quotes) " . PHP_EOL ;
75+ echo "If running with 'docker exec' try adding the option '-u " . $ configUser . "' to the docker command (without the single quotes) " . PHP_EOL ;
7276 exit (1 );
7377 }
7478
75- // Check if the user running the console is the same as the user that owns the data directory
76- // If the data directory does not exist, the server is not setup yet and we can skip.
77- if (is_dir ($ dataDirectory )) {
78- $ user = posix_getuid ();
79- $ dataDirectoryUser = fileowner ($ dataDirectory );
80- if ($ user !== $ dataDirectoryUser ) {
81- echo "Console has to be executed with the user that owns the data directory " . PHP_EOL ;
82- echo "Current user id: " . $ user . PHP_EOL ;
83- echo "Owner id of the data directory: " . $ dataDirectoryUser . PHP_EOL ;
84- echo "Try adding 'sudo -u # " . $ dataDirectoryUser . "' to the beginning of the command (without the single quotes) " . PHP_EOL ;
85- echo "If running with 'docker exec' try adding the option '-u " . $ dataDirectoryUser . "' to the docker command (without the single quotes) " . PHP_EOL ;
86- exit (1 );
87- }
88- }
89-
9079 $ oldWorkingDir = getcwd ();
9180 if ($ oldWorkingDir === false ) {
9281 echo "This script can be run from the Nextcloud root directory only. " . PHP_EOL ;
0 commit comments