#!/bin/bash -ex

HOSTNAME=OpenVPN

# set hostname
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts

#install openvpn and bridge-utils for bridged VPNs
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
    -o DPkg::Options::=--force-confdef \
    -o DPkg::Options::=--force-confold \
    install bridge-utils openvpn

#configure module
OVPN_CONFIG=/etc/webmin/openvpn/config
sed -i "s|cmd=/opt|cmd=/usr/share|" $OVPN_CONFIG
sed -i -e "s|plugin=/opt/webmin|plugin=/usr/lib|" -e "s|/ovpn_plugin||" $OVPN_CONFIG
