ProxmoxVED/ct/tor-snowflake.sh
2025-12-26 14:01:14 +01:00

79 lines
2.3 KiB
Bash

#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: KernelSailor
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://snowflake.torproject.org/
APP="tor-snowflake"
var_tags="privacy;proxy;tor"
var_cpu="1"
var_ram="512"
var_disk="4"
var_os="debian"
var_version="13"
var_unprivileged="1"
var_nesting="0"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/snowflake ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if ! id snowflake &>/dev/null; then
msg_error "snowflake user not found!"
exit
fi
msg_info "Updating Container OS"
$STD apt-get update
$STD apt-get -y upgrade
msg_ok "Updated Container OS"
RELEASE=$(curl -fsSL https://gitlab.torproject.org/api/v4/projects/tpo%2Fanti-censorship%2Fpluggable-transports%2Fsnowflake/releases | jq -r '.[0].tag_name' | sed 's/^v//')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping Service"
systemctl stop snowflake-proxy
msg_ok "Stopped Service"
msg_info "Updating Go"
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
setup_go
msg_ok "Updated Go"
msg_info "Updating ${APP} to v${RELEASE}"
cd /opt/snowflake || exit
$STD git fetch --all
$STD git checkout "v${RELEASE}"
chown -R snowflake:snowflake /opt/snowflake
$STD sudo -u snowflake go build -o proxy ./proxy
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to v${RELEASE}"
msg_info "Starting Service"
systemctl start snowflake-proxy
msg_ok "Started Service"
msg_ok "Updated successfully!"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}."
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}Tor Snowflake setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Snowflake proxy is running as a systemd service.${CL}"
echo -e "${INFO}${YW} Check status: systemctl status snowflake-proxy${CL}"