1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/bin/bash
- WG_DOCKER_PATH="/opt/wg-docker"
- cd $WG_DOCKER_PATH
- ls ./profiles || mkdir ./profiles
- # create profile
- [ -n $1 ] && [ -n $2 ] && \
- (ls ./profiles | grep $2) &&
- (ls ./profiles/$2/ || mkdir ./profiles/$2/) &&
- cp docker-compose.env.yml ./profiles/$2/ &&
- cp Makefile ./profiles/$2/ &&
- cp -r docker/ ./profiles/$2/ &&
- cd ./profiles/$2/ &&
- make $1 PROFILE="$2" ||
- (
- profile_name="test"
- wg_conf_path="/etc/wireguard/mullvad/mullvad-au1.conf"
- ssh_pubkey="$HOME/.ssh/id_rsa.pub"
- wg_port=52016
- socks_port=1116
- echo "
- usage: wg-docker [up|shell|firefox|thunderbird] [profile_name]
- Provide a profile name, and a valid WireGuard configuration file, and a public ssh key
- profile_name: Work
- wg_conf_path: /etc/wireguard/mullvad/mullvad-au1.conf
- ssh_pubkey: $HOME/.ssh/id_rsa.pub
- wg_port: 52000 [default]
- socks_port: 1100 [default]
- ######################
- "
- # comment out if manually entered
- read -p "profile_name : " profile_name
- read -p "wg_conf_path : " wg_conf_path
- read -p "ssh_pubkey : " ssh_pubkey
- read -p "wg_port : " wg_port
- read -p "socks_port : " socks_port
- profile_path="./profiles/${profile_name}_wg_${wg_port}_socks_${socks_port}"
- # Create a profile from template
- [ ! -d $profile_path ] && mkdir $profile_path || \
- touch $profile_path/.env
- # fill template
- cat << EOF >> $profile_path/.env
- # container wg
- CONTAINER_NAME=wg_${profile_name}
- WG_PORT=${wg_port}
- WG0_CONF=${wg_conf_path}
- # ssh socks
- SSH_PUBKEY=${ssh_pubkey}
- SOCKS_PORT=${socks_port}
- EOF
- echo "Profile enviroment created at $profile_path/.env"
- )
|