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; with lib;
let let
pkg = pkgs.softether;
cfg = config.services.softether; cfg = config.services.softether;
in in
@ -17,6 +16,15 @@ in
enable = mkEnableOption "SoftEther VPN services"; 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"; vpnserver.enable = mkEnableOption "SoftEther VPN Server";
vpnbridge.enable = mkEnableOption "SoftEther VPN Bridge"; vpnbridge.enable = mkEnableOption "SoftEther VPN Bridge";
@ -41,7 +49,7 @@ in
dataDir = mkOption { dataDir = mkOption {
type = types.string; type = types.string;
default = "${pkg.dataDir}"; default = "${cfg.package.dataDir}";
description = '' description = ''
Data directory for SoftEther VPN. Data directory for SoftEther VPN.
''; '';
@ -57,12 +65,13 @@ in
mkMerge [{ mkMerge [{
environment.systemPackages = [ environment.systemPackages = [
(pkgs.lib.overrideDerivation pkg (attrs: { (pkgs.lib.overrideDerivation cfg.package (attrs: {
dataDir = cfg.dataDir; dataDir = cfg.dataDir;
})) }))
]; ];
systemd.services."softether-init" = { systemd.services."softether-init" = {
description = "SoftEther VPN services initial task"; description = "SoftEther VPN services initial task";
wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = false; RemainAfterExit = false;
@ -71,11 +80,11 @@ in
for d in vpnserver vpnbridge vpnclient vpncmd; do for d in vpnserver vpnbridge vpnclient vpncmd; do
if ! test -e ${cfg.dataDir}/$d; then if ! test -e ${cfg.dataDir}/$d; then
${pkgs.coreutils}/bin/mkdir -m0700 -p ${cfg.dataDir}/$d ${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 fi
done done
rm -rf ${cfg.dataDir}/vpncmd/vpncmd 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) { (mkIf (cfg.vpnserver.enable) {
systemd.services.vpnserver = { systemd.services.vpnserver = {
description = "SoftEther VPN Server"; description = "SoftEther VPN Server";
after = [ "softether-init.service" "network.target" ]; after = [ "softether-init.service" ];
wants = [ "softether-init.service" ]; requires = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "forking";
ExecStart = "${pkg}/bin/vpnserver start"; ExecStart = "${cfg.package}/bin/vpnserver start";
ExecStop = "${pkg}/bin/vpnserver stop"; ExecStop = "${cfg.package}/bin/vpnserver stop";
}; };
preStart = '' preStart = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver 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 = '' postStop = ''
rm -rf ${cfg.dataDir}/vpnserver/vpnserver rm -rf ${cfg.dataDir}/vpnserver/vpnserver
@ -104,17 +113,17 @@ in
(mkIf (cfg.vpnbridge.enable) { (mkIf (cfg.vpnbridge.enable) {
systemd.services.vpnbridge = { systemd.services.vpnbridge = {
description = "SoftEther VPN Bridge"; description = "SoftEther VPN Bridge";
after = [ "softether-init.service" "network.target" ]; after = [ "softether-init.service" ];
wants = [ "softether-init.service" ]; requires = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "forking";
ExecStart = "${pkg}/bin/vpnbridge start"; ExecStart = "${cfg.package}/bin/vpnbridge start";
ExecStop = "${pkg}/bin/vpnbridge stop"; ExecStop = "${cfg.package}/bin/vpnbridge stop";
}; };
preStart = '' preStart = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge 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 = '' postStop = ''
rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge
@ -125,17 +134,17 @@ in
(mkIf (cfg.vpnclient.enable) { (mkIf (cfg.vpnclient.enable) {
systemd.services.vpnclient = { systemd.services.vpnclient = {
description = "SoftEther VPN Client"; description = "SoftEther VPN Client";
after = [ "softether-init.service" "network.target" ]; after = [ "softether-init.service" ];
wants = [ "softether-init.service" ]; requires = [ "softether-init.service" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "forking";
ExecStart = "${pkg}/bin/vpnclient start"; ExecStart = "${cfg.package}/bin/vpnclient start";
ExecStop = "${pkg}/bin/vpnclient stop"; ExecStop = "${cfg.package}/bin/vpnclient stop";
}; };
preStart = '' preStart = ''
rm -rf ${cfg.dataDir}/vpnclient/vpnclient 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 = '' postStart = ''
sleep 1 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 { }; oracleXE = callPackage ../servers/sql/oracle-xe { };
softether_4_18 = callPackage ../servers/softether/4.18.nix { }; 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; }; qboot = callPackage ../applications/virtualization/qboot { stdenv = stdenv_32bit; };