Skip to content

Commit

Permalink
support running without root
Browse files Browse the repository at this point in the history
  • Loading branch information
MusclePr committed May 17, 2024
1 parent e42129d commit 5a0a1a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
jq=1.6-2.1 \
netcat-traditional=1.10-47 \
iputils-ping libpcap0.8 \
mitmproxy \
mitmproxy sudo \
iproute2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -175,9 +175,12 @@ RUN chmod +x /home/steam/server/*.sh && \
ln -sf /home/steam/server/autopause.sh /usr/local/bin/autopause && \
ln -sf /home/steam/server/autopaused-ctl.sh /usr/local/sbin/autopaused-ctl

# install mitmproxy addons
# install mitmproxy addons & certs
RUN mkdir -p /home/steam/autopause/addons && \
mv /home/steam/server/PalIntercept.py ../autopause/addons/
mv /home/steam/server/PalIntercept.py ../autopause/addons/ && \
chown -R steam:steam /home/steam/autopause && \
ln -sf /home/steam/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt && \
mv /home/steam/server/files/sudoers-steam /etc/sudoers.d/

WORKDIR /home/steam/server

Expand Down
10 changes: 9 additions & 1 deletion scripts/helper_autopause.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ AP_stopDaemon() {

AP_skip() {
if isTrue "${1:-on}"; then
su steam -c "touch ${AP_skip_file}"
if [[ "$(id -u)" -eq 0 ]]; then
su steam -c "touch ${AP_skip_file}"
else
touch "${AP_skip_file}"
fi
else
rm -f "${AP_skip_file}"
fi
Expand Down Expand Up @@ -172,6 +176,10 @@ APComm_API() {
}

APComm_loadJSON() {
if [ ! -f "${APComm_datadir}/register.json" ] || [ ! -f "${APComm_datadir}/update.json" ]; then
APLog "Captured file not found. Perhaps your mitm proxy server is misconfigured, down, or has lost its connection to api.palworldgames.com."
return 1
fi
local -i result=0 delta
APComm_jsonRegister="$(jq -c < "${APComm_datadir}/register.json")"
result=$?
Expand Down
10 changes: 6 additions & 4 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ if isTrue "${AUTO_PAUSE_ENABLED}" && isTrue "${COMMUNITY}" && isTrue "${ENABLE_P
sleep 0.5
done
echo "done."
chown -R "${PUID}:${PGID}" "/home/steam/.mitmproxy"
chown -R "${PUID}:${PGID}" "/home/steam/autopause/addons/__pycache__"
if [ "$(id -u)" -eq 0 ]; then
chown -R "${PUID}:${PGID}" "/home/steam/.mitmproxy"
chown -R "${PUID}:${PGID}" "/home/steam/autopause/addons/__pycache__"
fi

LogInfo "Update ca-certificates."
cp /home/steam/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt
update-ca-certificates
#ln -sf /home/steam/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt
sudo update-ca-certificates

LogInfo "Using proxy now."
export http_proxy="localhost:8080"
Expand Down

0 comments on commit 5a0a1a7

Please sign in to comment.