docker-entrypoint.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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} && ${ip} ]]
  9. then
  10. if [[ !${client_net}]]
  11. then
  12. client_net = "10.10.20.0/24"
  13. fi
  14. trap cleanup SIGTERM EXIT
  15. cleanup()
  16. {
  17. ip addr del ${ip}/24 dev ${dev}:ovpn
  18. iptables -D FORWARD -m state --state NEW -s ${client_net} -o external -j DROP
  19. }
  20. ip addr add ${ip}/24 brd + dev ${dev} label ${dev}:ovpn
  21. iptables -I FORWARD 1 -m state --state NEW -s ${client_net} -o external -j DROP
  22. fi
  23. if [[ ${net} ]]
  24. then
  25. echo "push \"route ${net} 255.255.255.0\"" >> /etc/openvpn/ovpn.conf
  26. fi
  27. exec "/usr/sbin/openvpn" "--config" "/etc/openvpn/ovpn.conf" "$@" &
  28. wait
  29. fi
  30. if [ ${mode} == "client" ]
  31. then
  32. mv /etc/openvpn/client.conf /etc/openvpn/ovpn.conf
  33. echo "remote ${server}" >> /etc/openvpn/ovpn.conf
  34. echo -e "LegacySigningMDs md2 md5\nMinimumDHBits 512\n" >> /etc/pki/tls/legacy-settings
  35. exec "/usr/sbin/openvpn" "--config" "/etc/openvpn/ovpn.conf" "$@"
  36. fi
  37. if [ ${mode} == "keygen" ]
  38. then
  39. echo "$SSHKEY" > /tmp/keyfile
  40. chmod 0400 /tmp/keyfile
  41. exec "$@"
  42. fi