
:wq#!/bin/env bash

# ensure script is running under 'ubuntu' account
if [[ $(whoami) != "root" ]]; then
   sudo -u root $0 "$@"
   exit
fi


# do work
cd /var/www/connector.shopifypioneer.com/staging_webhook_setup/project
php artisan down
cd ../
git reset --hard
git clean -df
git checkout workflows
git pull origin workflows
cd project
php artisan migrate --force
sudo chmod -R 755 /var/www/connector.shopifypioneer.com/staging_webhook_setup/
sudo chown -R root:www-data /var/www/connector.shopifypioneer.com/staging_webhook_setup/
sudo chmod -R ugo+rw  storage bootstrap/cache 
php artisan optimize:clear;
#php artisan config:cache;
php artisan queue:restart;
php artisan up;


pm2 delete automous-staging-webhook-setup
pm2 start yarn --name "automous-staging-webhook-setup" -- dev
pm2 save
