#!/bin/bash
#
#  mBox OpenVPN Client Configuration State Checker v1.0.0
#  Created by Enrico Buttignol (ebuttignol@messana.tech)
#  Copyright by Messana Hydronic Technologies
#
#  This tool:
#    - Verifies whether the OpenVPN client configuration indicates
#      a NEW (virgin) mBox or an ALREADY INITIALIZED mBox
#    - Checks for placeholder OpenVPN client config files in /etc/openvpn/
#    - Returns "true" if the mBox is NEW / VIRGIN
#    - Returns "false" if the mBox is ALREADY INITIALIZED
#
#  Usage:
#    ./check-mbox-openvpn-client-conf.sh
#

set -e

OPENVPN_DIR="/etc/openvpn"
CONF_1="9999-9999.conf"
CONF_2="9999-999.conf"

if [ -f "${OPENVPN_DIR}/${CONF_1}" ] || [ -f "${OPENVPN_DIR}/${CONF_2}" ]; then
    echo "true"
else
    echo "false"
fi

exit 0
