Last active
November 19, 2016 01:04
-
-
Save linuxbandit/641bfea3fcd203f6d234afd728de50fd to your computer and use it in GitHub Desktop.
This is the file we should use to bootstrap our environment when working on OMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is for having a standardised developer environment | |
# It is composed of homestead adapted to AEGEE's needs, and the | |
# smaller modules of which the platform is consisted. | |
## PLEASE RUN FROM THE FOLDER YOU WANT TO SET AS ROOT | |
function install-oms { | |
#Check dependencies | |
dep=(git vagrant virtualbox ) | |
for d in ${dep[@]}; do | |
which $d || { echo "missing dependencies: " $d ", now exiting" ; exit 1 ; } | |
done; | |
#Check if SSH keys are already present; if not, generate them | |
if [[ ! -f ~/.ssh/id_rsa ]]; then ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)-omsdevel" ; fi | |
#If all is well then clone the repo | |
git clone --recursive https://github.com/AEGEE/oms-homestead | |
mkdir oms-project | |
cd oms-project | |
git clone --recursive https://github.com/AEGEE/oms-neo-core | |
git clone -b dev --recursive https://github.com/AEGEE/oms-events | |
##temp fix | |
cd oms-events | |
git reset --hard 6e0aa0 | |
cd .. | |
##end temp fix | |
git clone --recursive https://github.com/AEGEE/oms-microservice-example | |
cd .. | |
#sed has different implementation if on linux (GNU) or mac (BSD)... | |
if [[ $(uname) == "Linux" ]]; then OS="linux" ; else OS="other" ; fi | |
#Set the rootdir of the project in Homestead.yaml (and the settings folder in the Vagrantfile) | |
rootdir=$(pwd) | |
cd oms-homestead/src/stubs | |
if [[ $OS == "linux" ]]; then | |
sed -i "s|CHANGEME|"${rootdir}"|" Homestead.yaml | |
sed -i "s|homestead-7|homestead7-"$(date "+%d-%h_%H%M")"|" Homestead.yaml | |
else | |
sed -i '' -e "s|CHANGEME|"${rootdir}"|" Homestead.yaml | |
sed -i '' -e "s|homestead-7|homestead7-"$(date "+%d-%h_%H%M")"|" Homestead.yaml | |
fi | |
cd $rootdir | |
mkdir .homestead | |
cd oms-homestead | |
if [[ $OS == "linux" ]]; then | |
sed -i "s|CHANGEME|"${rootdir}"/.homestead|" Vagrantfile | |
else | |
sed -i '' -e "s|CHANGEME|"${rootdir}"/.homestead|" Vagrantfile | |
fi | |
#Launch init script (but modify it first) | |
if [[ $OS == "linux" ]]; then | |
sed -i "s|CHANGEME|"${rootdir}"/.homestead|" init.sh | |
else | |
sed -i '' -e "s|CHANGEME|"${rootdir}"/.homestead|" init.sh | |
fi | |
source init.sh | |
#Start everything | |
vagrant up | |
} | |
function update-core { | |
cd oms-project/oms-neo-core | |
git pull | |
cd ../../oms-homestead | |
vagrant ssh -- 'cd oms-project/oms-neo-core && php artisan migrate' | |
} | |
function update-events { | |
cd oms-project/oms-events-module | |
git pull | |
cd ../../oms-homestead | |
vagrant ssh -- 'cd oms-project/oms-events-module && npm update ; \ | |
killall node && node lib/server.js &' #TODO cannot do that for future node scripts | |
} | |
#check what to execute: if only 1 argument is there (the file name) then | |
#launch the main function; otherwise launch verbatim the command | |
#that is passed as argument (i.e. update) (but after a security check) | |
if [[ $# -eq 0 ]]; then | |
install-oms | |
else | |
case "$@" in | |
"update-core") update-core ;; | |
"update-events") update-events ;; | |
"update-all") update-core && update-events ;; | |
*) echo "wrong parameter" && exit 1 ;; | |
esac | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment