#!/bin/bash

# @file check-root-permissions
#
# Copyright (C) Metaswitch Networks 2016
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.

# Usage:
#
# To use this script, add the following to a bash file:
#
# . /usr/share/clearwater/utils/check-root-permissions [exit_code]
#
# where exit_code is the code to exit the script with if it detects the user
# is not running as root

if [ $EUID -ne 0 ]
then
  echo "You must run this script with root permissions"
  if [ "$#" -ne 0 ]
  then
    exit $1
  fi

  exit 1
fi
