ArchLinux / Manjaro 开启 rclocal.l

2019-04-12  本文已影响0人  iridescently
#!/bin/bash

echo 创建服务文件
sudo touch /usr/lib/systemd/system/rc-local.service
sudo echo '''[Unit]
Description="/etc/rc.local Compatibility" 

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target''' >  /usr/lib/systemd/system/rc-local.service

echo 启用服务
sudo systemctl enable rc-local.service

echo 创建rc.local文件
sudo touch  /etc/rc.local
echo '''#!/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.
# -----------替换横杠间的内容为需要开机执行的命令---------------
echo rc.local 文件正常!
# -----------替换横杠间的内容为需要开机执行的命令---------------
exit 0''' > /etc/rc.local

echo 授权
sudo chmod +x /etc/rc.local

echo 测试
sudo sh /etc/rc.local

Reference:Archlinux systemd 开机执行rc.local

上一篇下一篇

猜你喜欢

热点阅读