Difference between revisions of "Systemd/Services"

From ArchWiki
Jump to: navigation, search
(hddtemp: has been added to package)
(lircd: Adding $LIRC_DEVICE $LIRC_DRIVER $LIRC_CONFIGFILE EnvironmentFile=/etc/conf.d/lircd.conf)
Line 77: Line 77:
 
[Service]
 
[Service]
 
Type=forking
 
Type=forking
 +
EnvironmentFile=/etc/conf.d/lircd.conf
 
PIDFile=/run/lirc/lircd.pid
 
PIDFile=/run/lirc/lircd.pid
 
ExecStartPre=/bin/mkdir -p /run/lirc
 
ExecStartPre=/bin/mkdir -p /run/lirc
Line 83: Line 84:
 
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd
 
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd
  
ExecStart=/usr/sbin/lircd -d /dev/lirc0 -P /run/lirc/lircd.pid
+
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 -f /dev/lircd
 
ExecStopPost=/bin/rm -fR /run/lirc
 
ExecStopPost=/bin/rm -fR /run/lirc
Line 90: Line 91:
 
WantedBy=multi-user.target
 
WantedBy=multi-user.target
 
</nowiki>}}
 
</nowiki>}}
 +
 +
{{Note|$LIRC_EXTRAOPTS does not work, so if you have anything configured in $LIRC_EXTRAOPTS in {{ic|/etc/conf.d/lircd.conf}}, it won't be used. I tried to use Network connection via $LIRC_EXTRAOPTS (-c <ip>), lircd then always complains about the argument count. Hardcoding in the unit file works as solution.}}
  
 
== xinit ==
 
== xinit ==

Revision as of 00:06, 4 June 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text

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

Currently, systemd is mostly at feature parity with Arch's initscripts. However, a lot more testing is needed. If you would like to help out, you can fork the initscripts-systemd or systemd-arch-units git repos and submit pull requests for your additions. This wiki page can serve as a staging area for these files.

If you have any questions, ask in the thread in the Arch forums.

mysqld

Note: Mysqld requires an extra script to work properly. Remember to chmod +x /usr/bin/mysqld-post before attempting to start mysqld.service
/etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server

[Service]
User=mysql
ExecStart=/usr/bin/mysqld
ExecStartPost=/usr/bin/mysqld-post
Restart=always
Timeout=30

[Install]
WantedBy=multi-user.target
/usr/bin/mysqld-post
#!/bin/sh
while true; do
	response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
	echo "$response" | grep -q "mysqld is alive" && break
	sleep 1
done
/etc/tmpfiles.d/mysqld.conf
d /var/run/mysqld 0755 mysql mysql -

mythbackend

/etc/systemd/system/mythbackend.service
[Unit]
Description=MythTV backend service
After=network.target mysqld.service

# Uncomment if using either webserver for mythweb
# Wants=httpd.service
# Wants=lighttpd.service

[Service]
Type=simple
Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
Environment=HOME=/usr/share/mythtv
User=mythtv
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv

[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 does not work, so if you have anything configured in $LIRC_EXTRAOPTS in /etc/conf.d/lircd.conf, it won't be used. I tried to use Network connection via $LIRC_EXTRAOPTS (-c <ip>), lircd then always complains about the argument count. Hardcoding in the unit file works as solution.

xinit

See: Systemd#Using_service_file

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
Note: Also available through the unrecommended initscripts-systemd. See: Systemd#Arch_integration.

apache2

/etc/systemd/system/httpd.service
[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
/etc/tmpfiles.d/httpd.conf
D /var/run/httpd 0755 http http -

postfix

/etc/systemd/system/postfix.service
[Unit]
Description=Mail Daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/postfix start
ExecStop=/usr/sbin/postfix stop
ExecReload=/usr/sbin/postfix reload

[Install]
WantedBy=multi-user.target

memcached

/etc/systemd/system/memcached.service
[Unit]
Description=memcached daemon
After=network.target

[Service]
EnvironmentFile=/etc/conf.d/memcached
PIDFile=/var/run/memcached.pid
ExecStart=/usr/bin/memcached -d -P /var/run/memcached.pid -u $MEMCACHED_USER $MEMCACHED_ARGS
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

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

Remote filesystem mounts

See: Systemd#Remote_filesystem_mounts

distccd

/etc/systemd/system/distccd.service
[Unit]
Description=distcc

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/distccd
ExecStart=/usr/bin/distccd --daemon $DISTCC_ARGS
ExecStop=/bin/kill -15 $MAINPID

[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

cpufreq

/etc/systemd/system/cpufreq.service
[Unit]
Description=CPU frequency scaling daemon

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/cpufreq
ExecStart=/usr/bin/cpufreq-set -r -g $governor -d $min_freq -u $max_freq

[Install]
WantedBy=multi-user.target

This sets the governor of all cores to the one specified in /etc/conf.d/cpufreq.

If you use the freq option, use to the following instead:

/etc/systemd/system/cpufreq.service
[Unit]
Description=CPU frequency scaling daemon

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/cpufreq
ExecStart=/usr/bin/cpufreq-set -r -f $freq

[Install]
WantedBy=multi-user.target

apcupsd

/etc/systemd/system/apcupsd.service
[Unit]
Description=APC UPS Monitor

[Service]
ExecStart=/sbin/apcupsd -b

[Install]
WantedBy=multi-user.target

healthd

/etc/systemd/system/healthd.service
[Unit]
Description=Sensors Health Daemon
Requires=lm_sensors.service

[Service]
Type=forking
ExecStart=/usr/sbin/healthd

[Install]
WantedBy=multi-user.target

rsync daemon

/etc/systemd/system/rsyncd.service
[Unit]
Description=rsync daemon

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

[Install]
WantedBy=multi-user.target

transmission daemon

Set User= to the user the daemon should run as.

/etc/systemd/system/transmissiond.service
[Unit]
Description=transmission daemon

[Service]
User=transmission
ExecStart=/usr/bin/transmission-daemon -f

[Install]
WantedBy=multi-user.target

See also

systemd