File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,32 @@ echo $gw
10
10
11
11
ls -la
12
12
13
- MERGED_CONFIG=merged.config.ovpn
13
+ # Enable compatability layer with Alpine
14
+ MERGED_CONFIG_FILE=merged.config.ovpn
14
15
15
- cat << EOF > $MERGED_CONFIG
16
+ cat << EOF > $MERGED_CONFIG_FILE
16
17
script-security 2
17
18
up /etc/openvpn/up.sh
18
19
down /etc/openvpn/down.sh
19
20
EOF
20
21
21
- cat " ${OPENVPN_CONFIG_FILE} " >> $MERGED_CONFIG
22
+ cat " ${OPENVPN_CONFIG_FILE} " >> $MERGED_CONFIG_FILE
22
23
23
- openvpn --config " /opt/openvpn/${MERGED_CONFIG} "
24
+ # Auth using username and password
25
+ VPN_AUTH_FILE=vpn.auth
26
+ # Create credentials file
27
+ cat << EOF > $VPN_AUTH_FILE
28
+ ${OPENVPN_USERNAME}
29
+ ${OPENVPN_PASSWORD}
30
+ EOF
31
+
32
+ # Add `auth-user-pass $VPN_AUTH_FILE` to the merged config
33
+ if grep -q auth-user-pass $MERGED_CONFIG_FILE ; then
34
+ # if has string started with `auth-user-pass`
35
+ sed -i " s/^auth-user-pass.*/auth-user-pass ${VPN_AUTH_FILE} /" $MERGED_CONFIG_FILE
36
+ elif [ -n " ${OPENVPN_USERNAME} " ]; then
37
+ # If not empty username
38
+ echo " auth-user-pass ${VPN_AUTH_FILE} " >> $MERGED_CONFIG_FILE
39
+ fi
40
+
41
+ openvpn --config " /opt/openvpn/${MERGED_CONFIG_FILE} "
You can’t perform that action at this time.
0 commit comments