change App location
This commit is contained in:
parent
85652adee9
commit
654047e08a
@ -15,6 +15,8 @@ var_version="${var_version:-13}"
|
|||||||
var_unprivileged="${var_unprivileged:-1}"
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
var_nesting="${var_nesting:-0}"
|
var_nesting="${var_nesting:-0}"
|
||||||
|
|
||||||
|
SNOWFLAKEUSER="snowflake"
|
||||||
|
|
||||||
header_info "$APP"
|
header_info "$APP"
|
||||||
variables
|
variables
|
||||||
color
|
color
|
||||||
@ -31,24 +33,21 @@ function update_script() {
|
|||||||
msg_ok "Updated Container OS"
|
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//')
|
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
|
VERSION_FILE="/home/${SNOWFLAKEUSER}/.${APP}_version"
|
||||||
msg_info "Stopping Service"
|
if [[ ! -f "${VERSION_FILE}" ]] || [[ "${RELEASE}" != "$(cat "${VERSION_FILE}")" ]]; then
|
||||||
systemctl stop snowflake-proxy
|
systemctl stop snowflake-proxy
|
||||||
msg_ok "Stopped Service"
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
setup_go
|
setup_go
|
||||||
|
|
||||||
msg_info "Updating ${APP} to v${RELEASE}"
|
msg_info "Updating ${APP} to v${RELEASE}"
|
||||||
cd /opt
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && curl -fsSL 'https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/archive/v${RELEASE}/snowflake-v${RELEASE}.tar.gz' -o snowflake.tar.gz"
|
||||||
$STD curl -fsSL "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/archive/v${RELEASE}/snowflake-v${RELEASE}.tar.gz" -o snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
||||||
$STD tar -xzf snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm snowflake.tar.gz"
|
||||||
rm -rf snowflake
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm -rf .${APP}"
|
||||||
mv "snowflake-v${RELEASE}" snowflake
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
||||||
rm snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
||||||
chown -R snowflake:snowflake /opt/snowflake
|
echo "${RELEASE}" | sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
||||||
cd /opt/snowflake/proxy
|
|
||||||
$STD sudo -u snowflake go build -o snowflake-proxy .
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
|
|||||||
@ -13,23 +13,23 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
|
APP="tor-snowflake"
|
||||||
|
SNOWFLAKEUSER="snowflake"
|
||||||
|
|
||||||
setup_go
|
setup_go
|
||||||
|
|
||||||
msg_info "Creating snowflake user"
|
msg_info "Creating ${SNOWFLAKEUSER} user"
|
||||||
useradd -r -s /bin/false -d /opt/snowflake snowflake
|
useradd -m -r -s /usr/sbin/nologin -d /home/${SNOWFLAKEUSER} ${SNOWFLAKEUSER}
|
||||||
msg_ok "Created snowflake user"
|
msg_ok "Created ${SNOWFLAKEUSER} user"
|
||||||
|
|
||||||
msg_info "Building Snowflake Proxy from Source"
|
msg_info "Building Snowflake"
|
||||||
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//')
|
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//')
|
||||||
cd /opt
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && curl -fsSL 'https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/archive/v${RELEASE}/snowflake-v${RELEASE}.tar.gz' -o snowflake.tar.gz"
|
||||||
$STD curl -fsSL "https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/archive/v${RELEASE}/snowflake-v${RELEASE}.tar.gz" -o snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
||||||
$STD tar -xzf snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm snowflake.tar.gz"
|
||||||
mv "snowflake-v${RELEASE}" snowflake
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
||||||
rm snowflake.tar.gz
|
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
||||||
chown -R snowflake:snowflake /opt/snowflake
|
echo "${RELEASE}" | sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
||||||
cd /opt/snowflake/proxy
|
|
||||||
$STD sudo -u snowflake go build -o snowflake-proxy .
|
|
||||||
echo "${RELEASE}" >/opt/tor-snowflake_version.txt
|
|
||||||
msg_ok "Built Snowflake Proxy v${RELEASE}"
|
msg_ok "Built Snowflake Proxy v${RELEASE}"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
@ -42,10 +42,10 @@ Wants=network-online.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=snowflake
|
User=${SNOWFLAKEUSER}
|
||||||
Group=snowflake
|
Group=${SNOWFLAKEUSER}
|
||||||
WorkingDirectory=/opt/snowflake
|
WorkingDirectory=/home/${SNOWFLAKEUSER}/.${APP}
|
||||||
ExecStart=/opt/snowflake/proxy/snowflake-proxy -verbose -unsafe-logging
|
ExecStart=/home/${SNOWFLAKEUSER}/.${APP}/proxy/snowflake-proxy -verbose -unsafe-logging
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user