cl.install: improve service file based on sample

This commit is contained in:
openoms
2021-12-20 15:07:39 +00:00
parent ff3ab2585e
commit cf65db6023

View File

@@ -49,29 +49,50 @@ fi
sudo systemctl stop ${netprefix}lightningd sudo systemctl stop ${netprefix}lightningd
sudo systemctl disable ${netprefix}lightningd sudo systemctl disable ${netprefix}lightningd
# based on https://github.com/ElementsProject/lightning/blob/master/contrib/init/lightningd.service
echo "# Create /etc/systemd/system/${netprefix}lightningd.service" echo "# Create /etc/systemd/system/${netprefix}lightningd.service"
echo " echo "
[Unit] [Unit]
Description=c-lightning daemon on $CHAIN Description=c-lightning daemon on $CHAIN
Requires=${netprefix}bitcoind.service
After=${netprefix}bitcoind.service
Wants=network-online.target
After=network-online.target
[Service] [Service]
ExecStartPre=-/home/admin/config.scripts/cl.check.sh prestart $CHAIN ExecStartPre=-/home/admin/config.scripts/cl.check.sh prestart $CHAIN
ExecStart=/bin/sh -c '${passwordInput}/usr/local/bin/lightningd\ ExecStart=/bin/sh -c '${passwordInput}/usr/local/bin/lightningd \\
--conf=${CLCONF} ${encryptedHSMoption}' --conf=${CLCONF} ${encryptedHSMoption} \\
--pid-file=/run/lightningd/${netprefix}lightningd.pid'
# Creates /run/lightningd owned by bitcoin
RuntimeDirectory=lightningd
User=bitcoin User=bitcoin
Group=bitcoin Group=bitcoin
Type=simple Type=forking
Restart=always PIDFile=/run/lightningd/${netprefix}lightningd.pid
Restart=on-failure
TimeoutSec=240 TimeoutSec=240
RestartSec=30 RestartSec=30
StandardOutput=null StandardOutput=null
StandardError=journal StandardError=journal
# Hardening measures # Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target