minecraft: added auto restart every 4 AM
This commit is contained in:
parent
129e3dac84
commit
691e8e9ec8
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
name = "minecraft";
|
name = "minecraft";
|
||||||
podman = config.profile.podman;
|
podman = config.profile.podman;
|
||||||
|
@ -46,29 +46,37 @@ in
|
||||||
EOF 200
|
EOF 200
|
||||||
'';
|
'';
|
||||||
|
|
||||||
system.activationScripts."podman-${name}" = ''
|
systemd =
|
||||||
mkdir -p ${rootVolume}
|
let serviceName = "podman-${name}"; in
|
||||||
chown ${uid}:${gid} ${rootVolume}
|
{
|
||||||
'';
|
tmpfiles.settings."${serviceName}-mount".${rootVolume}.d = {
|
||||||
|
group = config.profile.user.name;
|
||||||
|
mode = "0755";
|
||||||
|
user = config.profile.user.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
services."${serviceName}-autorestart" = {
|
||||||
|
description = "Podman container ${name} autorestart";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = "${pkgs.podman}/bin/podman restart podman-${name}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
timers."${serviceName}-autorestart" = {
|
||||||
|
description = "Podman container ${name} autorestart";
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "*-*-* 04:00:00";
|
||||||
|
};
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
virtualisation.oci-containers.containers.${name} = {
|
virtualisation.oci-containers.containers.${name} = {
|
||||||
inherit image;
|
inherit image;
|
||||||
hostname = name;
|
hostname = name;
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
user = "${uid}:${gid}";
|
user = "${uid}:${gid}";
|
||||||
environment = {
|
|
||||||
# UID = uid;
|
|
||||||
# GID = gid;
|
|
||||||
# EULA = "TRUE";
|
|
||||||
# TZ = "Asia/Jakarta";
|
|
||||||
# SERVER_NAME = "Hutasuhut";
|
|
||||||
# DEFAULT_PLAYER_PERMISSION_LEVEL = "operator";
|
|
||||||
# LEVEL_NAME = "Hutasuhut";
|
|
||||||
# MAX_THREADS = "0"; # Use as many as possible
|
|
||||||
# ALLOW_LIST_USERS = strings.concatStringsSep "," (
|
|
||||||
# map (user: "${user.username}:${user.xuid}") users
|
|
||||||
# );
|
|
||||||
};
|
|
||||||
ports = [
|
ports = [
|
||||||
# Java Edition Ports
|
# Java Edition Ports
|
||||||
"25565:25565/udp"
|
"25565:25565/udp"
|
||||||
|
|
Loading…
Reference in a new issue