telebit-relay.js/dist/etc/systemd/system/telebit-relay.service

67 lines
2.5 KiB
SYSTEMD
Raw Permalink Normal View History

2018-05-23 11:12:39 +00:00
# Pre-req
2018-06-11 17:24:57 +00:00
# sudo adduser telebit --home /opt/telebit-relay
# sudo mkdir -p /opt/telebit-relay/
# sudo chown -R telebit:telebit /opt/telebit-relay/
2018-05-23 11:12:39 +00:00
[Unit]
Description=Telebit Relay
2018-06-11 17:24:57 +00:00
Documentation=https://git.coolaj86.com/coolaj86/telebit-relay.js/
2018-05-23 11:12:39 +00:00
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
# Restart on crash (bad signal), but not on 'clean' failure (error exit code)
# Allow up to 3 restarts within 10 seconds
# (it's unlikely that a user or properly-running script will do this)
Restart=on-failure
2018-05-23 11:12:39 +00:00
StartLimitInterval=10
StartLimitBurst=3
# User and group the process will run as
# (git is the de facto standard on most systems)
User=telebit
Group=telebit
2018-06-11 17:24:57 +00:00
WorkingDirectory=/opt/telebit-relay
2018-05-23 11:12:39 +00:00
# custom directory cannot be set and will be the place where gitea exists, not the working directory
2018-06-11 17:24:57 +00:00
ExecStart=/opt/telebit-relay/bin/node /opt/telebit-relay/bin/telebit-relay.js --config /opt/telebit-relay/etc/telebit-relay.yml
2018-05-23 11:12:39 +00:00
ExecReload=/bin/kill -USR1 $MAINPID
# Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings.
# Unmodified gitea is not expected to use more than this.
LimitNOFILE=1048576
LimitNPROC=64
# Use private /tmp and /var/tmp, which are discarded after gitea stops.
PrivateTmp=true
# Use a minimal /dev
PrivateDevices=true
# Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
ProtectHome=true
# Make /usr, /boot, /etc and possibly some more folders read-only.
ProtectSystem=full
# ... except /opt/gitea because we want a place for the database
# and /var/log/gitea because we want a place where logs can go.
# This merely retains r/w access rights, it does not add any new.
# Must still be writable on the host!
2018-06-14 20:40:43 +00:00
ReadWriteDirectories=/opt/telebit-relay
2018-05-23 11:12:39 +00:00
# Note: in v231 and above ReadWritePaths has been renamed to ReadWriteDirectories
2018-06-11 17:24:57 +00:00
; ReadWritePaths=/opt/telebit-relay /etc/telebit
2018-05-23 11:12:39 +00:00
# The following additional security directives only work with systemd v229 or later.
# They further retrict privileges that can be gained by gitea.
# Note that you may have to add capabilities required by any plugins in use.
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
# Caveat: Some features may need additional capabilities.
# For example an "upload" may need CAP_LEASE
; CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_LEASE
; AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_LEASE
; NoNewPrivileges=true
[Install]
WantedBy=multi-user.target