docker-entrypoint.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. #set -e
  3. export RNG=PROGRAM
  4. if [ ${mode} == "server" ]
  5. then
  6. mv /etc/openvpn/server.conf /etc/openvpn/ovpn.conf
  7. echo -e "LegacySigningMDs md2 md5\nMinimumDHBits 512\n" >> /etc/pki/tls/legacy-settings
  8. if [[ ${dev} && ${net} && ${ip} ]]
  9. then
  10. trap cleanup SIGTERM EXIT
  11. cleanup()
  12. {
  13. ip addr del ${ip}/24 dev ${dev}:ovpn
  14. iptables -D FORWARD -m state --state NEW -s 10.10.20.0/24 -d ${net}/24 -j DROP
  15. }
  16. ip addr add ${ip}/24 brd + dev ${dev} label ${dev}:ovpn
  17. iptables -I FORWARD 1 -m state --state NEW -s 10.10.20.0/24 -d ${net}/24 -j DROP
  18. echo "push \"route ${net} 255.255.255.0\"" >> /etc/openvpn/ovpn.conf
  19. exec "/usr/sbin/openvpn" "--config" "/etc/openvpn/ovpn.conf" "$@" &
  20. wait
  21. else
  22. exec "/usr/sbin/openvpn" "--config" "/etc/openvpn/ovpn.conf" "$@"
  23. fi
  24. fi
  25. if [ ${mode} == "client" ]
  26. then
  27. mv /etc/openvpn/client.conf /etc/openvpn/ovpn.conf
  28. echo "remote ${server}" >> /etc/openvpn/ovpn.conf
  29. echo -e "LegacySigningMDs md2 md5\nMinimumDHBits 512\n" >> /etc/pki/tls/legacy-settings
  30. exec "/usr/sbin/openvpn" "--config" "/etc/openvpn/ovpn.conf" "$@"
  31. fi
  32. if [ ${mode} == "keygen" ]
  33. then
  34. echo "$SSHKEY" > /tmp/keyfile
  35. chmod 0400 /tmp/keyfile
  36. exec "$@"
  37. fi