Difference between revisions of "Systemd/Services"

From ArchWiki
Jump to: navigation, search
(tftpd)
(apache2: added to package)
Line 8: Line 8:
  
 
This page is useful to publish [[systemd]] service files that are missing in the appropriate package in the repositories. These files can be copied from other distributions or created by yourself.
 
This page is useful to publish [[systemd]] service files that are missing in the appropriate package in the repositories. These files can be copied from other distributions or created by yourself.
 
== apache2 ==
 
{{Note|You have to either reboot or use {{ic|systemd-tmpfiles --create httpd.conf}} for the tmpfile to take effect.}}
 
{{hc|/etc/systemd/system/httpd.service|<nowiki>
 
[Unit]
 
Description=Apache Webserver
 
After=network.target
 
 
[Service]
 
Type=forking
 
EnvironmentFile=/etc/conf.d/apache
 
ExecStart=/usr/sbin/httpd -k start $OPTIONS
 
ExecStop=/usr/sbin/httpd -k graceful-stop $OPTIONS
 
ExecReload=/usr/sbin/httpd -k graceful $OPTIONS
 
Restart=always
 
 
[Install]
 
WantedBy=multi-user.target
 
</nowiki>}}
 
 
{{hc|/etc/tmpfiles.d/httpd.conf|<nowiki>
 
D /var/run/httpd 0755 http http -
 
</nowiki>}}
 
  
 
== atd ==
 
== atd ==

Revision as of 14:37, 20 September 2012

Template:Article summary start Template:Article summary heading Template:Article summary wiki Template:Article summary end

This page is useful to publish systemd service files that are missing in the appropriate package in the repositories. These files can be copied from other distributions or created by yourself.

atd

/etc/systemd/system/atd.service

[Unit]
Description=Execution Queue Daemon

[Service]
ExecStart=/usr/sbin/atd -f

[Install]
WantedBy=multi-user.target

BOINC Daemon

/etc/systemd/system/boinc.service
[Unit]
Description=BOINC Daemon

[Service]
User=boinc
Nice=19
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc --redirectio

[Install]
WantedBy=multi-user.target

CouchDB

/etc/systemd/system/couchdb.service
[Unit]
Description=CouchDB Server

[Service]
User=couchdb
Type=forking
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/run/couchdb ; /bin/chown -R couchdb /var/run/couchdb
ExecStart=/usr/bin/couchdb -b -o /dev/null -e /dev/null
ExecStop=/usr/bin/couchdb -d

[Install]
WantedBy=multi-user.target

distccd

/etc/systemd/system/distccd.service
[Unit]
Description=A distributed C/C++ compiler
Documentation=man:distccd(1)

[Service]
ExecStart=/usr/bin/distccd --daemon --no-detach

[Install]
WantedBy=multi-user.target

dropbear

/etc/systemd/system/dropbear.service

[Unit]
Description=Dropbear SSH server

[Service]
Type=oneshot
ExecStart=/usr/sbin/dropbear -p 22 -d /etc/dropbear/dropbear_dss_host_key -w -P /var/run/dropbear.pid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

irexecd

/etc/systemd/system/irexecd.service

[Unit]
Description=LIRC irexec Daemon
Requires=lircd.service
After=lircd.service

[Service]
Type=forking
ExecStart=/usr/bin/irexec --daemon

[Install]
WantedBy=multi-user.target

References:

lircd

/etc/systemd/system/lircd.service

[Unit]
Description=LIRC Daemon
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lircd.conf
PIDFile=/run/lirc/lircd.pid
ExecStartPre=/bin/mkdir -p /run/lirc
ExecStartPre=/bin/rm -f /dev/lircd
ExecStartPre=/bin/rm -f /run/lirc/lircd
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd

ExecStart=/usr/sbin/lircd -d $LIRC_DEVICE -P /run/lirc/lircd.pid -H $LIRC_DRIVER $LIRC_CONFIGFILE
ExecStopPost=/bin/rm -f /dev/lircd
ExecStopPost=/bin/rm -fR /run/lirc

[Install]
WantedBy=multi-user.target
Note: $LIRC_EXTRAOPTS set in /etc/conf.d/lircd.conf will not work, as lircd will print an error about the argument count. Any extra options should be hardcoded into the unit file.

References:

Logmein Hamachi

/etc/systemd/system/hamachi.service
[Unit]
Description=Hamachi Daemon
After=network.target

[Service]
Type=forking
ExecStart=/opt/logmein-hamachi/bin/hamachid

[Install]
WantedBy=multi-user.target

munin-node

/etc/systemd/system/munin-node.service
[Unit]
Description=Munin Node Server
Documentation=man:munin-node
After=network.target

[Service]
Type=forking
PIDFile=/var/run/munin/munin-node.pid
ExecStart=/usr/bin/munin-node
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Noip

/etc/systemd/system/noip2.service
[Unit]
Description=No-IP Dynamic DNS Update Client
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/noip2

[Install]
WantedBy=multi-user.target

pcscd

/etc/systemd/system/pcscd.service
[Unit]
Description=PC/SC Smart Card Daemon
Requires=pcscd.socket

[Service]
ExecStart=/usr/sbin/pcscd --foreground --auto-exit
ExecReload=/usr/sbin/pcscd --hotplug
StandardOutput=syslog

[Install]
Also=pcscd.socket
/etc/systemd/system/pcscd.socket
[Unit]
Description=PC/SC Smart Card Daemon Activation Socket

[Socket]
ListenStream=/var/run/pcscd/pcscd.comm

[Install]
WantedBy=sockets.target

Reference:

rc.local

/etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Tip: You can replace your rc.local with native systemd units in /etc/systemd/system/.
Note: Also available in initscripts (see: Systemd#Arch_integration).
Note: StandardInput=tty may give strange behaviour: https://bbs.archlinux.org/viewtopic.php?id=147790

redis

/etc/systemd/system/redis.service
[Unit]
Description=Redis Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/redis-server /etc/redis.conf
ExecStop=/bin/kill -15 $MAINPID
PIDFile=/var/run/redis.pid
Restart=always

[Install]
WantedBy=multi-user.target

Taken from https://bbs.archlinux.org/viewtopic.php?id=135922

Remote filesystem mounts

See: Systemd#Remote_filesystem_mounts

smbnetfs

/etc/systemd/system/smbnetfs.service
[Unit]
Description=Mount Samba Shares
After=network.target

[Service]
Environment=HOME=/etc/smbnetfs SMBNETFS_MOUNT_POINT=/mnt/smbnet
EnvironmentFile=/etc/conf.d/smbnetfs
User=nobody
ExecStart=/usr/bin/smbnetfs -f -o allow_other $SMBNETFS_MOUNT_POINT
ExecStop=/bin/fusermount -u $SMBNETFS_MOUNT_POINT

[Install]
WantedBy=multi-user.target

Static Ethernet network

This is a custom service file for static Ethernet configurations. For other configurations, see Systemd#Network

/etc/conf.d/network
interface=eth0
address=192.168.0.1
netmask=24
broadcast=192.168.0.255
gateway=192.168.0.254
/etc/systemd/system/network.service
[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target

tftpd

/etc/systemd/system/tftpd.service
[Unit]
Description=TFTPD Server
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/in.tftpd
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target
Note: Seems that this way of starting doesn't source /etc/conf.d/tftpd and you have to add -l -s /var/tftpboot/ flags to ExecStart.

tpfand

/etc/systemd/system/tpfand.service
[Unit]
Description=ThinkPad Fan Control

[Service]
Type=forking
PIDFile=/var/run/tpfand.pid
ExecStart=/usr/sbin/tpfand

[Install]
WantedBy=multi-user.target

verynice

/etc/systemd/system/verynice.service
[Unit]
Description=A tool for dynamically adjusting the nice-level of processes

[Service]
Type=forking
PIDFile=/var/run/verynice.pid
ExecStart=/usr/sbin/verynice -d /var/run/verynice.pid
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

VideoLAN 2.0

Change the User parameter.

/etc/systemd/system/vlc.service
[Unit]
Description=VideoOnLAN Service
After=network.target

[Service]
Type=forking
User=nobody
ExecStart=/usr/bin/cvlc --intf=lua --lua-intf=http --daemon --http-port 8090
Restart=on-abort

[Install]
WantedBy=multi-user.target

See also