#!/bin/bash

# Define the destination path for Firefox policies
destination="/etc/firefox/distribution"

# Check if the directory exists; if not, create it
if [ ! -d "$destination" ]; then
    sudo mkdir -p "$destination"
    # Ensure the directory is owned by root
    sudo chown -R root:root "$destination"
fi

# Define the URL to the policies.json file
url="https://spin.ai/wp-content/uploads/kb/google-workspace/policies.json"

# Define the output path for the policies.json file
outputPath="$destination/policies.json"

# Download the policies.json file (using -L to follow redirects if necessary)
curl -L -o "$outputPath" "$url"

# Ensure the policies.json file is owned by root after downloading
sudo chown root:root "$outputPath"
