Git Post Receive Hook

I for my deployment start to using a new hook so I don't have to do and maybe forget about updating my Deployment. I got a big inspiration from this site
Because I use node.js I always want to install all deps that I just added and also restart the pm2 process for that

#!/bin/sh
#
## store the arguments given to the script
read oldrev newrev refname

# The deployed directory (the running site)
DEPLOYDIR=/var/www/some/dir
# Number of pm2 process
NUM=1


echo '========post-update hook========='
echo "Starting Deploy"

echo " - Starting code update"
GIT_WORK_TREE="$DEPLOYDIR" git checkout -f
echo " - Finished code update"
if [ "$NUM" -gt "0" ];then
        echo " - Starting npm install"
        cd "$DEPLOYDIR"; npm install; cd -
        echo " - Finished npm install"
        echo " - Starting pm2 restart $NUM"
        pm2 restart $NUM
        echo " - Finished pm2 restart $NUM"
else
        echo " - No npm install (only static content)"
        echo " - No pm2 restart (only static content)"
fi