Merge pull request #31048 from LumiGuide/fix-owncloud

Fix some but not all errors in owncloud
This commit is contained in:
Joachim F 2017-11-25 12:43:29 +00:00 committed by GitHub
commit 822342ffdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 12 deletions

View File

@ -188,8 +188,7 @@ let
/* date format to be used while writing to the owncloud logfile */ /* date format to be used while writing to the owncloud logfile */
'logdateformat' => 'F d, Y H:i:s', 'logdateformat' => 'F d, Y H:i:s',
/* timezone used while writing to the owncloud logfile (default: UTC) */ ${tzSetting}
'logtimezone' => '${serverInfo.fullConfig.time.timeZone}',
/* Append all database queries and parameters to the log file. /* Append all database queries and parameters to the log file.
(watch out, this option can increase the size of your log file)*/ (watch out, this option can increase the size of your log file)*/
@ -339,6 +338,31 @@ let
''; '';
tzSetting = let tz = serverInfo.fullConfig.time.timeZone; in optionalString (!isNull tz) ''
/* timezone used while writing to the owncloud logfile (default: UTC) */
'logtimezone' => '${tz}',
'';
postgresql = serverInfo.fullConfig.services.postgresql.package;
setupDb = pkgs.writeScript "setup-owncloud-db" ''
#!${pkgs.stdenv.shell}
PATH="${postgresql}/bin"
createuser --no-superuser --no-createdb --no-createrole "${config.dbUser}" || true
createdb "${config.dbName}" -O "${config.dbUser}" || true
psql -U postgres -d postgres -c "alter user ${config.dbUser} with password '${config.dbPassword}';" || true
QUERY="CREATE TABLE appconfig
( appid VARCHAR( 255 ) NOT NULL
, configkey VARCHAR( 255 ) NOT NULL
, configvalue VARCHAR( 255 ) NOT NULL
);
GRANT ALL ON appconfig TO ${config.dbUser};
ALTER TABLE appconfig OWNER TO ${config.dbUser};"
psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true
'';
in in
rec { rec {
@ -373,7 +397,7 @@ rec {
defaultText = "pkgs.owncloud70"; defaultText = "pkgs.owncloud70";
example = literalExample "pkgs.owncloud70"; example = literalExample "pkgs.owncloud70";
description = '' description = ''
PostgreSQL package to use. ownCloud package to use.
''; '';
}; };
@ -574,13 +598,7 @@ rec {
chmod -R o-rwx ${config.dataDir} chmod -R o-rwx ${config.dataDir}
chown -R wwwrun:wwwrun ${config.dataDir} chown -R wwwrun:wwwrun ${config.dataDir}
${pkgs.postgresql}/bin/createuser -s -r postgres ${pkgs.sudo}/bin/sudo -u postgres ${setupDb}
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole "${config.dbUser}" || true
${pkgs.postgresql}/bin/createdb "${config.dbName}" -O "${config.dbUser}" || true
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/psql -U postgres -d postgres -c "alter user ${config.dbUser} with password '${config.dbPassword}';" || true
QUERY="CREATE TABLE appconfig (appid VARCHAR( 255 ) NOT NULL ,configkey VARCHAR( 255 ) NOT NULL ,configvalue VARCHAR( 255 ) NOT NULL); GRANT ALL ON appconfig TO ${config.dbUser}; ALTER TABLE appconfig OWNER TO ${config.dbUser};"
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true
fi fi
if [ -e ${config.package}/config/ca-bundle.crt ]; then if [ -e ${config.package}/config/ca-bundle.crt ]; then
@ -591,7 +609,11 @@ rec {
chown wwwrun:wwwrun ${config.dataDir}/owncloud.log || true chown wwwrun:wwwrun ${config.dataDir}/owncloud.log || true
QUERY="INSERT INTO groups (gid) values('admin'); INSERT INTO users (uid,password) values('${config.adminUser}','${builtins.hashString "sha1" config.adminPassword}'); INSERT INTO group_user (gid,uid) values('admin','${config.adminUser}');" QUERY="INSERT INTO groups (gid) values('admin');
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true INSERT INTO users (uid,password)
values('${config.adminUser}','${builtins.hashString "sha1" config.adminPassword}');
INSERT INTO group_user (gid,uid)
values('admin','${config.adminUser}');"
${pkgs.sudo}/bin/sudo -u postgres ${postgresql}/bin/psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true
''; '';
} }

View File

@ -309,6 +309,7 @@ in rec {
tests.leaps = callTest tests/leaps.nix { }; tests.leaps = callTest tests/leaps.nix { };
tests.nsd = callTest tests/nsd.nix {}; tests.nsd = callTest tests/nsd.nix {};
tests.openssh = callTest tests/openssh.nix {}; tests.openssh = callTest tests/openssh.nix {};
tests.owncloud = callTest tests/owncloud.nix {};
tests.pam-oath-login = callTest tests/pam-oath-login.nix {}; tests.pam-oath-login = callTest tests/pam-oath-login.nix {};
#tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; }); #tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
tests.peerflix = callTest tests/peerflix.nix {}; tests.peerflix = callTest tests/peerflix.nix {};

39
nixos/tests/owncloud.nix Normal file
View File

@ -0,0 +1,39 @@
import ./make-test.nix ({ pkgs, ... }:
{
name = "owncloud";
nodes =
{ web =
{ config, pkgs, ... }:
{
services.postgresql.enable = true;
services.httpd = {
enable = true;
logPerVirtualHost = true;
adminAddr = "example@example.com";
virtualHosts = [
{
hostName = "owncloud";
extraSubservices =
[
{
serviceType = "owncloud";
adminPassword = "secret";
dbPassword = "secret";
}
];
}
];
};
};
};
testScript = ''
startAll;
$web->waitForUnit("postgresql");
$web->waitForUnit("httpd");
$web->succeed("curl -L 127.0.0.1:80");
'';
})