Compare commits

..

2 Commits

Author SHA1 Message Date
CanbiZ (MickLesk) f055380c03 cleanup 2026-11-07 21:02:06 +01:00
push-app-to-main[bot] 77db45ecad Add firefox-syncserver (ct) 2026-11-07 19:56:53 +00:00
4 changed files with 165 additions and 111 deletions
-57
View File
@@ -1,57 +0,0 @@
#!/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/chattocorp/chatto
APP="Chatto"
var_tags="${var_tags:-chat;messaging}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-8}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/chatto ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "chatto" "chattocorp/chatto"; then
msg_info "Stopping Service"
systemctl stop chatto
msg_ok "Stopped Service"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "chatto" "chattocorp/chatto" "prebuild" "latest" "/opt/chatto" "chatto_Linux_$(arch_resolve x86_64 arm64).tar.gz"
chmod +x /opt/chatto/chatto
msg_info "Starting Service"
systemctl start chatto
msg_ok "Started Service"
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 "${TAB}${GATEWAY}${BGN}http://${IP}:4000${CL}"
+66
View File
@@ -0,0 +1,66 @@
#!/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/mozilla-services/syncstorage-rs
APP="Firefox-Syncserver"
var_tags="${var_tags:-sync;firefox}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-3072}"
var_disk="${var_disk:-10}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
#var_arm64="${var_arm64:-yes}" # built from source, nothing x86-only, but not yet run on arm64
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /usr/local/bin/syncserver ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "firefox-syncserver" "mozilla-services/syncstorage-rs"; then
msg_info "Stopping Firefox Syncserver"
systemctl stop firefox-syncserver
msg_ok "Stopped Firefox Syncserver"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "firefox-syncserver" "mozilla-services/syncstorage-rs" "tarball"
setup_rust
msg_info "Building Firefox Syncserver (Patience)"
cd /opt/firefox-syncserver
$STD cargo build --release --locked --no-default-features --features=syncstorage-db/postgres --features=tokenserver-db/postgres --features=py_verifier
cp target/release/syncserver /usr/local/bin/syncserver
rm -rf target
$STD uv venv --python /usr/bin/python3 /opt/firefox-syncserver/.venv
$STD uv pip install --python /opt/firefox-syncserver/.venv/bin/python pyfxa tokenlib cryptography
msg_ok "Built Firefox Syncserver"
msg_info "Starting Firefox Syncserver"
systemctl start firefox-syncserver
msg_ok "Started Firefox Syncserver"
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}In Firefox, set identity.sync.tokenserver.uri in about:config to:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:8000/1.0/sync/1.5${CL}"
-54
View File
@@ -1,54 +0,0 @@
#!/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/chattocorp/chatto
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
fetch_and_deploy_gh_release "chatto" "chattocorp/chatto" "prebuild" "latest" "/opt/chatto" "chatto_Linux_$(arch_resolve x86_64 arm64).tar.gz"
chmod +x /opt/chatto/chatto
msg_info "Configuring Chatto"
mkdir -p /opt/chatto_data
cd /opt/chatto
$STD ./chatto init
mv /opt/chatto/chatto.toml /opt/chatto_data/chatto.toml
sed -i \
-e "/^\[webserver\]/,/^\[/ s|^url = .*|url = 'http://${LOCAL_IP}:4000'|" \
-e "/^\[nats.embedded\]/,/^\[/ s|^data_dir = .*|data_dir = '/opt/chatto_data/data'|" \
-e '/^# \[operator_api\]$/,/^$/ { s|^# \[operator_api\]$|[operator_api]|; s|^# enabled = false$|enabled = true| }' \
/opt/chatto_data/chatto.toml
msg_ok "Configured Chatto"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/chatto.service
[Unit]
Description=Chatto
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/chatto
ExecStart=/opt/chatto/chatto run -c /opt/chatto_data/chatto.toml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now chatto
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc
+99
View File
@@ -0,0 +1,99 @@
#!/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/mozilla-services/syncstorage-rs
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 \
build-essential \
pkg-config \
libssl-dev \
libpq-dev \
python3-dev
msg_ok "Installed Dependencies"
PG_VERSION="18" setup_postgresql
PG_DB_NAME="syncserver" PG_DB_USER="syncserver" setup_postgresql_db
setup_rust
setup_uv
fetch_and_deploy_gh_release "firefox-syncserver" "mozilla-services/syncstorage-rs" "tarball"
msg_info "Building Firefox Syncserver (Patience)"
cd /opt/firefox-syncserver
$STD cargo build --release --locked --no-default-features --features=syncstorage-db/postgres --features=tokenserver-db/postgres --features=py_verifier
cp target/release/syncserver /usr/local/bin/syncserver
rm -rf target
$STD uv venv --python /usr/bin/python3 /opt/firefox-syncserver/.venv
$STD uv pip install --python /opt/firefox-syncserver/.venv/bin/python pyfxa tokenlib cryptography
msg_ok "Built Firefox Syncserver"
msg_info "Configuring Firefox Syncserver"
mkdir -p /opt/firefox-syncserver_data
cat <<EOF >/opt/firefox-syncserver_data/.env
SYNC_HOST=0.0.0.0
SYNC_PORT=8000
SYNC_MASTER_SECRET=$(openssl rand -hex 32)
SYNC_HUMAN_LOGS=true
RUST_LOG=info
SYNC_SYNCSTORAGE__DATABASE_URL=postgres://syncserver:${PG_DB_PASS}@127.0.0.1:5432/syncserver
SYNC_SYNCSTORAGE__GLEAN_ENABLED=false
SYNC_TOKENSERVER__ENABLED=true
SYNC_TOKENSERVER__RUN_MIGRATIONS=true
SYNC_TOKENSERVER__DATABASE_URL=postgres://syncserver:${PG_DB_PASS}@127.0.0.1:5432/syncserver
SYNC_TOKENSERVER__NODE_TYPE=postgres
SYNC_TOKENSERVER__FXA_EMAIL_DOMAIN=api.accounts.firefox.com
SYNC_TOKENSERVER__FXA_OAUTH_SERVER_URL=https://oauth.accounts.firefox.com
SYNC_TOKENSERVER__INIT_NODE_URL=http://${LOCAL_IP}:8000
EOF
chmod 600 /opt/firefox-syncserver_data/.env
cat <<'EOF' >/opt/firefox-syncserver_data/nodes.sql
SELECT to_regclass('nodes') IS NOT NULL AS ready \gset
\if :ready
UPDATE nodes SET node = :'url'
WHERE id = (SELECT min(id) FROM nodes)
AND NOT EXISTS (SELECT 1 FROM nodes WHERE node = :'url');
UPDATE users SET nodeid = (SELECT id FROM nodes WHERE node = :'url')
WHERE nodeid <> (SELECT id FROM nodes WHERE node = :'url');
DELETE FROM nodes WHERE node <> :'url';
\endif
EOF
msg_ok "Configured Firefox Syncserver"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/firefox-syncserver.service
[Unit]
Description=Firefox Syncserver
After=network.target postgresql.service
Wants=postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/firefox-syncserver
EnvironmentFile=/opt/firefox-syncserver_data/.env
Environment=PYTHONPATH=/opt/firefox-syncserver/.venv/lib/python3.13/site-packages
ExecStartPre=/usr/bin/psql -1 -q -v ON_ERROR_STOP=1 -v url=\${SYNC_TOKENSERVER__INIT_NODE_URL} -f /opt/firefox-syncserver_data/nodes.sql \${SYNC_TOKENSERVER__DATABASE_URL}
ExecStart=/usr/local/bin/syncserver
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now firefox-syncserver
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc