From 2cc855484b62fd2a59ab61af7095fdd92e3fb933 Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 24 Mar 2022 01:32:10 +0100 Subject: [PATCH] Preserve cwd. --- start-openvpn.sh | 3 +-- start.tmpl | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/start-openvpn.sh b/start-openvpn.sh index 4a26512..a5f8b7f 100644 --- a/start-openvpn.sh +++ b/start-openvpn.sh @@ -33,8 +33,7 @@ print_ip() { } switch_user() { - cd "$OVPN_HOME" || exit 1 - su - "$OVPN_USER" + su -c "cd $OVPN_WORKDIR && "'$SHELL' -l "$OVPN_USER" } own_ip="$(get_ip)" diff --git a/start.tmpl b/start.tmpl index e1858c6..c399e9a 100755 --- a/start.tmpl +++ b/start.tmpl @@ -32,8 +32,10 @@ docker run -it --cap-add NET_ADMIN \ -v /etc/passwd:/etc/passwd \ -v "$ovpn_configuration_file_parent_dir:$ovpn_configuration_file_parent_dir" \ -v "$HOME:$HOME" \ + -v "$PWD:/data/" \ -e OVPN_USER="$USER" \ -e OVPN_HOME="$HOME" \ + -e OVPN_WORKDIR="/data/" \ -e OVPN_CONFIGURATION_FILE="$ovpn_configuration_file" \ "$TAG" sh