Skip to content

Instantly share code, notes, and snippets.

@xenithorb
Last active January 30, 2018 18:39
Show Gist options
  • Save xenithorb/0dc5e8304a6e42a293feb01ac1f50a10 to your computer and use it in GitHub Desktop.
Save xenithorb/0dc5e8304a6e42a293feb01ac1f50a10 to your computer and use it in GitHub Desktop.
This is an instanced service, usage: `systemctl enable weechat@<user>` will start a tmux session with weechat for the <user>
# /etc/systemd/system/[email protected]
[Unit]
Description=Weechat bouncer
After=network-online.target
[Service]
User=%i
Environment=SOCKET_NAME=%p
Environment=LC_CERT_FILE=/etc/letsencrypt/live/%H/all.pem
Environment=LOCAL_CERT_PATH=/home/%i/.weechat/ssl
Environment=LOCAL_CERT_FILE=relay.pem
Type=forking
Restart=on-failure
PermissionsStartOnly=true
WorkingDirectory=/home/%i
ExecStartPre=/bin/mkdir -p ${LOCAL_CERT_PATH}
ExecStartPre=/bin/cp -f ${LC_CERT_FILE} ${LOCAL_CERT_PATH}/${LOCAL_CERT_FILE}
ExecStartPre=/bin/bash -c '/bin/chown -R --quiet %i: $${LOCAL_CERT_PATH%/*}'
ExecStartPre=/bin/bash -c '/sbin/restorecon -RF $${LOCAL_CERT_PATH%/*}'
ExecStart=/usr/bin/tmux -L ${SOCKET_NAME} new-session -d -s %i weechat
#ExecStop=/usr/bin/tmux -L ${SOCKET_NAME} kill-session -t %i
ExecReload=/bin/bash -c 'cat < ${LC_CERT_FILE} > ${LOCAL_CERT_PATH}/${LOCAL_CERT_FILE}'
ExecReload=/bin/bash -c "echo '*/relay sslcertkey' > /home/%i/.weechat/weechat_fifo_*"
ExecReload=/bin/bash -c "echo '*/reload' > /home/%i/.weechat/weechat_fifo_*"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment