#!/usr/bin/bash

if [ -z $1 ]; then 
	VCCD_DIR=$HOME/.vccd-runtime/
fi;

if [ ! -d $VCCD_DIR ]; then 
	mkdir $VCCD_DIR;
else 
	choise=y
	echo -n "$VCCD_DIR already exists. Clean it or exit? y/n: "
	read choice

	if [ $choise == n ]; then 
		exit 0;
	elif [ $choice != y ]; then 
		echo "Please input y/n (yes / no). "
		exit 0
	fi;

	rm -rf $VCCD_DIR/*
fi;

echo "vccd will put data into $VCCD_DIR"
echo -n $VCCD_DIR > /etc/vccd-runtime
touch $VCCD_DIR/usrlist 

if [ $? -ne 0 ]; then 
	echo "*** writing to /etc/vccd-runtime failed"
	exit 1
fi

mkdir $VCCD_DIR/users


