hardcode username instead of var
This commit is contained in:
parent
2e5376c4d6
commit
9de46cae2d
@ -15,8 +15,6 @@ 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
|
||||||
@ -33,29 +31,28 @@ 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//')
|
||||||
VERSION_FILE="/home/${SNOWFLAKEUSER}/.${APP}_version"
|
if [[ ! -f "/home/snowflake/.${APP}_version" ]] || [[ "${RELEASE}" != "$(cat "/home/snowflake/.${APP}_version")" ]]; then
|
||||||
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 Snowflake"
|
||||||
$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 sudo -H -u snowflake 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 sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
$STD sudo -H -u snowflake bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm snowflake.tar.gz"
|
$STD sudo -H -u snowflake bash -c "cd ~ && rm snowflake.tar.gz"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm -rf .${APP}"
|
$STD sudo -H -u snowflake bash -c "cd ~ && rm -rf .${APP}"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
$STD sudo -H -u snowflake bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
$STD sudo -H -u snowflake bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
||||||
echo "${RELEASE}" | sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
echo "${RELEASE}" | sudo -H -u snowflake bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
||||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
msg_ok "Updated Snowflake to v${RELEASE}"
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
systemctl start snowflake-proxy
|
systemctl start snowflake-proxy
|
||||||
msg_ok "Started Service"
|
msg_ok "Started Service"
|
||||||
msg_ok "Updated successfully!"
|
msg_ok "Updated successfully!"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
msg_ok "No update required. Snowflake is already at v${RELEASE}."
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,22 +14,21 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
APP="tor-snowflake"
|
APP="tor-snowflake"
|
||||||
SNOWFLAKEUSER="snowflake"
|
|
||||||
|
|
||||||
setup_go
|
setup_go
|
||||||
|
|
||||||
msg_info "Creating ${SNOWFLAKEUSER} user"
|
msg_info "Creating snowflake user"
|
||||||
useradd -m -r -s /usr/sbin/nologin -d /home/${SNOWFLAKEUSER} ${SNOWFLAKEUSER}
|
useradd -m -r -s /usr/sbin/nologin -d /home/snowflake snowflake
|
||||||
msg_ok "Created ${SNOWFLAKEUSER} user"
|
msg_ok "Created snowflake user"
|
||||||
|
|
||||||
msg_info "Building Snowflake"
|
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//')
|
||||||
$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 sudo -H -u snowflake 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 sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
$STD sudo -H -u snowflake bash -c "cd ~ && tar -xzf snowflake.tar.gz"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && rm snowflake.tar.gz"
|
$STD sudo -H -u snowflake bash -c "cd ~ && rm snowflake.tar.gz"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
$STD sudo -H -u snowflake bash -c "cd ~ && mv snowflake-v${RELEASE} .${APP}"
|
||||||
$STD sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
$STD sudo -H -u snowflake bash -c "cd ~/.${APP}/proxy && go build -o snowflake-proxy ."
|
||||||
echo "${RELEASE}" | sudo -H -u ${SNOWFLAKEUSER} bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
echo "${RELEASE}" | sudo -H -u snowflake bash -c "cd ~ && tee .${APP}_version >/dev/null"
|
||||||
msg_ok "Built Snowflake Proxy v${RELEASE}"
|
msg_ok "Built Snowflake Proxy v${RELEASE}"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
@ -42,10 +41,10 @@ Wants=network-online.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=${SNOWFLAKEUSER}
|
User=snowflake
|
||||||
Group=${SNOWFLAKEUSER}
|
Group=snowflake
|
||||||
WorkingDirectory=/home/${SNOWFLAKEUSER}/.${APP}
|
WorkingDirectory=/home/snowflake/.${APP}
|
||||||
ExecStart=/home/${SNOWFLAKEUSER}/.${APP}/proxy/snowflake-proxy -verbose -unsafe-logging
|
ExecStart=/home/snowflake/.${APP}/proxy/snowflake-proxy -verbose -unsafe-logging
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user