在树莓派安装了seafile,设置了网盘应用,设置seafile由systemctl管理。
1、创建启动,停止脚本
#!/bin/bash
cd /usr/local/src/seafile-server_7.0.5_stable_pi/seafile-server-7.0.5
sudo ./seafile.sh start
sudo ./seahub.sh start
#!/bin/bash
cd /usr/local/src/seafile-server_7.0.5_stable_pi/seafile-server-7.0.5
sudo ./seafile.sh stop
sudo ./seahub.sh stop
2、创建service文件
root@raspberrypi:/usr/lib/systemd/system# cat seafile.service
[Unit]
Description=Seafile Service
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=/usr/local/src/seafile-server_7.0.5_stable_pi/seafile-server-7.0.5/start_seafile.sh
ExecStop=/usr/local/src/seafile-server_7.0.5_stable_pi/seafile-server-7.0.5/stop_seafile.sh
[Install]
WantedBy=multi-user.target
注意Type要设置oneshot代表启动一次,RemainAfterExit=yes,表示启动后仍然是active状态,否则service状态错误,不能设置restart配置,否则提示seafile.service: Service has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.
3、设置开机启动,并且启动服务
systemctl enable seafile.service
systemctl start seafile.service
4、查看服务状态