我正在创建一个小的 Debian 包来安装 systemd 单元文件,特别是*.service文件。
我的包裹看起来像:
myservice
|
|--debian
|- comapat
|- preinst
|- postinst
|- rules
|- myservice.service
Run Code Online (Sandbox Code Playgroud)
当我安装我的软件包时,systemd 服务会自动禁用并且不会启动。
安装后立即systemctl status myservice显示
root@ubuntu-xenial:~# systemctl status myservice
? myservice.service - My Service - echos output and says when it started
Loaded: loaded (/lib/systemd/system/myservice.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Run Code Online (Sandbox Code Playgroud)
但是,当我在没有postinst脚本的情况下安装我的包时,systemd 服务会自动启用,并且它们会在安装后启动。
root@ubuntu-xenial:~# systemctl status myservice
? myservice.service - MyService - echos output and says when it started
Loaded: loaded (/lib/systemd/system/myservice.service; …Run Code Online (Sandbox Code Playgroud)