openSUSE:Systemd 服务文件收集
使用 systemd - Systemd 状态 - 管理 Systemd - Systemd 打包指南 - 如何编写 Systemd 服务文件 - Systemd 服务文件收集 - Systemd 侦错
本页面收集了 systemd 的服务文件,这些文件最初由 openSUSE 的打包者/开发者创建,其中包含针对本发行版的特殊更改。
注: 建议至少先检查以下页面,确保其他发行版不存在现成的使用了 systemd 的包。因为 systemd 的服务是可以跨发行版的,我们不需要重复造轮子。此页面上的内容基本上是为其他发行版的打包者/开发者准备的,他们希望直接使用我们的贡献成果。
- Fedora 的 Systemd 服务文件
- Arch Linux 的 Systemd 服务文件
- Gentoo 的 Systemd 服务文件
- 一些 Debian 的 Systemd 服务文件
- 一些 ubuntu 的 Systemd 服务文件
再注: 最佳的贡献方式是将这些服务文件提交到上游。所以请至少尝试一次。与上游开发者合作并不困难 :-)
关于如何编写 systemd 服务文件: openSUSE:How to write a systemd service (等 marguerite 从中文翻译成英文)
请确保此页面 按字母顺序排序,谢谢。
Networking
DNS
dnscrypt
# This file is part of dnscrypt
# Author: Marguerite Su <i@marguerite.su>
# Version: 1.2.0
# Description: dnscrypt is a tool developed by OpenDNS company.
# it aims to encrypt your dns query to OpenDNS to protect from
# middle-man attack or DNS polution(commonly see in China).
# it publics free (also redistributes free).
# in openSUSE it's licensed under SuSE-Permissive(Non-free ware).
# details see its documentation.
[Unit]
Description=Secure connection between your computer and DNS resolver(openDNS)
After=network.target
[Service]
Type=forking
PIDFile=/var/run/dnscrypt-proxy.pid
ExecStart=/usr/sbin/dnscrypt-proxy --daemonize \
-p /var/run/dnscrypt-proxy.pid \
-l /var/log/dnscrypt-proxy.log
Restart=on-abort
[Install]
WantedBy=multi-user.target
IPv6
He.net
# Author: Marguerite Su <i@marguerite.su>
# Use Case: You registered a He.net IPv6 tunnel, and want it connected automatically
# without entering commands every startup.
[Unit]
Description=Daemon to start He.net IPv6
Wants=network-online.target
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ip tunnel add he-ipv6 mode sit \
remote 66.220.19.42 local 108.171.7.158 ttl 255 ; \
/usr/sbin/ip link set he-ipv6 up ; \
/usr/sbin/ip addr add 2001:475:c:1183::2/64 dev he-ipv6 ; \
/usr/sbin/ip route add ::/0 dev he-ipv6 ; \
/usr/sbin/ip -6 addr
ExecStop=/usr/sbin/ip route delete ::/0 dev he-ipv6 ; \
/usr/sbin/ip -6 addr del 2001:475:c:1183::2/64 dev he-ipv6 ; \
/usr/sbin/ip link set he-ipv6 down ; \
/usr/sbin/ip tunnel del he-ipv6
[Install]
WantedBy=multi-user.target
请将 `remote`, `local`, `ipv6` 地址改为你所需要的。以上配置用于 openSUSE 中文论坛,所以请不要大量传播。
VPN
strongswan
Strongswan 在 openSUSE 中已经有 systemd 服务文件用于自启动了。此服务文件是用来自动设置"允许","伪装"和"转发"的端口的。因为其配置的虚拟 IP 池使用了 iptables。
# Author: Marguerite Su <i@marguerite.su>
# Use Case: You have a strongswan vpn. You don't want to input iptables commands
# everytime upon server restart.
[Unit]
Description=Scripts to setup iptables rules for strongswan
Wants=network-online.target
# has to start before strongswan, or it doesn't know the routes.
# so you can connect, but no traffic.
Before=strongswan.service
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/iptables -A INPUT -p udp --dport 500 -j ACCEPT ; \
/usr/sbin/iptables -A INPUT -p udp --dport 4500 -j ACCEPT ; \
/usr/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE ; \
/usr/sbin/iptables -A FORWARD -s 10.0.0.0/24 -j ACCEPT ; \
/bin/sh -c 'echo -n 1 > /proc/sys/net/ipv4/ip_forward'
ExecStop=/bin/sh -c 'echo -n 0 > /proc/sys/net/ipv4/ip_forward' ; \
/usr/sbin/iptables -D FORWARD -s 10.0.0.0/24 -j ACCEPT ; \
/usr/sbin/iptables -t nat -D POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE ; \
/usr/sbin/iptables -D INPUT -p udp --dport 4500 -j ACCEPT ; \
/usr/sbin/iptables -D INPUT -p udp --dport 500 -j ACCEPT
[Install]
WantedBy=multi-user.target
需要将 "10.0.0.0/24" 改为你需要的 _rightsourceip_.