Package IONOS-DynDNS repository Fix spigot-server's ExecStop Enable Firewall but allow port 25565
This commit is contained in:
parent
8e0c6266af
commit
9b622e6e3e
@ -55,6 +55,9 @@
|
|||||||
# $ nix search wget
|
# $ nix search wget
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
vim
|
vim
|
||||||
|
tmux
|
||||||
|
bottom
|
||||||
|
(pkgs.callPackage ../packages/ionos-dyndns.nix {})
|
||||||
];
|
];
|
||||||
|
|
||||||
# List services that you want to enable:
|
# List services that you want to enable:
|
||||||
@ -78,14 +81,15 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: ddclient + a nice domain
|
# DynDNS stuff. IONOS has a (proprietary?) API for this,
|
||||||
|
# so we're using a Python script from the interwebs :shrug:
|
||||||
|
# TODO: Config using agenix
|
||||||
|
|
||||||
# Open ports in the firewall.
|
# Open ports in the firewall.
|
||||||
# networking.firewall.allowedTCPPorts = [ ... ];
|
networking.firewall.allowedTCPPorts = [ 25565 ];
|
||||||
# networking.firewall.allowedUDPPorts = [ ... ];
|
networking.firewall.allowedUDPPorts = [ 25565 ];
|
||||||
# Or disable the firewall altogether.
|
# Or disable the firewall altogether.
|
||||||
# TODO: Only enable minecraft outside
|
# networking.firewall.enable = false;
|
||||||
networking.firewall.enable = false;
|
|
||||||
|
|
||||||
# TODO: Backups
|
# TODO: Backups
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
nixos-rebuild -I nixos-config=configuration.nix --target-host 192.168.0.206 --use-remote-sudo switch
|
nixos-rebuild -I nixos-config=configuration.nix --target-host gilgamesh --use-remote-sudo switch
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
|
ionos-dyndns = pkgs.callPackage ../packages/ionos-dyndns.nix {};
|
||||||
spigot-server = pkgs.callPackage ../packages/spigot-server.nix {};
|
spigot-server = pkgs.callPackage ../packages/spigot-server.nix {};
|
||||||
cfg = config.services.spigot;
|
cfg = config.services.spigot;
|
||||||
name = "spigot";
|
name = "spigot";
|
||||||
@ -39,16 +40,43 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.spigot-server = rec {
|
systemd = {
|
||||||
|
services.spigot-server = {
|
||||||
description = "Spigot Minecraft server";
|
description = "Spigot Minecraft server";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "${cfg.user}";
|
User = "${cfg.user}";
|
||||||
|
|
||||||
|
Sockets = "spigot-server.socket";
|
||||||
|
StandardInput = "socket";
|
||||||
|
StandardOutput = "journal";
|
||||||
|
StandardError = "journal";
|
||||||
|
|
||||||
inherit StateDirectory;
|
inherit StateDirectory;
|
||||||
WorkingDirectory = "/var/lib/${StateDirectory}";
|
WorkingDirectory = "/var/lib/${StateDirectory}";
|
||||||
ExecStart = "${spigot-server}/bin/spigot-server";
|
ExecStart = "${spigot-server}/bin/spigot-server -nogui";
|
||||||
|
ExecStop = [
|
||||||
|
"${pkgs.bash}/bin/bash -c '${pkgs.coreutils}/bin/echo save-all > /run/spigot-server.stdin'"
|
||||||
|
"${pkgs.bash}/bin/bash -c '${pkgs.coreutils}/bin/echo stop > /run/spigot-server.stdin'"
|
||||||
|
# Wait for the main process to exit
|
||||||
|
# If we don't do this systemd tries to nudge Java to stop, causing a race condition
|
||||||
|
# that leads to an ungraceful shutdown
|
||||||
|
"${pkgs.coreutils}/bin/echo \"Waiting for \${MAINPID} to exit...\""
|
||||||
|
"${pkgs.bash}/bin/bash -c 'while ${pkgs.coreutils}/bin/kill -s 0 $MAINPID 2>/dev/null; do sleep 0.5; done'"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sockets.spigot-server = {
|
||||||
|
description = "Spigot Minecraft server socket for commands and stuff";
|
||||||
|
unitConfig = {
|
||||||
|
# Automatically start and stop socket along with the service
|
||||||
|
PartOf = "spigot-server.service";
|
||||||
|
};
|
||||||
|
socketConfig = {
|
||||||
|
ListenFIFO = "/run/spigot-server.stdin";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
29
nix/packages/ionos-dyndns.nix
Normal file
29
nix/packages/ionos-dyndns.nix
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
fetchFromGitHub,
|
||||||
|
makeWrapper,
|
||||||
|
stdenv,
|
||||||
|
# Runtime Dependencies
|
||||||
|
python3
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
pythonWithDeps = python3.withPackages (p: [p.requests]);
|
||||||
|
in stdenv.mkDerivation rec {
|
||||||
|
pname = "ionos-dyndns";
|
||||||
|
# Packaging time, not commit time
|
||||||
|
version = "20231118";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "lazaroblanc";
|
||||||
|
repo = "IONOS-DynDNS";
|
||||||
|
rev = "6c090ab928ce8d6eaa28b09614995b036ad60027";
|
||||||
|
hash = "sha256-rabDuKuPvzcMltnCSvc5kDjcDhv7sXxbDLWw3/hdSmk=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
|
buildCommand = ''
|
||||||
|
install -Dm755 $src/ionos_dyndns.py $out/lib/ionos_dyndns.py
|
||||||
|
|
||||||
|
makeWrapper ${pythonWithDeps}/bin/python3 $out/bin/ionos-dyndns \
|
||||||
|
--add-flags $out/lib/ionos_dyndns.py
|
||||||
|
'';
|
||||||
|
}
|
@ -18,7 +18,6 @@ in stdenv.mkDerivation rec {
|
|||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
install -Dm644 $src $out/lib/spigot-${version}.jar
|
install -Dm644 $src $out/lib/spigot-${version}.jar
|
||||||
|
|
||||||
mkdir -p $out/bin
|
|
||||||
makeWrapper ${jre}/bin/java $out/bin/spigot-server \
|
makeWrapper ${jre}/bin/java $out/bin/spigot-server \
|
||||||
--argv0 spigot-server \
|
--argv0 spigot-server \
|
||||||
--add-flags "${javaFlags}" \
|
--add-flags "${javaFlags}" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user