-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
67 additions
and
1 deletion.
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 @@ | ||
/openvpn-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# You can use any debian based image you want | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:0-bullseye | ||
|
||
# Install openvpn client | ||
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \ | ||
&& apt-get -y install --no-install-recommends openvpn \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/library-scripts \ | ||
# | ||
# Remove the OPENVPN_CONFIG variable since we don't neeed it after is written to a file | ||
&& echo "unset OPENVPN_CONFIG" | tee -a /etc/bash.bashrc > /etc/profile.d/unset-openvpn-config.sh \ | ||
&& if [ -d "/etc/zsh" ]; then echo "unset OPENVPN_CONFIG" >> /etc/zsh/zshenv; fi |
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,18 @@ | ||
{ | ||
"name": "OpenVPN Sample", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
}, | ||
|
||
// Allow the container to interact with host networking | ||
"runArgs": ["--cap-add=NET_ADMIN", "--cap-add=NET_RAW", "--device=/dev/net/tun"], | ||
|
||
// Save the contents of the OPENVPN_CONFIG secret to disk - it lands in .devcontainer/openvpn-tmp | ||
"initializeCommand": "bash .devcontainer/save-config.sh", | ||
|
||
// [Optional] Once the dev container is running, automatically start up the VPN client | ||
"postStartCommand": "bash .devcontainer/start-openvpn.sh", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
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 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Switch to the .devcontainer folder | ||
cd "$( dirname "${BASH_SOURCE[0]}" )" | ||
|
||
# Create a temporary directory | ||
mkdir -p openvpn-tmp | ||
cd openvpn-tmp | ||
|
||
# Save the configuration from the secret if it is present | ||
if [ ! -z "${OPENVPN_CONFIG}" ]; then | ||
echo "${OPENVPN_CONFIG}" > vpnconfig.ovpn | ||
fi |
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,21 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Switch to the .devcontainer folder | ||
cd "$( dirname "${BASH_SOURCE[0]}" )" | ||
|
||
# Create a temporary directory | ||
mkdir -p openvpn-tmp | ||
cd openvpn-tmp | ||
|
||
# Touch file to make sure this user can read it | ||
touch openvpn.log | ||
|
||
# If we are running as root, we do not need to use sudo | ||
sudo_cmd="" | ||
if [ "$(id -u)" != "0" ]; then | ||
sudo_cmd="sudo" | ||
fi | ||
|
||
# Start up the VPN client using the config stored in vpnconfig.ovpn by save-config.sh | ||
nohup ${sudo_cmd} /bin/sh -c "openvpn --config vpnconfig.ovpn --log openvpn.log &" | tee openvpn-launch.log |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
# codespaces-openvpn | ||
# Using the OpenVPN client from Codespaces | ||
|