-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Luke Childs <lukechilds123@gmail.com> Co-authored-by: Steven Briscoe <me@stevenbriscoe.com>
- Loading branch information
1 parent
c9a7cfa
commit 37f08cf
Showing
16 changed files
with
297 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '3.7' | ||
|
||
services: | ||
tor_server: | ||
container_name: tor_server | ||
image: getumbrel/tor:0.4.7.8@sha256:2ace83f22501f58857fa9b403009f595137fa2e7986c4fda79d82a8119072b6a | ||
user: "1000:1000" | ||
# build: ./deps/tor | ||
restart: on-failure | ||
volumes: | ||
- ${PWD}/tor/torrc-server:/etc/tor/torrc:ro | ||
- ${PWD}/tor/data:/data | ||
environment: | ||
HOME: "/tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)" | ||
USER_FILE="${UMBREL_ROOT}/db/user.json" | ||
STATUS_FILE="${UMBREL_ROOT}/statuses/remote-tor-access-status.json" | ||
SIGNAL_FILE="${UMBREL_ROOT}/events/signals/remote-tor-access" | ||
|
||
updateStatus() { | ||
local -r state="${1}" | ||
local -r progress="${2}" | ||
|
||
cat <<EOF > "${STATUS_FILE}" | ||
{"state": "${state}", "progress": ${progress}} | ||
EOF | ||
} | ||
|
||
if [[ ! -f "${SIGNAL_FILE}" ]]; then | ||
exit | ||
fi | ||
|
||
enabled=$(cat "${SIGNAL_FILE}") | ||
rm -f "${SIGNAL_FILE}" | ||
|
||
if [[ -f "${STATUS_FILE}" ]]; then | ||
state=$(cat "${STATUS_FILE}" 2> /dev/null | jq -r 'if has("state") then .state else "" end' || true) | ||
|
||
if [[ "${state}" == "running" ]]; then | ||
>&2 echo "Error: Already running!" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
updateStatus "running" "20" | ||
|
||
echo "Stopping Umbrel..." | ||
"${UMBREL_ROOT}/scripts/stop" || true | ||
|
||
updateStatus "running" "50" | ||
|
||
echo | ||
echo "Saving 'remoteTorAccess' setting..." | ||
|
||
while ! (set -o noclobber; echo "$$" > "${USER_FILE}.lock") 2> /dev/null; do | ||
echo "Waiting for JSON lock to be released for ${app} update..." | ||
sleep 1 | ||
done | ||
# This will cause the lock-file to be deleted in case of a | ||
# premature exit. | ||
trap "rm -f "${USER_FILE}.lock"; exit $?" INT TERM EXIT | ||
|
||
jq ".remoteTorAccess = ${enabled}" "${USER_FILE}" > /tmp/user.json | ||
mv /tmp/user.json "${USER_FILE}" | ||
|
||
rm -f "${USER_FILE}.lock" | ||
|
||
echo | ||
echo "Starting Umbrel..." | ||
"${UMBREL_ROOT}/scripts/start" | ||
|
||
updateStatus "complete" "100" |
Oops, something went wrong.