From ef5c2fb379e3fa26ba4dd1d5db3c0faec3790094 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 13 Mar 2026 13:39:18 -0500 Subject: [PATCH] cleanup --- INSTALL.md | 73 ++++++++++++++++++++++++++++++++++++++++ README.md | 1 + email-sig-manager.xml | 34 +++++++++++++++++++ src/routes/admin.js | 10 ++++-- src/services/gmailApi.js | 3 +- src/services/renderer.js | 2 -- 6 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 INSTALL.md create mode 100644 email-sig-manager.xml diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..d821a39 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,73 @@ +# Unraid Installation Guide - Email Signature Manager + +Follow these steps to deploy the Email Signature Manager on your Unraid server using a local build and the Unraid Docker GUI. + +## Step 1: Clone the Repository +SSH into your Unraid server (or use the Terminal in the WebUI) and run: + +```bash +cd /mnt/user/appdata +git clone https://github.com/JasonStedwell/email-sig-manager.git email-sigs +cd email-sigs +``` + +## Step 2: Add your Google Service Account Key +Place your `sa.json` file (acquired from Google Cloud Console) into the `secrets` folder. + +```bash +# Example if copying via SMB from Windows: +# Copy sa.json to \\UNRAID-IP\appdata\email-sigs\secrets\sa.json +``` + +## Step 3: Build the Image Locally +In the terminal, run the build command to create your local Docker image: + +```bash +cd /mnt/user/appdata/email-sigs +docker build -t email-sigs:latest . +``` + +## Step 4: Configure the Container in Unraid GUI +Now, go to the **Docker** tab in your Unraid WebUI and click **Add Container** at the bottom. Fill out the fields exactly as follows: + +- **Name:** `email-sig-manager` +- **Repository:** `email-sigs:latest` +- **Network Type:** `Bridge` +- **WebUI Port:** `3000` + +### Add Path Mappings +Click **+ Add another Path, Port, Variable, Label or Device** for each of these: + +1. **Secrets Path** + - **Name:** `Secrets` + - **Container Path:** `/app/secrets` + - **Host Path:** `/mnt/user/appdata/email-sigs/secrets` + - **Access Mode:** `Read Only` + +2. **Data Path** + - **Name:** `Data` + - **Container Path:** `/app/data` + - **Host Path:** `/mnt/user/appdata/email-sigs/data` + - **Access Mode:** `Read/Write` + +### Add Variables +Click **+ Add another Path, Port, Variable, Label or Device** for each of these: + +1. **Admin Email** + - **Key:** `GOOGLE_ADMIN_EMAIL` + - **Value:** *(your Workspace admin email, e.g., jason@messagepoint.tv)* + +2. **Admin Username** + - **Key:** `ADMIN_USERNAME` + - **Value:** `admin` + +3. **Admin Password** + - **Key:** `ADMIN_PASSWORD` + - **Value:** *(your chosen password)* + +4. **Cron Schedule** (Optional) + - **Key:** `CRON_SCHEDULE` + - **Value:** `0 2 * * *` + +## Step 5: Click Apply +Once all fields are filled, click **Apply**. Unraid will start the container using your locally built image. You can then access the UI at `http://UNRAID-IP:3000`. diff --git a/README.md b/README.md index 8333bd0..56915fb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A self-hosted, Dockerized Google Workspace email signature manager. Runs as a single container — designed for Unraid but works on any Docker host. +See [INSTALL.md](INSTALL.md) for Unraid-specific instructions. ## Features diff --git a/email-sig-manager.xml b/email-sig-manager.xml new file mode 100644 index 0000000..2fdcd44 --- /dev/null +++ b/email-sig-manager.xml @@ -0,0 +1,34 @@ + + + Email Signature Manager + email-sigs:latest + + bridge + + sh + false + https://github.com/JasonStedwell/email-sig-manager/issues + https://github.com/JasonStedwell/email-sig-manager + A self-hosted, Dockerized Google Workspace email signature manager. Pulls user data from Google Workspace and pushes signatures directly to Gmail. + Tools: Productivity + http://[IP]:[PORT:3000] + + https://raw.githubusercontent.com/google/material-design-icons/master/png/communication/email/materialicons/48dp/1x/baseline_email_black_48dp.png + + + + + + + + 3000 + /mnt/user/appdata/email-sigs/secrets + /mnt/user/appdata/email-sigs/data + /mnt/user/appdata/email-sigs/public/assets + + my_customer + admin + + 0 2 * * * + production + diff --git a/src/routes/admin.js b/src/routes/admin.js index b1a99ec..c971c59 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -38,9 +38,13 @@ router.post('/preview', (req, res) => { const { templateHtml, userData } = req.body; try { const Handlebars = require('handlebars'); - Handlebars.registerHelper('if_val', function(val, options) { - return val && val.trim() !== '' ? options.fn(this) : options.inverse(this); - }); + // Helper is registered globally when renderer.js is loaded, but + // since this is a separate require, we'll ensure it's there. + if (!Handlebars.helpers.if_val) { + Handlebars.registerHelper('if_val', function(val, options) { + return val && val.trim() !== '' ? options.fn(this) : options.inverse(this); + }); + } const template = Handlebars.compile(templateHtml); const rendered = template(userData || { fullName: 'Jason Stedwell', diff --git a/src/services/gmailApi.js b/src/services/gmailApi.js index f9ad23e..a641217 100644 --- a/src/services/gmailApi.js +++ b/src/services/gmailApi.js @@ -5,7 +5,8 @@ async function pushSignatureToUser(userEmail, signatureHtml) { const auth = getAuthClient(userEmail); const gmail = google.gmail({ version: 'v1', auth }); const sendAsRes = await gmail.users.settings.sendAs.list({ userId: 'me' }); - const primary = sendAsRes.data.sendAs.find(s => s.isPrimary); + const sendAsList = sendAsRes.data.sendAs || []; + const primary = sendAsList.find(s => s.isPrimary); if (!primary) throw new Error(`No primary sendAs found for ${userEmail}`); await gmail.users.settings.sendAs.patch({ userId: 'me', diff --git a/src/services/renderer.js b/src/services/renderer.js index 9816887..7e359d7 100644 --- a/src/services/renderer.js +++ b/src/services/renderer.js @@ -1,5 +1,3 @@ -const Handlebars = require('handlebars'); -const fs = require('fs'); const path = require('path'); Handlebars.registerHelper('if_val', function(val, options) {