Merge pull request #35343 from gnidorah/softether

softether module: fix dataDir option
This commit is contained in:
Jörg Thalheim 2018-02-23 12:38:11 +00:00 committed by GitHub
commit df4963daca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 26 deletions

View File

@ -5,6 +5,8 @@ with lib;
let
cfg = config.services.softether;
package = cfg.package.override { dataDir = cfg.dataDir; };
in
{
@ -49,7 +51,7 @@ in
dataDir = mkOption {
type = types.string;
default = "${cfg.package.dataDir}";
default = "/var/lib/softether";
description = ''
Data directory for SoftEther VPN.
'';
@ -64,11 +66,8 @@ in
config = mkIf cfg.enable (
mkMerge [{
environment.systemPackages = [
(pkgs.lib.overrideDerivation cfg.package (attrs: {
dataDir = cfg.dataDir;
}))
];
environment.systemPackages = [ package ];
systemd.services."softether-init" = {
description = "SoftEther VPN services initial task";
wantedBy = [ "network.target" ];
@ -80,11 +79,11 @@ in
for d in vpnserver vpnbridge vpnclient vpncmd; do
if ! test -e ${cfg.dataDir}/$d; then
${pkgs.coreutils}/bin/mkdir -m0700 -p ${cfg.dataDir}/$d
install -m0600 ${cfg.package}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2
install -m0600 ${package}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2
fi
done
rm -rf ${cfg.dataDir}/vpncmd/vpncmd
ln -s ${cfg.package}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd
ln -s ${package}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd
'';
};
}
@ -97,12 +96,12 @@ in
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${cfg.package}/bin/vpnserver start";
ExecStop = "${cfg.package}/bin/vpnserver stop";
ExecStart = "${package}/bin/vpnserver start";
ExecStop = "${package}/bin/vpnserver stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver
ln -s ${cfg.package}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver
ln -s ${package}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver
'';
postStop = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver
@ -118,12 +117,12 @@ in
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${cfg.package}/bin/vpnbridge start";
ExecStop = "${cfg.package}/bin/vpnbridge stop";
ExecStart = "${package}/bin/vpnbridge start";
ExecStop = "${package}/bin/vpnbridge stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge
ln -s ${cfg.package}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge
ln -s ${package}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge
'';
postStop = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge
@ -139,12 +138,12 @@ in
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${cfg.package}/bin/vpnclient start";
ExecStop = "${cfg.package}/bin/vpnclient stop";
ExecStart = "${package}/bin/vpnclient start";
ExecStop = "${package}/bin/vpnclient stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnclient/vpnclient
ln -s ${cfg.package}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient
ln -s ${package}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient
'';
postStart = ''
sleep 1

View File

@ -1,5 +1,6 @@
{ stdenv, fetchurl
, openssl, readline, ncurses, zlib }:
, openssl, readline, ncurses, zlib
, dataDir ? "/var/lib/softether" }:
let
os = if stdenv.isLinux then "1"
@ -17,7 +18,6 @@ stdenv.mkDerivation rec {
version = "4.18";
build = "9570";
compiledDate = "2015.07.26";
dataDir = "/var/lib/softether";
src = fetchurl {
url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
homepage = https://www.softether.org/;
license = licenses.gpl2;
maintainers = [ maintainers.rick68 ];
platforms = platforms.linux;
platforms = filter (p: p != "aarch64-linux") platforms.linux;
};
}

View File

@ -1,5 +1,6 @@
{ stdenv, fetchurl
, openssl, readline, ncurses, zlib }:
, openssl, readline, ncurses, zlib
, dataDir ? "/var/lib/softether" }:
let
os = if stdenv.isLinux then "1"
@ -17,7 +18,6 @@ stdenv.mkDerivation rec {
version = "4.20";
build = "9608";
compiledDate = "2016.04.17";
dataDir = "/var/lib/softether";
src = fetchurl {
url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
homepage = https://www.softether.org/;
license = licenses.gpl2;
maintainers = [ maintainers.rick68 ];
platforms = platforms.linux;
platforms = filter (p: p != "aarch64-linux") platforms.linux;
};
}

View File

@ -1,5 +1,6 @@
{ stdenv, fetchurl
, openssl, readline, ncurses, zlib }:
, openssl, readline, ncurses, zlib
, dataDir ? "/var/lib/softether" }:
let
os = if stdenv.isLinux then "1"
@ -17,7 +18,6 @@ stdenv.mkDerivation rec {
version = "4.25";
build = "9656";
compiledDate = "2018.01.15";
dataDir = "/var/lib/softether";
src = fetchurl {
url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
homepage = https://www.softether.org/;
license = licenses.gpl2;
maintainers = [ maintainers.rick68 ];
platforms = platforms.linux;
platforms = filter (p: p != "aarch64-linux") platforms.linux;
};
}