#!/bin/bash

currpath=$(dirname "$(realpath $0)")
profile="$currpath/profile.json"

# 3. Check if the parameter is a symlink.
if [[ -L "$profile" ]]; then
  # 4. Check if it links to a valid path.
  if [[ -e "$profile" ]]; then
    echo "Valid link!"
  else
    unlink "$profile"
    ln -s "$currpath/000/profile.json" "$profile"
  fi
else
  unlink "$profile"
  ln -s "$currpath/000/profile.json" "$profile"
fi
