#!/bin/bash REPO="/opt/siimee.git" commands=( "cd ${REPO}" "git --git-dir=${REPO} --work-tree=${REPO} checkout master -f" "cd ${REPO}/backend && rm -f ${REPO}/backend/package-lock.json && npm install" "echo no build needed!" "cd ${REPO}/frontend && rm -f ${REPO}/frontend/package-lock.json && npm install" "npm run build" "mkdir ${REPO}/frontend/dist/assets/fonts" "cp ${REPO}/frontend/assets/fonts/icomoon.* ${REPO}/frontend/dist/assets/fonts" # "cd ${REPO}/backend && npm run generate && npm run reseed" "pm2 restart siimee_backend -i -1 -n siimee_backend" ) steps=( "navigate to project…" "git checkout…" "backend npm install…" "building backend…" "frontend npm install…" "building frontend…" "making font directory..." "copying fonts..." # "regenerate db data…" "start-up…" ) SPAN=80 COUNT=0 hr() { printf "\n" for i in $(seq 0 $SPAN) ; do printf $1 done printf "\n" } print_step() { hr "-" let step_count=$COUNT+1 printf "* POST-RECEIVE | Step: ${step_count} of ${#steps[@]}: ${1}" hr "-" printf "\n" let COUNT++ } run() { # Header line printf "\n\n" printf "** SIIMEE **" hr "=" printf "\nStarting POST-RECEIVE…" # Body for step in ${!steps[@]}; do printf "\n" print_step "${steps[$step]}" eval "${commands[$step]}" done # Footer line printf "\n" hr "=" } run