Merge pull request #29781 from rick68/softether

softether: 4.18 -> 4.20
This commit is contained in:
Orivej Desh 2017-10-05 08:26:23 +00:00 committed by GitHub
commit 184f80aeb8
3 changed files with 87 additions and 24 deletions

View File

@ -3,7 +3,6 @@
with lib;
let
pkg = pkgs.softether;
cfg = config.services.softether;
in
@ -17,6 +16,15 @@ in
enable = mkEnableOption "SoftEther VPN services";
package = mkOption {
type = types.package;
default = pkgs.softether;
defaultText = "pkgs.softether";
description = ''
softether derivation to use.
'';
};
vpnserver.enable = mkEnableOption "SoftEther VPN Server";
vpnbridge.enable = mkEnableOption "SoftEther VPN Bridge";
@ -41,7 +49,7 @@ in
dataDir = mkOption {
type = types.string;
default = "${pkg.dataDir}";
default = "${cfg.package.dataDir}";
description = ''
Data directory for SoftEther VPN.
'';
@ -57,12 +65,13 @@ in
mkMerge [{
environment.systemPackages = [
(pkgs.lib.overrideDerivation pkg (attrs: {
(pkgs.lib.overrideDerivation cfg.package (attrs: {
dataDir = cfg.dataDir;
}))
];
systemd.services."softether-init" = {
description = "SoftEther VPN services initial task";
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = false;
@ -71,11 +80,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 ${pkg}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2
install -m0600 ${cfg.package}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2
fi
done
rm -rf ${cfg.dataDir}/vpncmd/vpncmd
ln -s ${pkg}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd
ln -s ${cfg.package}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd
'';
};
}
@ -83,17 +92,17 @@ in
(mkIf (cfg.vpnserver.enable) {
systemd.services.vpnserver = {
description = "SoftEther VPN Server";
after = [ "softether-init.service" "network.target" ];
wants = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ];
after = [ "softether-init.service" ];
requires = [ "softether-init.service" ];
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${pkg}/bin/vpnserver start";
ExecStop = "${pkg}/bin/vpnserver stop";
ExecStart = "${cfg.package}/bin/vpnserver start";
ExecStop = "${cfg.package}/bin/vpnserver stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver
ln -s ${pkg}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver
ln -s ${cfg.package}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver
'';
postStop = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver
@ -104,17 +113,17 @@ in
(mkIf (cfg.vpnbridge.enable) {
systemd.services.vpnbridge = {
description = "SoftEther VPN Bridge";
after = [ "softether-init.service" "network.target" ];
wants = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ];
after = [ "softether-init.service" ];
requires = [ "softether-init.service" ];
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${pkg}/bin/vpnbridge start";
ExecStop = "${pkg}/bin/vpnbridge stop";
ExecStart = "${cfg.package}/bin/vpnbridge start";
ExecStop = "${cfg.package}/bin/vpnbridge stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge
ln -s ${pkg}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge
ln -s ${cfg.package}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge
'';
postStop = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge
@ -125,17 +134,17 @@ in
(mkIf (cfg.vpnclient.enable) {
systemd.services.vpnclient = {
description = "SoftEther VPN Client";
after = [ "softether-init.service" "network.target" ];
wants = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ];
after = [ "softether-init.service" ];
requires = [ "softether-init.service" ];
wantedBy = [ "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${pkg}/bin/vpnclient start";
ExecStop = "${pkg}/bin/vpnclient stop";
ExecStart = "${cfg.package}/bin/vpnclient start";
ExecStop = "${cfg.package}/bin/vpnclient stop";
};
preStart = ''
rm -rf ${cfg.dataDir}/vpnclient/vpnclient
ln -s ${pkg}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient
ln -s ${cfg.package}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient
'';
postStart = ''
sleep 1

View File

@ -0,0 +1,53 @@
{ stdenv, fetchurl
, openssl, readline, ncurses, zlib }:
let
os = if stdenv.isLinux then "1"
else if stdenv.isFreeBSD then "2"
else if stdenv.isSunOS then "3"
else if stdenv.isDarwin then "4"
else if stdenv.isOpenBSD then "5"
else "";
cpuBits = if stdenv.is64bit then "2" else "1";
in
stdenv.mkDerivation rec {
name = "softether-${version}";
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";
sha256 = "e559644e34ec6feba43d99f4083f77f9b082dd0574d0bb1e416a65f32ccbc51e";
};
buildInputs = [ openssl readline ncurses zlib ];
preConfigure = ''
echo "${os}
${cpuBits}
" | ./configure
rm configure
'';
buildPhase = ''
mkdir -p $out/bin
sed -i \
-e "/INSTALL_BINDIR=/s|/usr/bin|/bin|g" \
-e "/_DIR=/s|/usr|${dataDir}|g" \
-e "s|\$(INSTALL|$out/\$(INSTALL|g" \
-e "/echo/s|echo $out/|echo |g" \
Makefile
'';
meta = with stdenv.lib; {
description = "An Open-Source Free Cross-platform Multi-protocol VPN Program";
homepage = https://www.softether.org/;
license = licenses.gpl2;
maintainers = [ maintainers.rick68 ];
platforms = platforms.linux;
};
}

View File

@ -11738,7 +11738,8 @@ with pkgs;
oracleXE = callPackage ../servers/sql/oracle-xe { };
softether_4_18 = callPackage ../servers/softether/4.18.nix { };
softether = softether_4_18;
softether_4_20 = callPackage ../servers/softether/4.20.nix { };
softether = softether_4_20;
qboot = callPackage ../applications/virtualization/qboot { stdenv = stdenv_32bit; };