#!/bin/bash

# This shell script is part of package cp-vpn
#
# Copyright (c) 2014 Com-Pro, Germany
#
# It will be executed to load the basic configuration
# from the registered User.
# If there's no registration file found, it will exit
# and the service is not started.

CONFIGDIR="/etc/cp-vpn/"
EXITSTATE=1

cp-vpn-rc $CONFIGDIR
EXITSTATE=$?

if [ $EXITSTATE = 0 ]; then
  peervpn "${CONFIGDIR}/cp-vpn.conf"
  EXITSTATE=$?
  if [ $EXITSTATE = 0 ]; then
    cp-vpn-on $CONFIGDIR
  fi
fi

exit ${EXITSTATE}
