Frohes Neues Jahr, Habr!
Am 1. Januar beschäftigen sich alle normalen Menschen mit Aufschub, der Zerstörung des strategischen Bestands von Olivier und anderen Dingen, die nicht mit physischem oder intellektuellem Stress zusammenhängen. Ich hatte vor, mich dieser Neujahrsarmee anzuschließen, aber es hat nicht funktioniert!
Habr ist für alles verantwortlich!
…. ! , , — , . , !
?
systemd, «systemd », , , , , . systemd 100500 , , ( ;-), .
-
, , , - .
« »
(/etc/systemd/system/ssh-chat.service
):
[Unit]
Description=SSH Chat Service
After=network.target network-online.target
[Service]
#
User=ssh-chat
Group=ssh-chat
Type=Simple
ExecStart=/usr/local/bin/ssh-chat --admin=/etc/ssh-chat/admins --bind=0.0.0.0:22 --log /var/log/ssh-chat.log --motd=/etc/ssh-chat/motd
# .
# on-failure — .
Restart=on-failure
# , .
RestartSec=1
# Capablities . -
# (< 1000)
AmbientCapablities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multiuser.target
systemd-sysusers.service(/etc/sysusers.d/ssh-chat.conf
):
u ssh-chat - "SSH Chat user" /etc/ssh-chat
# :
# u :
# ssh-chat : username
# - : UID[:GID] UID/GID < 1000
# "SSH Chat user" : , "-", .
# /etc/ssh-chat : Home Directory
# -- login shell. /usr/bin/nologin
:
sudo systemctl restart systemd-sysusers.service && sudo systemctl enable --now ssh-chat
« »
(/etc/systemd/system/domoticz.service
):
[Unit]
Description=Domoticz Daemon
After=network.target
[Service]
User=http
Group=http
#
# . "+" .
ExecStartPre=+/usr/bin/install -d -m 0700 -o http -g http /var/run/domoticz
ExecStart=/opt/domoticz/domoticz -www 8080 -pidfile /var/run/domoticz/domoticz.pid
PIDFile=/var/run/domoticz/domoticz.pid
WorkingDirectory=/opt/domoticz
# , "", 5 .
RestartSec=5
Restart=on-failure
[Install]
WantedBy=multi-user.target
:
sudo systemctl enable --now domoticz
?
systemd, , - , . , , «»(transient) , and more, more... « » . :
man systemd.unit man systemd.service man systemd.exec man systemctl man sysusers.d man systemd-sysusers
Und ein kleines Geheimnis für einen Snack. Eines meiner Lieblingsmanas: man systemd.directives
- Eine Anleitung zu allen Konfigurationsanweisungen, auf die Sie beim Erlernen von systemd stoßen können.
Nochmals ein frohes neues Jahr, Habr! Und benutze die richtigen Werkzeuge!
PS: Es wurde ein Link zu dem Mann auf systemd.exec hinzugefügt . Irgendwie habe ich ihn ein wenig vergessen.