run from cloned folder

This commit is contained in:
AJ ONeal 2017-11-07 04:09:01 -07:00
parent 5c7a5c0b2e
commit 3bb6dc9680
1 changed files with 101 additions and 92 deletions

View File

@ -3,22 +3,26 @@
set -e set -e
set -u set -u
source ./installer/sudo-cmd.sh
source ./installer/http-get.sh
### IMPORTANT ### ### IMPORTANT ###
### VERSION ### ### VERSION ###
#my_app_ver="v1.1" #my_app_ver="v1.1"
my_app_ver="installer-v2" my_app_ver="installer-v2"
my_azp_oauth3_ver="v1.2"
export NODE_VERSION="v8.9.0" export NODE_VERSION="v8.9.0"
################# #################
export NODE_PATH=$my_tmp/opt/$my_app_name/lib/node_modules
export PATH=$PATH:$my_tmp/opt/$my_app_name/bin/
export NPM_CONFIG_PREFIX=$my_tmp/opt/$my_app_name
my_npm="$NPM_CONFIG_PREFIX/bin/npm"
#################
my_app_name=goldilocks my_app_name=goldilocks
my_app_pkg_name=com.daplie.goldilocks.web my_app_pkg_name=com.daplie.goldilocks.web
my_app_dir=$(mktemp -d) my_tmp=$(mktemp -d)
my_app_dist=$my_app_dir/opt/goldilocks/lib/node_modules/goldilocks/dist my_app_dir=$my_tmp
my_app_dist=$my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name/dist
git_base="https://git.daplie.com/Daplie/goldilocks.js.git" git_base="https://git.daplie.com/Daplie/goldilocks.js.git"
installer_base="https://git.daplie.com/Daplie/goldilocks.js/raw/$my_app_ver" installer_base="https://git.daplie.com/Daplie/goldilocks.js/raw/$my_app_ver"
@ -27,22 +31,30 @@ installer_base="https://git.daplie.com/Daplie/goldilocks.js/raw/$my_app_ver"
# #
# Install to tmp location, then move to /opt # Install to tmp location, then move to /opt
# #
echo "Installing to $my_app_dir (will be moved after install)" echo "Installing to $my_tmp (will be moved after install)"
mkdir -p $my_app_dir/opt/goldilocks/lib/node_modules/goldilocks mkdir -p $my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name
git clone $git_base $my_app_dir/opt/goldilocks/lib/node_modules/goldilocks git clone $git_base $my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name
pushd $my_app_dir/opt/goldilocks/lib/node_modules/goldilocks pushd $my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name
git checkout $my_app_ver git checkout $my_app_ver
popd
mkdir -p "$my_app_dir/opt/$my_app_name"/{lib,bin,etc} mkdir -p "$my_tmp/opt/$my_app_name"/{lib,bin,etc}
ln -s ../lib/node_modules/$my_app_name/bin/$my_app_name.js $my_app_dir/opt/$my_app_name/bin/goldilocks ln -s ../lib/node_modules/$my_app_name/bin/$my_app_name.js $my_tmp/opt/$my_app_name/bin/$my_app_name
ln -s ../lib/node_modules/$my_app_name/bin/$my_app_name.js $my_app_dir/opt/$my_app_name/bin/goldilocks.js ln -s ../lib/node_modules/$my_app_name/bin/$my_app_name.js $my_tmp/opt/$my_app_name/bin/$my_app_name.js
mkdir -p "$my_app_dir/etc/$my_app_name" mkdir -p "$my_tmp/etc/$my_app_name"
chmod 775 "$my_app_dir/etc/$my_app_name" chmod 775 "$my_tmp/etc/$my_app_name"
cat "$my_app_dist/etc/$my_app_name/$my_app_name.example.yml" > "$my_app_dir/etc/$my_app_name/$my_app_name.example.yml" cat "$my_app_dist/etc/$my_app_name/$my_app_name.example.yml" > "$my_tmp/etc/$my_app_name/$my_app_name.example.yml"
chmod 664 "$my_app_dir/etc/$my_app_name/$my_app_name.example.yml" chmod 664 "$my_tmp/etc/$my_app_name/$my_app_name.example.yml"
mkdir -p $my_app_dir/srv/www mkdir -p $my_tmp/srv/www
mkdir -p $my_app_dir/var/www mkdir -p $my_tmp/var/www
mkdir -p $my_app_dir/var/log/$my_app_name mkdir -p $my_tmp/var/log/$my_app_name
#
# Helpers
#
source ./installer/sudo-cmd.sh
source ./installer/http-get.sh
@ -50,22 +62,18 @@ mkdir -p $my_app_dir/var/log/$my_app_name
# Dependencies # Dependencies
# #
echo $NODE_VERSION > /tmp/NODEJS_VER echo $NODE_VERSION > /tmp/NODEJS_VER
export NODE_PATH=$my_app_dir/opt/goldilocks/lib/node_modules
export PATH=$PATH:$my_app_dir/opt/goldilocks/bin/
export NPM_CONFIG_PREFIX=$my_app_dir/opt/goldilocks
http_bash "https://git.coolaj86.com/coolaj86/node-installer.sh/raw/v1.1/install.sh" http_bash "https://git.coolaj86.com/coolaj86/node-installer.sh/raw/v1.1/install.sh"
my_npm="$NPM_CONFIG_PREFIX/bin/npm"
$my_npm install -g npm@4 $my_npm install -g npm@4
pushd $my_app_dir/opt/goldilocks/lib/node_modules/goldilocks pushd $my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name
$my_npm install $my_npm install
popd popd
pushd $my_app_dir/opt/goldilocks/lib/node_modules/goldilocks/packages/assets pushd $my_tmp/opt/$my_app_name/lib/node_modules/$my_app_name/packages/assets
OAUTH3_GIT_URL="https://git.daplie.com/Oauth3/oauth3.js.git" OAUTH3_GIT_URL="https://git.daplie.com/Oauth3/oauth3.js.git"
git clone ${OAUTH3_GIT_URL} oauth3.org || true git clone ${OAUTH3_GIT_URL} oauth3.org || true
ln -s oauth3.org org.oauth3 ln -s oauth3.org org.oauth3
pushd oauth3.org pushd oauth3.org
git remote set-url origin ${OAUTH3_GIT_URL} git remote set-url origin ${OAUTH3_GIT_URL}
git checkout v1.2 git checkout $my_azp_oauth3_ver
git pull git pull
popd popd
@ -95,22 +103,22 @@ popd
# System Service # System Service
# #
source ./installer/my-root.sh source ./installer/my-root.sh
echo "Pre-installation to $my_app_dir complete, now installing to $my_root/ ..." echo "Pre-installation to $my_tmp complete, now installing to $my_root/ ..."
set +e set +e
if type -p tree >/dev/null 2>/dev/null; then if type -p tree >/dev/null 2>/dev/null; then
#tree -I "node_modules|include|share" $my_app_dir #tree -I "node_modules|include|share" $my_tmp
tree -L 6 -I "include|share|npm" $my_app_dir tree -L 6 -I "include|share|npm" $my_tmp
else else
ls $my_app_dir ls $my_tmp
fi fi
set -e set -e
source ./installer/my-user-my-group.sh source ./installer/my-user-my-group.sh
echo "User $my_user Group $my_group" echo "User $my_user Group $my_group"
$sudo_cmd chown -R $my_user:$my_group $my_app_dir $sudo_cmd chown -R $my_user:$my_group $my_tmp
rsync -a $my_app_dir/ $my_root/ rsync -a $my_tmp/ $my_root/
rsync -a --ignore-existing $my_app_dist/etc/goldilocks/goldilocks.yml $my_root/etc/goldilocks/goldilocks.yml rsync -a --ignore-existing $my_app_dist/etc/$my_app_name/$my_app_name.yml $my_root/etc/$my_app_name/$my_app_name.yml
source ./installer/install-system-service.sh source ./installer/install-system-service.sh
# Change to admin perms # Change to admin perms
@ -122,6 +130,7 @@ $sudo_cmd chown -R $my_user:$my_group $my_root/var/www $my_root/srv/www
# directories have the same owner and group. # directories have the same owner and group.
$sudo_cmd chmod -R ug+rwX /opt/$my_app_name $sudo_cmd chmod -R ug+rwX /opt/$my_app_name
find /opt/$my_app_name -type d -exec $sudo_cmd chmod ug+s {} \; find /opt/$my_app_name -type d -exec $sudo_cmd chmod ug+s {} \;
popd
rm -rf $my_app_dir rm -rf $my_tmp