#!/bin/zsh

################################################################################
# Created by LucidLink Support | Technical Support | LucidLink
################################################################################
# Created on 2024/07/01
#
################################################################################
# Tested macOS Versions
################################################################################
#
#
################################################################################
# Software Information
################################################################################
#
# A simple Audit script to evaluate the presence of the .fskey file, please
# edit the fskey variable below to match your fskey filename
#
################################################################################
# License Information
################################################################################
# Copyright 2024 LucidLink
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is furnished
# to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
################################################################################

# Script Version
VERSION="1.0.0"

##############################################################################
############################# USER INPUT #####################################
##############################################################################

# Enter the full filename of the fskey
fskey="filespace.domain.1234567890ab.fskey"

##############################################################################
############################# VARIABLES ######################################
##############################################################################
app_path="/Applications/Lucid.app"
loggedInUser=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ {print $3}')
lucidKeyPath="/Users/${loggedInUser}/.lucid-keys/${fskey}"

##############################################################################
################### MAIN LOGIC - DO NOT MODIFY BELOW #########################
##############################################################################
# Do not modify the below. Modify at your own risk.

if [[ ! -e ${lucidKeyPath} ]]; then
    echo ".fskey not found, will proceed with install."
    exit 1
elif [[ -e ${lucidKeyPath} ]]; then
    echo ".fskey found. Will not proceed."
    exit 0
fi