From 8af56989765aede570d934389d26810cbf99e8de Mon Sep 17 00:00:00 2001
From: Neshura <neshura@noreply.forgejo.neshweb.net>
Date: Sat, 12 Apr 2025 13:17:39 +0000
Subject: [PATCH] Add install script

---
 install.sh | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 install.sh

diff --git a/install.sh b/install.sh
new file mode 100644
index 0000000..b09d43e
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+set -u
+DOMAIN=$1
+USER=$2
+PASS=$3
+if [[ -z "$DOMAIN" ]]; then
+    echo "Must provide Domain as 1st argument" 1>&2
+    exit 1
+fi
+
+if [[ -z "$USER" ]]; then
+    echo "Must provide User as 2nd argument" 1>&2
+    exit 1
+fi
+
+if [[ -z "$PASS" ]]; then
+    echo "Must provide Password as 3rd argument" 1>&2
+    exit 1
+fi
+
+apt-get -y install ssmtp
+sed -i -e 's/=mail/=mail.neshweb.net:587/' /etc/ssmtp/ssmtp.conf # replace 'mail' mailhub with actual mailserver
+sed -i -e 's/hostname=.*/hostname='"$DOMAIN"'/' /etc/ssmtp/ssmtp.conf # replace hostname with actual domain
+sed -i -e 's/#FromLine/FromLine/' /etc/ssmtp/ssmtp.conf
+echo "useSTARTTLS=YES\nAuthUser=$USER@$DOMAIN\nAuthPass=$PASS" >> /etc/ssmpt/ssmtp.conf
+echo "root:noreply@$ALIAS:mail.neshweb.net:587" >> /etc/ssmtp/revaliases # alias 'root' sender to actual noreply sender to be used
+wget "https://forgejo.neshweb.net/Neshura/disk-warn-script/raw/branch/main/disk-warn.sh" -P /root
+chmod +x /root/disk-warn.sh
+(crontab -l 2>/dev/null; echo "0 1 * * * /root/disk-warn.sh") | crontab -