1
0

2 Revīzijas e94a53c8c6 ... 45546bea7c

Autors SHA1 Ziņojums Datums
  Pi 45546bea7c add theming and systemd service 3 nedēļas atpakaļ
  Pi c910dc4063 refactor sms-sendmail.sh to read better 3 nedēļas atpakaļ

+ 21 - 0
convert.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+set -euo pipefail
+for i in ""
+do
+	(
+		cd "site/static/$i"
+		for x in 48 72 96 144 192 512
+		do
+			rsvg-convert -w "$x" -h "$x" -d 300 sms.svg -o "$x".png
+			continue
+			MAGICK_USE_DELEGATE=rsvg convert \
+				-density 3200 \
+				-background none \
+				-antialias \
+				-resize "${x}x${x}" \
+				-strip \
+				sms.svg "$x".png \
+			&& : "Use ImageMagick to convert SVG to PNG"
+		done
+	)
+done

+ 5 - 0
run.sh

@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+sqlpage/target/debug/sqlpage -w site -c config/sqlpage.yaml &
+. .venv/bin/activate
+python3 webhook.py &
+wait

+ 1 - 0
site/index.sql

@@ -0,0 +1 @@
+SELECT 'redirect' AS component, '/conv' AS link;

BIN
site/static/144.png


BIN
site/static/192.png


BIN
site/static/48.png


BIN
site/static/512.png


BIN
site/static/72.png


BIN
site/static/96.png


+ 50 - 0
site/static/manifest.json

@@ -0,0 +1,50 @@
+{
+  "id": "/sms",
+  "name": "SMS over Email and IP",
+  "short_name": "SMSoE&IP",
+  "description": "Seceive SMS over IP via webhook and send SMS via email",
+  "start_url": "/conv",
+  "shortcuts": [ ],
+  "scope": "/",
+  "theme_color": "#2fb344",
+  "background_color": "black",
+  "display": "standalone",
+  "icons": [
+    {
+      "src": "/static/512.png",
+      "sizes": "512x512",
+      "type": "image/png",
+      "purpose": "any"
+    },
+    {
+      "src": "/static/192.png",
+      "sizes": "192x192",
+      "type": "image/png",
+      "purpose": "any"
+    },
+    {
+      "src": "/static/144.png",
+      "sizes": "144x144",
+      "type": "image/png",
+      "purpose": "any"
+    },
+    {
+      "src": "/static/96.png",
+      "sizes": "96x96",
+      "type": "image/png",
+      "purpose": "any"
+    },
+    {
+      "src": "/static/72.png",
+      "sizes": "72x72",
+      "type": "image/png",
+      "purpose": "any"
+    },
+    {
+      "src": "/static/48.png",
+      "sizes": "48x48",
+      "type": "image/png",
+      "purpose": "any"
+    }
+  ]
+}

+ 1 - 0
site/static/sms.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-device-mobile-message"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M11 3h10v8h-3l-4 2v-2h-3l0 -8" /><path d="M15 16v4a1 1 0 0 1 -1 1h-8a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1h2" /><path d="M10 18v.01" /></svg>

+ 3 - 0
site/theme.sql

@@ -1,3 +1,6 @@
+SET ":favicon" = '/static/sms.svg';
+SET ":image" = '/static/sms.svg';
+SET ":manifest" = '/static/manifest.json';
 SELECT 'shell' AS component
 , 'dark' AS theme
 , :title AS title

+ 14 - 8
sms-sendmail.sh

@@ -13,19 +13,25 @@ sender="wyn3-14@shandan.one"
 recipient="sms@voip.ms"
 subject="$TO.$CODE.$FROM"
 
-store_to_db(){
-	export MESSAGE FROM TO
-	python3 <<'EOF'
+printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE" \
+	| reformail \
+		-I"To: $recipient" \
+		-I"From: $sender" \
+		-I"Subject: $subject" \
+		-I"Content-Type: text/plain" -d1 \
+	| sendmail -f "$sender" -t
+
+export MESSAGE FROM TO
+python3 <<'EOF'
 import sqlite3
 from os import environ as env
 params = [ env.get(x) for x in ('FROM', 'TO', 'MESSAGE') ]
 conn = sqlite3.connect('sms.db')
 cursor = conn.cursor()
-cursor.execute(""" INSERT INTO outbox (sent, "from", "to", payload) VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?) """, params)
+cursor.execute("""
+INSERT INTO outbox (sent, "from", "to", payload)
+VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?)
+""", params)
 conn.commit()
 conn.close()   
 EOF
-}
-
-reformail -I"To: $recipient" -I"From: $sender" -I"Subject: $subject" -I"Content-Type: text/plain" -d1 < <(printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE") | sendmail -f "$sender" -t
-store_to_db

+ 14 - 0
smsoip.service

@@ -0,0 +1,14 @@
+[Unit]
+Description=SMS over IP and email
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=%h/git/smpp-sqlite/run.sh
+WorkingDirectory=%h/git/smpp-sqlite/
+Restart=always
+RestartSec=10
+
+[Install]
+WantedBy=default.target
+