#!/bin/bash
#
# Copyright (c) 2019-2020 Oracle and/or its affiliates. All rights reserved.
# Licensed under the GNU General Public License Version 2 as shown at https://oss.oracle.com/licenses/GPL-2.

whitelist="/etc/keepalived/keepalived.conf
/etc/olcne-nginx/nginx.conf
/etc/olcne-nginx/image
/etc/keepalived/check_apiserver.sh
/etc/crio/crio.conf
"

if echo "$whitelist" | grep -q -x "$1"; then
	echo "$2" > "$1"
	if [ ${1: -3} == ".sh" ]; then
		chmod +x "$1"
	fi
	exit 0
fi

echo "$1 cannot be written by this script"
exit 1
