2019-08-09 13:12:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# ssl.sh - for acme.sh edition
|
|
|
|
|
|
|
|
# WARNING!
|
|
|
|
# Check file permissions very carefully so other users cannot access the
|
|
|
|
# certificate copies.
|
2021-02-08 20:21:33 +01:00
|
|
|
# Used with crontab as root, remember `@daily bash /root/acmesh-ssl.bash >/dev/null 2>&1`
|
2019-08-09 16:32:40 +02:00
|
|
|
|
2019-08-09 17:51:05 +02:00
|
|
|
# Echo a warning and exit if NOT running as root
|
2019-08-09 16:32:40 +02:00
|
|
|
if [ "$(id -u)" != "0" ]; then
|
2023-04-06 11:03:10 +02:00
|
|
|
echo "acme.sh prefers root, this script demands it." 1>&2
|
|
|
|
exit 1
|
2019-08-09 16:32:40 +02:00
|
|
|
fi
|
2019-08-09 13:12:58 +02:00
|
|
|
|
2019-08-09 15:03:39 +02:00
|
|
|
# The domain the certs are mainly issued for
|
2021-07-01 11:48:42 +02:00
|
|
|
DOMAINNAME=etro.mikaela.info
|
2019-08-09 16:32:40 +02:00
|
|
|
# Directories
|
|
|
|
SYNCPLAYDIR=/opt/syncplay/ssl
|
|
|
|
MUMBLEDIR=/var/lib/mumble-server/ssl
|
|
|
|
ZNCDIR=/home/znc/.znc/ssl
|
2019-09-13 14:48:03 +02:00
|
|
|
NGINXDIR=/etc/nginx/ssl
|
2021-05-30 13:44:06 +02:00
|
|
|
ORAGONODIR=/home/oragono/oragono-conf
|
2021-06-06 12:05:59 +02:00
|
|
|
WEECHATDIR=/home/mikaela/.weechat/ssl
|
2021-08-07 23:02:30 +02:00
|
|
|
CHRONYDIR=/etc/chrony/tls
|
2019-08-09 15:03:39 +02:00
|
|
|
|
|
|
|
# Where is acme.sh + flags applying to them all
|
2021-07-01 11:48:42 +02:00
|
|
|
ACMESH="/root/.acme.sh/acme.sh --install-cert"
|
2019-08-09 13:12:58 +02:00
|
|
|
|
2019-08-09 16:37:01 +02:00
|
|
|
# restarting with systemctl
|
|
|
|
SYSTEMCTLRESTART="systemctl restart --quiet"
|
2019-09-12 23:51:18 +02:00
|
|
|
SYSTEMCTLRELOAD="systemctl reload --quiet"
|
2019-08-09 16:37:01 +02:00
|
|
|
|
2019-08-09 16:32:40 +02:00
|
|
|
# Start by creating the directories if they don't exist
|
2021-08-07 23:02:30 +02:00
|
|
|
/bin/mkdir -p $SYNCPLAYDIR $MUMBLEDIR $ZNCDIR $NGINXDIR $ORAGONODIR $WEECHATDIR $CHRONYDIR
|
2019-08-09 16:32:40 +02:00
|
|
|
|
2019-08-09 18:54:45 +02:00
|
|
|
# Syncplay - note: reloads certs on every connect like ZNC
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --cert-file $SYNCPLAYDIR/cert.pem --key-file $SYNCPLAYDIR/privkey.pem --ca-file $SYNCPLAYDIR/chain.pem
|
2019-08-09 16:32:40 +02:00
|
|
|
chmod -R 700 $SYNCPLAYDIR
|
|
|
|
chown -R syncplay:root $SYNCPLAYDIR
|
2019-08-09 13:12:58 +02:00
|
|
|
|
|
|
|
# Mumble
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --fullchain-file $MUMBLEDIR/fullchain.cer --key-file $MUMBLEDIR/$DOMAINNAME.key --reloadcmd "$SYSTEMCTLRESTART mumble-server"
|
2019-08-09 15:03:39 +02:00
|
|
|
# future on 1.3.0 +
|
2019-08-09 16:50:36 +02:00
|
|
|
# --reloadcmd "/usr/bin/pkill $(cat /var/run/mumble-server/mumble-server.pid) -USR1"
|
2019-08-09 16:32:40 +02:00
|
|
|
chmod -R 700 $MUMBLEDIR/
|
|
|
|
chown -R mumble-server:mumble-server $MUMBLEDIR/
|
2019-08-09 13:12:58 +02:00
|
|
|
|
2019-08-09 15:03:39 +02:00
|
|
|
# ZNC 1.7.0 (SSLCertFile & SSLKeyFile in znc.conf)
|
2019-08-09 16:32:40 +02:00
|
|
|
# znc.conf's SSLDHParamFile is created by `openssl dhparam 2048 > $ZNCDIRdh.pem`
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --fullchain-file $ZNCDIR/fullchain.cer --key-file $ZNCDIR/$DOMAINNAME.key
|
2019-08-09 16:32:40 +02:00
|
|
|
chmod -R 700 $ZNCDIR
|
|
|
|
chown -R znc:znc $ZNCDIR
|
2019-08-16 16:42:27 +02:00
|
|
|
|
2019-09-13 14:48:03 +02:00
|
|
|
# nginx
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --key-file $NGINXDIR/key.pem --fullchain-file $NGINXDIR/cert.pem --reloadcmd "$SYSTEMCTLRESTART nginx"
|
2019-09-13 14:48:03 +02:00
|
|
|
chmod -R 700 $NGINXDIR
|
|
|
|
chown -R root:root $NGINXDIR
|
2021-05-30 13:44:06 +02:00
|
|
|
|
|
|
|
# Egro IRCd, previously known as Oragono
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --key-file $ORAGONODIR/privkey.pem --fullchain-file $ORAGONODIR/fullchain.pem --reloadcmd "$SYSTEMCTLRELOAD oragono"
|
2021-05-30 13:44:06 +02:00
|
|
|
chmod -R 700 $ORAGONODIR
|
|
|
|
chown -R oragono:oragono $ORAGONODIR
|
2021-06-06 12:05:59 +02:00
|
|
|
|
2021-08-07 23:02:30 +02:00
|
|
|
# WeeChat relay, remember to /relay sslcertkey
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --fullchain-file $WEECHATDIR/fullchain.pem --key-file $WEECHATDIR/privkey.pem
|
2023-05-18 11:25:47 +02:00
|
|
|
cat $WEECHATDIR/{fullchain,privkey}.pem >$WEECHATDIR/relay.pem
|
2021-06-06 12:05:59 +02:00
|
|
|
chmod -R 700 $WEECHATDIR
|
|
|
|
chown -R mikaela:mikaela $WEECHATDIR
|
2021-07-01 11:48:42 +02:00
|
|
|
|
2021-08-07 23:02:30 +02:00
|
|
|
# Chrony (for running as an NTS server)
|
|
|
|
$ACMESH -d $DOMAINNAME -key-file $CHRONYDIR/$DOMAINNAME.key --fullchain-file $CHRONYDIR/$DOMAINNAME.crt --reloadcmd "$SYSTEMCTLRESTART chronyd"
|
|
|
|
chown -R 700 $CHRONYDIR
|
|
|
|
# NOTE THE NAMES!
|
|
|
|
chown -R _chrony:_chrony $CHRONYDIR
|
|
|
|
|
2021-07-01 11:48:42 +02:00
|
|
|
# Another domain
|
|
|
|
DOMAINNAME=T4.114077943.xyz
|
2021-08-07 23:02:30 +02:00
|
|
|
|
|
|
|
# Nginx for another domain
|
2021-07-01 11:48:42 +02:00
|
|
|
$ACMESH -d $DOMAINNAME --key-file $NGINXDIR/$DOMAINNAME.key.pem --fullchain-file $NGINXDIR/$DOMAINNAME.cert.pem --reloadcmd "$SYSTEMCTLRESTART nginx"
|
|
|
|
chmod -R 700 $NGINXDIR
|
|
|
|
chown -R root:root $NGINXDIR
|