Compare commits

...
Author SHA1 Message Date
push-app-to-main[bot] 831a8a7e1d Add usesend (ct) 2026-11-23 07:42:04 +00:00
2 changed files with 213 additions and 0 deletions

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/usesend/useSend
APP="useSend"
var_tags="${var_tags:-email;smtp;newsletter}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-10}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
export var_github_id="${var_github_id:-}"
export var_github_secret="${var_github_secret:-}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/usesend ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "usesend" "usesend/useSend"; then
msg_info "Stopping useSend"
systemctl stop usesend usesend-smtp
msg_ok "Stopped useSend"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "usesend" "usesend/useSend" "tarball"
NODE_VERSION="22" NODE_MODULE="pnpm@$(jq -r '.packageManager | split("@")[1]' /opt/usesend/package.json)" setup_nodejs
msg_info "Building useSend"
cd /opt/usesend
PUPPETEER_SKIP_DOWNLOAD=true $STD pnpm install --frozen-lockfile --filter "web..." --filter smtp-server
$STD pnpm --filter web db:generate
SKIP_ENV_VALIDATION=true DOCKER_OUTPUT=1 NEXT_TELEMETRY_DISABLED=1 NEXT_PUBLIC_APP_VERSION="v$(cat ~/.usesend)" $STD pnpm --filter "web..." --filter smtp-server build
cp -r apps/web/.next/static apps/web/.next/standalone/apps/web/.next/
cp -r apps/web/public apps/web/.next/standalone/apps/web/
rm -rf apps/web/.next/cache
msg_ok "Built useSend"
msg_info "Migrating useSend Database"
set -a && source /opt/usesend_data/.env && set +a
$STD pnpm --filter web db:migrate-deploy
msg_ok "Migrated useSend Database"
msg_info "Starting useSend"
systemctl start usesend usesend-smtp
msg_ok "Started useSend"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Access it using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:3000${CL}"
echo -e "${INFO}${YW}Login needs a GitHub OAuth app with the callback URL http://${IP}:3000/api/auth/callback/github${CL}"
echo -e "${INFO}${YW}If you skipped it, set GITHUB_ID/GITHUB_SECRET in /opt/usesend_data/.env, then run: systemctl enable --now usesend usesend-smtp${CL}"
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/usesend/useSend
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y redis-server
msg_ok "Installed Dependencies"
PG_VERSION="16" setup_postgresql
PG_DB_NAME="usesend" PG_DB_USER="usesend" setup_postgresql_db
fetch_and_deploy_gh_release "usesend" "usesend/useSend" "tarball"
NODE_VERSION="22" NODE_MODULE="pnpm@$(jq -r '.packageManager | split("@")[1]' /opt/usesend/package.json)" setup_nodejs
msg_info "Building useSend"
cd /opt/usesend
# Puppeteer only comes with the docs tooling (Mintlify) in the root devDependencies; useSend never runs a browser
PUPPETEER_SKIP_DOWNLOAD=true $STD pnpm install --frozen-lockfile --filter "web..." --filter smtp-server
$STD pnpm --filter web db:generate
SKIP_ENV_VALIDATION=true DOCKER_OUTPUT=1 NEXT_TELEMETRY_DISABLED=1 NEXT_PUBLIC_APP_VERSION="v$(cat ~/.usesend)" $STD pnpm --filter "web..." --filter smtp-server build
cp -r apps/web/.next/static apps/web/.next/standalone/apps/web/.next/
cp -r apps/web/public apps/web/.next/standalone/apps/web/
rm -rf apps/web/.next/cache
msg_ok "Built useSend"
if [[ -t 0 && ( -z "${var_github_id:-}" || -z "${var_github_secret:-}" ) ]]; then
echo -e "${INFO}${YW} useSend has no local accounts; logging in needs a GitHub OAuth app.${CL}"
echo -e "${TAB}Create one at https://github.com/settings/developers with this callback URL:"
echo -e "${TAB}${BGN}http://${LOCAL_IP}:3000/api/auth/callback/github${CL}"
if [[ -z "${var_github_id:-}" ]]; then
read -t 300 -rp "${TAB3}GitHub Client ID (Enter to set it up later): " var_github_id || true
fi
if [[ -n "${var_github_id:-}" && -z "${var_github_secret:-}" ]]; then
read -t 300 -rsp "${TAB3}GitHub Client Secret: " var_github_secret || true
echo
fi
fi
msg_info "Configuring useSend"
mkdir -p /opt/usesend_data
cat <<EOF >/opt/usesend_data/.env
PORT=3000
NEXTAUTH_URL=http://${LOCAL_IP}:3000
NEXTAUTH_SECRET=$(openssl rand -base64 32)
DATABASE_URL=postgresql://usesend:${PG_DB_PASS}@localhost:5432/usesend
REDIS_URL=redis://localhost:6379
SMTP_HOST=${LOCAL_IP}
SMTP_USER=usesend
# Sending goes through AWS SES: an IAM user with AmazonSESFullAccess and AmazonSNSFullAccess.
# The SES region and callback URL are set in the web UI under Admin after the first login.
AWS_DEFAULT_REGION=us-east-1
#AWS_ACCESS_KEY_ID=
#AWS_SECRET_ACCESS_KEY=
EOF
if [[ -n "${var_github_id:-}" && -n "${var_github_secret:-}" ]]; then
cat <<EOF >>/opt/usesend_data/.env
GITHUB_ID=${var_github_id}
GITHUB_SECRET=${var_github_secret}
EOF
else
cat <<EOF >>/opt/usesend_data/.env
# useSend has no local accounts. Create a GitHub OAuth app with the callback URL
# http://${LOCAL_IP}:3000/api/auth/callback/github, fill in the two lines below
# (or GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET, which needs an HTTPS domain), then run:
# systemctl enable --now usesend usesend-smtp
#GITHUB_ID=
#GITHUB_SECRET=
EOF
fi
chmod 600 /opt/usesend_data/.env
create_self_signed_cert "usesend"
msg_ok "Configured useSend"
msg_info "Migrating useSend Database"
set -a && source /opt/usesend_data/.env && set +a
$STD pnpm --filter web db:migrate-deploy
msg_ok "Migrated useSend Database"
msg_info "Creating useSend Services"
cat <<EOF >/etc/systemd/system/usesend.service
[Unit]
Description=useSend
After=network.target postgresql.service redis-server.service
Requires=postgresql.service redis-server.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/usesend/apps/web/.next/standalone
EnvironmentFile=/opt/usesend_data/.env
ExecStart=/usr/bin/node apps/web/server.js
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/usesend-smtp.service
[Unit]
Description=useSend SMTP Proxy
After=network.target usesend.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/usesend/apps/smtp-server
Environment=USESEND_BASE_URL=http://127.0.0.1:3000
Environment=SMTP_AUTH_USERNAME=usesend
Environment=USESEND_API_KEY_PATH=/etc/ssl/usesend/usesend.key
Environment=USESEND_API_CERT_PATH=/etc/ssl/usesend/usesend.crt
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
if [[ -n "${var_github_id:-}" && -n "${var_github_secret:-}" ]]; then
systemctl enable -q --now usesend usesend-smtp
fi
msg_ok "Created useSend Services"
motd_ssh
customize
cleanup_lxc