prosody

- xmpp.supernets.org
git clone git://git.acid.vegas/prosody.git
Log | Files | Refs | Archive | README

deploy (2811B)

      1 #!/bin/bash
      2 # Prosody Container Script - developed by acidvegas (https://git.acid.vegas/prosody)
      3 
      4 set -xev
      5 
      6 create_container() {
      7 	NAME=$1
      8 
      9 	incus storage create $NAME-pool dir
     10 	incus launch images:debian/12 $NAME-container -s $NAME-pool	
     11 	incus config set $NAME-container boot.autostart true
     12 	sleep 10 # Delay to allow the container to start and get an IP address from the DHCP server
     13 	incus exec $NAME-container -- apt update  -y
     14 	incus exec $NAME-container -- apt upgrade -y
     15 	incus exec $NAME-container -- apt install -y git nano unattended-upgrades wget
     16 	incus exec $NAME-container -- useradd -m -s /bin/bash agent
     17 	incus exec $NAME-container -- journalctl --vacuum-time=1d
     18 	incus exec $NAME-container -- sh -c 'printf "[Journal]\nStorage=volatile\nSplitMode=none\nRuntimeMaxUse=500K\n" > /etc/systemd/journald.conf'
     19 	incus exec $NAME-container -- systemctl restart systemd-journald
     20 }
     21 
     22 setup_prosody() {
     23     PORT_C2S=5222 # Default 5222
     24     PORT_S2S=5269 # Default 5269
     25     CONTAINER_IP=$(incus list | grep gotify-container | awk '{print $6}')
     26 
     27     create_container prosody
     28     
     29     incus config set prosody-container boot.autostart true
     30     incus config device add prosody-container prosody-c2s-port proxy listen=tcp:0.0.0.0:$PORT_C2S connect=tcp:$CONTAINER_IP:5222
     31     incus config device add prosody-container prosody-s2s-port proxy listen=tcp:0.0.0.0:$PORT_S2S connect=tcp:$CONTAINER_IP:5269
     32 
     33     incus exec prosody-container -- apt-get install certbot libevent-dev prosody -y
     34 
     35     incus exec prosody-container -- certbot certonly --standalone -d xmpp.supernets.org -d muc.supernets.org -m nobody@no.name --agree-tos --non-interactive --no-eff-email
     36 
     37     incus exec prosody-container -- sh -c 'printf "[Unit]\nDescription=cerbot renewal\n\n[Service]\nType=oneshot\nExecStart=/usr/bin/certbot renew -n --quiet --agree-tos --deploy-hook \"prosodyctl --root cert import /etc/letsencrypt/live\"\n" > /etc/systemd/system/certbot.service'
     38 	incus exec prosody-container -- sh -c 'printf "[Unit]\nDescription=cerbot renewal timer\n\n[Timer]\nOnCalendar=0/12:00:00\nRandomizedDelaySec=1h\nPersistent=true\n\n[Install]\nWantedBy=timers.target\n" > /etc/systemd/system/certbot.timer'
     39 
     40 	incus exec prosody-container -- systemctl enable certbot.timer
     41 	incus exec prosody-container -- systemctl start certbot.timer
     42 
     43     incus file push prosody.cfg.lua prosody-container:/etc/prosody/prosody.cfg.lua
     44 
     45     # Need to set the certifcate permissions to allow prosody to read it
     46     #sudo ln -s /etc/letsencrypt/live/xmpp.supernets.org/privkey.pem /etc/prosody/certs/xmpp.supernets.org.key
     47     #sudo ln -s /etc/letsencrypt/live/xmpp.supernets.org/privkey.pem /etc/prosody/certs/xmpp.supernets.org.key
     48 
     49     incus exec prosody-container -- systemctl enable prosody
     50     incus exec prosody-container -- systemctl start prosody
     51 }