2016-04-04 09:28:46 +00:00
|
|
|
#!/bin/bash
|
2016-04-04 12:08:21 +00:00
|
|
|
NVM="$HOME/.nvm"
|
|
|
|
NVM_VERSION="5.7.0"
|
|
|
|
DEV="$HOME/dev"
|
|
|
|
LIVE="$HOME/live"
|
|
|
|
SWAP="/swapfile"
|
2016-04-04 13:21:53 +00:00
|
|
|
DBSETUP="obrand-admin-server/dbrebuild.sh"
|
2016-04-04 09:28:46 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
fancy_echo() {
|
|
|
|
local fmt="$1"; shift
|
|
|
|
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "\n$fmt\n" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
fancy_echo "Installing Obrand Admin Server ..."
|
2016-04-04 09:28:46 +00:00
|
|
|
## Update initial packages
|
2016-04-04 12:08:21 +00:00
|
|
|
|
|
|
|
sudo apt-get -y -q --force-yes update
|
|
|
|
# sudo apt-get -y -q --force-yes upgrade
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
# install apps
|
2016-04-04 13:21:53 +00:00
|
|
|
sudo apt-get --assume-yes install build-essential git nginx htop screen wget curl postgresql postgresql-contrib
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
# set up and install swap file
|
2016-04-04 12:08:21 +00:00
|
|
|
if [[ ! -f "$SWAP" ]]; then
|
|
|
|
sudo fallocate -l 1G $SWAP
|
|
|
|
sudo chmod 600 $SWAP
|
|
|
|
sudo mkswap $SWAP
|
|
|
|
sudo swapon $SWAP
|
|
|
|
fi
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
# setup node and npm
|
2016-04-04 09:56:28 +00:00
|
|
|
if [ ! -d "$NVM" ]; then
|
|
|
|
# Will enter here if $DIRECTORY exists, even if it contains spaces
|
|
|
|
|
|
|
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
|
2016-04-04 12:08:21 +00:00
|
|
|
export NVM_DIR=$NVM
|
|
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
2016-04-04 09:56:28 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
source $HOME/.bashrc
|
|
|
|
source $NVM/nvm.sh
|
2016-04-04 09:56:28 +00:00
|
|
|
fi
|
2016-04-04 09:28:46 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
nvm install $NVM_VERSION
|
|
|
|
|
2016-04-04 09:28:46 +00:00
|
|
|
# get source and build
|
2016-04-04 09:56:28 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
# Install global packages.
|
|
|
|
fancy_echo "Installing global packages ..."
|
|
|
|
npm set progress=false
|
|
|
|
npm install -g gulp bower pm2 npm-check npm-install-missing ember-cli phantomjs-prebuilt
|
|
|
|
|
2016-04-04 09:56:28 +00:00
|
|
|
if [ ! -d "$LIVE" ]; then
|
2016-04-04 12:08:21 +00:00
|
|
|
mkdir $LIVE
|
2016-04-04 09:56:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$DEV" ]; then
|
2016-04-04 12:08:21 +00:00
|
|
|
mkdir $DEV
|
2016-04-04 09:56:28 +00:00
|
|
|
fi
|
2016-04-04 09:42:04 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
cd $DEV
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
# Get latest version of Obrand Admin
|
|
|
|
git clone https://censis.visualstudio.com/DefaultCollection/_git/O-Brand
|
|
|
|
|
|
|
|
# Get latest version of Obrand Admin Server
|
|
|
|
git clone http://gitlab.silvrtree.co.uk/martind2000/obrand-admin-server.git
|
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
cd $DEV/O-Brand
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
npm install .
|
|
|
|
npm-install-missing
|
|
|
|
bower install
|
2016-04-04 12:08:21 +00:00
|
|
|
ember build --environment production
|
2016-04-04 09:28:46 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
cd $DEV/obrand-admin-server
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
npm install . && npm-install-missing
|
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
cd $DEV/O-Brand/dist
|
|
|
|
cp -ra . $DEV/obrand-admin-server/wwwroot
|
2016-04-04 09:28:46 +00:00
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
cd $DEV/obrand-admin-server
|
2016-04-04 13:21:53 +00:00
|
|
|
|
|
|
|
echo Setting up Database server...
|
|
|
|
|
|
|
|
sudo su - postgres -c "$DEV/$DBSETUP"
|
|
|
|
|
|
|
|
echo Copying...
|
2016-04-04 12:08:21 +00:00
|
|
|
rsync -uav --exclude .git $DEV/obrand-admin-server/ $LIVE
|
2016-04-04 09:28:46 +00:00
|
|
|
|
|
|
|
# Configure nginx
|
|
|
|
sudo fuser -k 80/tcp
|
|
|
|
|
|
|
|
sudo wget https://dl.dropboxusercontent.com/u/233909/obrand/obrand.nginx -O /etc/nginx/sites-available/obrand && sudo ln -s /etc/nginx/sites-available/obrand /etc/nginx/sites-enabled/obrand
|
|
|
|
|
2016-04-04 12:08:21 +00:00
|
|
|
npm set progress=true
|
|
|
|
sudo /etc/init.d/nginx restart
|
2016-04-04 09:28:46 +00:00
|
|
|
|