#!/bin/bash

if [[ "${USER}" != "{{ item }}" ]]; then
  echo "This script should be run as {{ item }}, please sudo first"
  echo "sudo -u {{ item }} -s /bin/bash"
  echo "${0}"
  exit
fi

cd /home/{{ item }}/sites
git stash
git pull
rm -rf web/wp
composer update
cd web/app/themes/coop-tech-oowp-theme
composer update
npm install
nodejs ./node_modules/gulp/bin/gulp.js
cd ../../..
wp core update-db