Compare commits
5 Commits
58e40897a5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1189ec810d | ||
|
|
a64c28761b | ||
|
|
00433e664f | ||
|
|
e50abcb9a2 | ||
|
|
1d4c57c737 |
165
start.sh
165
start.sh
@@ -684,6 +684,151 @@ sync_dir "$APP_DIR/server/mail-templates" "$MUSEUM_RUNTIME_DIR/mail-templates"
|
|||||||
sync_dir "$APP_DIR/server/assets" "$MUSEUM_RUNTIME_DIR/assets"
|
sync_dir "$APP_DIR/server/assets" "$MUSEUM_RUNTIME_DIR/assets"
|
||||||
sync_dir "$APP_DIR/data" "$MUSEUM_RUNTIME_DIR/data"
|
sync_dir "$APP_DIR/data" "$MUSEUM_RUNTIME_DIR/data"
|
||||||
|
|
||||||
|
customize_mail_templates() {
|
||||||
|
local base_template="$MUSEUM_RUNTIME_DIR/mail-templates/base.html"
|
||||||
|
if [ ! -f "$base_template" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
cat > "$base_template" <<EOF_BASE_TEMPLATE
|
||||||
|
{{define "base"}}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f0f1f3;
|
||||||
|
font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 27px;
|
||||||
|
margin: 0;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
background: #f4f4f4f4;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
border-color: #ddd;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 30px;
|
||||||
|
max-width: 525px;
|
||||||
|
margin: 0 auto;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
background: #0055d4;
|
||||||
|
border-radius: 3px;
|
||||||
|
text-decoration: none !important;
|
||||||
|
color: #fff !important;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 10px 30px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #888;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gutter {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0055d4;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
.wrap {
|
||||||
|
max-width: auto;
|
||||||
|
}
|
||||||
|
.gutter {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="gutter" style="padding: 4px"> </div>
|
||||||
|
<div class="wrap" style="background-color: #ffffff; padding: 2px 30px 30px 30px; max-width: 525px; margin: 0 auto; border-radius: 5px; font-size: 16px;">
|
||||||
|
<main>
|
||||||
|
{{block "content" .}} Default Content {{end}}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="footer">
|
||||||
|
<p style="margin-bottom: 4px;">
|
||||||
|
<strong><a href="$BASE_URL" target="_blank" style="color: #555;">$BASE_URL</a></strong>
|
||||||
|
</p>
|
||||||
|
<p style="margin: 0;">
|
||||||
|
This email was sent by a self-hosted instance of the open source Ente application.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{end}}
|
||||||
|
EOF_BASE_TEMPLATE
|
||||||
|
chown cloudron:cloudron "$base_template"
|
||||||
|
|
||||||
|
python3 - "$MUSEUM_RUNTIME_DIR/mail-templates" "$BASE_URL" <<'PY'
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
template_dir = Path(sys.argv[1])
|
||||||
|
base_url = sys.argv[2]
|
||||||
|
|
||||||
|
footer_html = f'''
|
||||||
|
<div class="footer" style="text-align: center; font-size: 12px; color: #888; padding: 16px;">
|
||||||
|
<p style="margin-bottom: 4px;">
|
||||||
|
<strong><a href="{base_url}" target="_blank" style="color: #555;">{base_url}</a></strong>
|
||||||
|
</p>
|
||||||
|
<p style="margin: 0;">This email was sent by a self-hosted instance of the open source Ente application.</p>
|
||||||
|
</div>
|
||||||
|
</body>'''.lstrip()
|
||||||
|
|
||||||
|
pattern = re.compile(r'<div class="footer".*?</div>\s*</body>', re.DOTALL | re.IGNORECASE)
|
||||||
|
|
||||||
|
for html_path in template_dir.rglob("*.html"):
|
||||||
|
original = html_path.read_text()
|
||||||
|
updated = pattern.sub(footer_html, original)
|
||||||
|
if updated != original:
|
||||||
|
html_path.write_text(updated)
|
||||||
|
# Ownership will be fixed later by the caller
|
||||||
|
PY
|
||||||
|
find "$MUSEUM_RUNTIME_DIR/mail-templates" -type f -name "*.html" -exec chown cloudron:cloudron {} +
|
||||||
|
}
|
||||||
|
|
||||||
|
customize_mail_templates
|
||||||
|
|
||||||
if [ ! -x "$MUSEUM_BIN" ]; then
|
if [ ! -x "$MUSEUM_BIN" ]; then
|
||||||
log ERROR "Museum binary not found at $MUSEUM_BIN"
|
log ERROR "Museum binary not found at $MUSEUM_BIN"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -704,7 +849,7 @@ http:
|
|||||||
apps:
|
apps:
|
||||||
public-albums: "$ALBUMS_URL"
|
public-albums: "$ALBUMS_URL"
|
||||||
embed-albums: "$EMBED_URL"
|
embed-albums: "$EMBED_URL"
|
||||||
public-locker: "$SHARE_URL"
|
public-locker: "$EMBED_URL"
|
||||||
accounts: "$ACCOUNTS_URL"
|
accounts: "$ACCOUNTS_URL"
|
||||||
cast: "$CAST_URL"
|
cast: "$CAST_URL"
|
||||||
family: "$FAMILY_URL"
|
family: "$FAMILY_URL"
|
||||||
@@ -978,6 +1123,16 @@ PHOTOS_HOST_MATCHERS="$PHOTOS_HOST"
|
|||||||
if [ "$APP_FQDN" != "$PHOTOS_HOST" ]; then
|
if [ "$APP_FQDN" != "$PHOTOS_HOST" ]; then
|
||||||
PHOTOS_HOST_MATCHERS="$PHOTOS_HOST_MATCHERS $APP_FQDN"
|
PHOTOS_HOST_MATCHERS="$PHOTOS_HOST_MATCHERS $APP_FQDN"
|
||||||
fi
|
fi
|
||||||
|
if [ "$APP_FQDN" != "$PHOTOS_HOST" ]; then
|
||||||
|
BASE_DOMAIN_REDIRECT="
|
||||||
|
@base_app_host host ${APP_FQDN}
|
||||||
|
handle @base_app_host {
|
||||||
|
redir https://${PHOTOS_HOST}{uri}
|
||||||
|
}
|
||||||
|
"
|
||||||
|
else
|
||||||
|
BASE_DOMAIN_REDIRECT=""
|
||||||
|
fi
|
||||||
cat > "$CADDY_CONFIG" <<EOF_CADDY
|
cat > "$CADDY_CONFIG" <<EOF_CADDY
|
||||||
{
|
{
|
||||||
admin off
|
admin off
|
||||||
@@ -1013,6 +1168,7 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
|||||||
respond 204
|
respond 204
|
||||||
}
|
}
|
||||||
|
|
||||||
|
${BASE_DOMAIN_REDIRECT}\
|
||||||
handle_path /api/* {
|
handle_path /api/* {
|
||||||
@api_cors_subdomain header Origin *
|
@api_cors_subdomain header Origin *
|
||||||
header @api_cors_subdomain {
|
header @api_cors_subdomain {
|
||||||
@@ -1063,7 +1219,10 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@user_api path_regexp user_api ^/users($|/.*)
|
@user_api {
|
||||||
|
host ${PHOTOS_HOST_MATCHERS}
|
||||||
|
path_regexp user_api ^/users($|/.*)
|
||||||
|
}
|
||||||
handle @user_api {
|
handle @user_api {
|
||||||
reverse_proxy localhost:8080 {
|
reverse_proxy localhost:8080 {
|
||||||
trusted_proxies private_ranges
|
trusted_proxies private_ranges
|
||||||
@@ -1075,6 +1234,7 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@museum_api_get {
|
@museum_api_get {
|
||||||
|
host ${PHOTOS_HOST_MATCHERS}
|
||||||
method GET HEAD
|
method GET HEAD
|
||||||
path_regexp museum_api_get ^/(admin|authenticator|billing|cast|collections|custom-domain|diff|discount|email-hash|emails-from-hashes|emergency-contacts|family|file|file-link|files|fire|info|job|mail|metrics|multipart-upload-urls|offers|options|pass-info|passkeys|public-collection|push|queue|remote-store|storage-bonus|thumbnail|trash|unknown-api|upload-urls|user|user-entity|verify-password)(/|$)
|
path_regexp museum_api_get ^/(admin|authenticator|billing|cast|collections|custom-domain|diff|discount|email-hash|emails-from-hashes|emergency-contacts|family|file|file-link|files|fire|info|job|mail|metrics|multipart-upload-urls|offers|options|pass-info|passkeys|public-collection|push|queue|remote-store|storage-bonus|thumbnail|trash|unknown-api|upload-urls|user|user-entity|verify-password)(/|$)
|
||||||
}
|
}
|
||||||
@@ -1089,6 +1249,7 @@ cat > "$CADDY_CONFIG" <<EOF_CADDY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@write_methods {
|
@write_methods {
|
||||||
|
host ${PHOTOS_HOST_MATCHERS}
|
||||||
not method GET
|
not method GET
|
||||||
not method HEAD
|
not method HEAD
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user