Firebird service:
* simplify directory layout * clean up option descriptions * let the user override Firebird package * create firebird user * clarify TODO comment Close # 1061.
This commit is contained in:
parent
ae39f6c0cb
commit
6cb91c33d0
|
@ -1,9 +1,18 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
# TODO: this file needs some additional work - at least you can connect to
|
# TODO: This may file may need additional review, eg which configuartions to
|
||||||
# firebird ..
|
# expose to the user.
|
||||||
# Example how to connect:
|
#
|
||||||
# isql /var/db/firebird/data/your-db.fdb -u sysdba -p <default password>
|
# I only used it to access some simple databases.
|
||||||
|
|
||||||
|
# test:
|
||||||
|
# isql, then type the following commands:
|
||||||
|
# CREATE DATABASE '/var/db/firebird/data/test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
|
||||||
|
# CONNECT '/var/db/firebird/data/test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
|
||||||
|
# CREATE TABLE test ( text varchar(100) );
|
||||||
|
# DROP DATABASE;
|
||||||
|
#
|
||||||
|
# Be careful, virtuoso-opensource also provides a different isql command !
|
||||||
|
|
||||||
# There are at least two ways to run firebird. superserver has been choosen
|
# There are at least two ways to run firebird. superserver has been choosen
|
||||||
# however there are no strong reasons to prefer this or the other one AFAIK
|
# however there are no strong reasons to prefer this or the other one AFAIK
|
||||||
|
@ -18,7 +27,8 @@ let
|
||||||
|
|
||||||
firebird = cfg.package;
|
firebird = cfg.package;
|
||||||
|
|
||||||
pidFile = "${cfg.pidDir}/firebirdd.pid";
|
dataDir = "${cfg.baseDir}/data";
|
||||||
|
systemDir = "${cfg.baseDir}/system";
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -32,9 +42,9 @@ in
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = "
|
description = ''
|
||||||
Whether to enable the firebird super server.
|
Whether to enable the Firebird super server.
|
||||||
";
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
|
@ -45,29 +55,31 @@ in
|
||||||
reasons. See comments at the firebirdSuper derivation
|
reasons. See comments at the firebirdSuper derivation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
description = "
|
description = ''
|
||||||
Which firebird derivation to use.
|
Which firebird derivation to use.
|
||||||
";
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
default = "3050";
|
default = "3050";
|
||||||
description = "Port of Firebird.";
|
description = ''
|
||||||
|
Port Firebird uses.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
default = "firebird";
|
default = "firebird";
|
||||||
description = "User account under which firebird runs.";
|
description = ''
|
||||||
|
User account under which firebird runs.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
dataDir = mkOption {
|
baseDir = mkOption {
|
||||||
default = "/var/db/firebird/data"; # ubuntu is using /var/lib/firebird/2.1/data/.. ?
|
default = "/var/db/firebird"; # ubuntu is using /var/lib/firebird/2.1/data/.. ?
|
||||||
description = "Location where firebird databases are stored.";
|
description = ''
|
||||||
};
|
Location containing data/ and system/ directories.
|
||||||
|
data/ stores the databases, system/ stores the password database security2.fdb.
|
||||||
pidDir = mkOption {
|
'';
|
||||||
default = "/run/firebird";
|
|
||||||
description = "Location of the file which stores the PID of the firebird server.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -79,12 +91,10 @@ in
|
||||||
|
|
||||||
config = mkIf config.services.firebird.enable {
|
config = mkIf config.services.firebird.enable {
|
||||||
|
|
||||||
users.extraUsers.firebird.description = "Firebird server user";
|
environment.systemPackages = [cfg.package];
|
||||||
|
|
||||||
environment.systemPackages = [firebird];
|
|
||||||
|
|
||||||
systemd.services.firebird =
|
systemd.services.firebird =
|
||||||
{ description = "firebird super server";
|
{ description = "Firebird Super-Server";
|
||||||
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
@ -92,20 +102,17 @@ in
|
||||||
# is a better way
|
# is a better way
|
||||||
preStart =
|
preStart =
|
||||||
''
|
''
|
||||||
secureDir="${cfg.dataDir}/../system"
|
|
||||||
|
|
||||||
mkdir -m 0700 -p \
|
mkdir -m 0700 -p \
|
||||||
"${cfg.dataDir}" \
|
"${dataDir}" \
|
||||||
"${cfg.pidDir}" \
|
"${systemDir}" \
|
||||||
/var/log/firebird \
|
/var/log/firebird
|
||||||
"$secureDir"
|
|
||||||
|
|
||||||
if ! test -e "$secureDir/security2.fdb"; then
|
if ! test -e "${systemDir}/security2.fdb"; then
|
||||||
cp ${firebird}/security2.fdb "$secureDir"
|
cp ${firebird}/security2.fdb "${systemDir}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R ${cfg.user} "${cfg.pidDir}" "${cfg.dataDir}" "$secureDir" /var/log/firebird
|
chown -R ${cfg.user} "${dataDir}" "${systemDir}" /var/log/firebird
|
||||||
chmod -R 700 "${cfg.pidDir}" "${cfg.dataDir}" "$secureDir" /var/log/firebird
|
chmod -R 700 "${dataDir}" "${systemDir}" /var/log/firebird
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig.PermissionsStartOnly = true; # preStart must be run as root
|
serviceConfig.PermissionsStartOnly = true; # preStart must be run as root
|
||||||
|
@ -119,9 +126,9 @@ in
|
||||||
|
|
||||||
# think about this again - and eventually make it an option
|
# think about this again - and eventually make it an option
|
||||||
environment.etc."firebird/firebird.conf".text = ''
|
environment.etc."firebird/firebird.conf".text = ''
|
||||||
# RootDirectory = Restrict ${cfg.dataDir}
|
# RootDirectory = Restrict ${dataDir}
|
||||||
DatabaseAccess = Restrict ${cfg.dataDir}
|
DatabaseAccess = Restrict ${dataDir}
|
||||||
ExternalFileAccess = Restrict ${cfg.dataDir}
|
ExternalFileAccess = Restrict ${dataDir}
|
||||||
# what is this? is None allowed?
|
# what is this? is None allowed?
|
||||||
UdfAccess = None
|
UdfAccess = None
|
||||||
# "Native" = traditional interbase/firebird, "mixed" is windows only
|
# "Native" = traditional interbase/firebird, "mixed" is windows only
|
||||||
|
@ -142,8 +149,14 @@ in
|
||||||
#RemoteAuxPort = 0
|
#RemoteAuxPort = 0
|
||||||
# rsetrict connections to a network card:
|
# rsetrict connections to a network card:
|
||||||
#RemoteBindAddress =
|
#RemoteBindAddress =
|
||||||
# there are some more settings ..
|
# there are some additional settings which should be reviewed
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users.extraUsers.firebird = {
|
||||||
|
description = "firebird server user";
|
||||||
|
group = "firebird";
|
||||||
|
uid = config.ids.uids.firebird;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue