#!/usr/bin/bash
#
# Author: Song Zhao <szhao@noggin.com.au>
# Date  : Tue, 11 Nov 2014
# 
# This script will be called from the OCA application to clear
# php-fpm's cache. At the moment, we are just using a crude 
# pkill to stop all the php-fpm installed owned by the caller
#
# If the script is invoked by root then a uid must be specified
# as a cmd line argument 

#set -x

uid=$(whoami)

if [ "$uid" == "root" ]; then
  if [ -z "$1" ]; then
    echo "Please specify a uid"
    exit 1
  else
    uid="$1"
    pkill -u "$uid" php-fpm
  fi
else
  pkill -u "$uid" php-fpm
fi

exit 0

