forked from haugene/docker-transmission-openvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a helper script to avoid mac sed and bash differences from linux
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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,42 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
# Wrapper script of adjustConfigs.sh | ||
# Getting errors that I don't care to fix when running sed on my mac (different versions and syntax) | ||
# Copying provider files into a temporary container, running the script and copying it out again | ||
|
||
|
||
display_usage() { | ||
echo "${bold}Hint: read the script before using it${normal}" | ||
echo "If you just forgot: ./adjustConfigs.sh <provider-folder>" | ||
} | ||
|
||
# if no arguments supplied, display usage | ||
if [ $# -lt 1 ] | ||
then | ||
display_usage | ||
exit 1 | ||
fi | ||
|
||
provider=$1 | ||
|
||
# Create a simple container that, when started, just tails a static file | ||
CONTAINER=$(docker create ubuntu bash -c "tail -f /etc/os-release") | ||
|
||
# Copy provider files and script into container | ||
docker cp ${provider} ${CONTAINER}:/${provider} | ||
docker cp adjustConfigs.sh ${CONTAINER}:/ | ||
|
||
# Start it and exec the script (need to install dos2unix first, might be improved later) | ||
docker start ${CONTAINER} | ||
docker exec -it ${CONTAINER} bash -c "apt update && apt install -y dos2unix" | ||
docker exec -it -w / ${CONTAINER} bash -c "./adjustConfigs.sh ${provider}" | ||
docker exec -it -w /${provider} ${CONTAINER} bash -c "find . -type f -name '*.ovpn' -print0 | xargs -0 dos2unix" | ||
|
||
# Copy our result back out, and remove the container | ||
docker cp ${CONTAINER}:/${provider} . | ||
docker rm -f ${CONTAINER} |