Debian - установка rc.local: различия между версиями

Материал из support.qbpro.ru
м (Vix переименовал страницу Debian 9 "stretch" - установка rc.local в Debian - установка rc.local без оставления перенаправления)
Нет описания правки
 
Строка 24: Строка 24:
  :>/etc/systemd/system/rc-local.service
  :>/etc/systemd/system/rc-local.service


* Содержимое:
* Для '''Debin (9-10)''' Содержимое:
  #  SPDX-License-Identifier: LGPL-2.1-or-later
  #  SPDX-License-Identifier: LGPL-2.1-or-later
  #
  #
Строка 48: Строка 48:
  RemainAfterExit=yes
  RemainAfterExit=yes
  GuessMainPID=no
  GuessMainPID=no
   
 
* Для '''Debin (11-12)''' Содержимое:
  [Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
 
[Service]
Type=idle
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
 
[Install]
WantedBy=multi-user.target
 
 
* Даем права на запуск: /etc/rc.local
* Даем права на запуск: /etc/rc.local
  chmod +x /etc/rc.local
  chmod +x /etc/rc.local

Текущая версия от 13:44, 15 января 2024

Установка службы авто-запуска в системе rc.local

  • Создаем файл: /etc/rc.local
:>/etc/rc.local
  • Содержимое:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
 
exit 0
  • Создаем файл: /etc/systemd/system/rc-local.service
:>/etc/systemd/system/rc-local.service
  • Для Debin (9-10) Содержимое:
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
  • Для Debin (11-12) Содержимое:
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
 
[Service]
Type=idle
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
 
[Install]
WantedBy=multi-user.target


  • Даем права на запуск: /etc/rc.local
chmod +x /etc/rc.local
  • Включаем сервис rc-local:
systemctl enable rc-local
systemctl start rc-local.service
  • Проверяем работу:
systemctl status rc-local.service
  • Вывод правильный:
● rc-local.service - /etc/rc.local Compatibility
  Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset:
 Drop-In: /lib/systemd/system/rc-local.service.d
          └─debian.conf
  Active: active (exited) since Tue 2017-07-25 11:10:09 EEST; 7s ago
 Process: 1148 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

Июл 25 11:10:09 webserver systemd[1]: Starting /etc/rc.local Compatibility...
Июл 25 11:10:09 webserver systemd[1]: Started /etc/rc.local Compatibility.

Ресурсы: