¿Por qué los dueños de negocios prefieren las bicicletas a las soluciones listas para usar? O sobre systemd, parte 0

¡Feliz año nuevo, Habr!







El 1 de enero, toda la gente normal se dedica a la dilación, la destrucción del stock estratégico de Olivier y otras cosas que no están relacionadas con el estrés físico o intelectual. Así que estaba planeando unirme al ejército de este Año Nuevo, ¡pero no funcionó!





¡Habr tiene la culpa de todo!

…. ! , , — , . , !





  github. , ,  /usr/bin



. , , .









… ( sleep-)





©









, Domoticz . , watchdog cron.









… ( , )









5 , , Domoticz ,





©









?

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
      
      



Y un pequeño secreto para picar. Uno de mis manas favoritos: man systemd.directives



- Una guía de todas las directivas de configuración que puede encontrar mientras aprende sobre systemd.





Una vez más ¡Feliz año nuevo, Habr! ¡Y use las herramientas adecuadas!





PD: Se agregó un enlace al hombre en systemd.exec . De alguna manera me olvidé un poco de él.








All Articles