Skip to content

Instantly share code, notes, and snippets.

@dogi
Last active September 9, 2015 20:16
Show Gist options
  • Save dogi/9c37ca68982f488dd9b9 to your computer and use it in GitHub Desktop.
Save dogi/9c37ca68982f488dd9b9 to your computer and use it in GitHub Desktop.
nation bell qa out of git
#!/bin/bash
# rename hostname from raspberrypi to git
pirateship rename git
# configure static global valid ip address
#pirateship ethernet 204.9.221.79 255.255.255.128 204.9.221.1 "204.9.221.30 204.9.223.18 204.9.223.19"
#sleep 10
# template for nation install
function nation {
# s1 = name
# s2 = port
# s3 = branch
# create couchdb docker container
docker run -d -p $2:5984 --name $1 -v /srv/data/$1:/usr/local/var/lib/couchdb -v /srv/log/$1:/usr/local/var/log/couchdb dogi/rpi-couchdb
# download BeLL-Apps
mkdir -p /root/ole/$3
cd /root/ole/$3
git clone -b $3 https://github.com/open-learning-exchange/BeLL-Apps.git
cd BeLL-Apps
# create install_linux
echo "node_modules/.bin/couchapp push \$1 \$2" > pushDocToDb.sh
chmod +x node_modules/.bin/couchapp pushDocToDb.sh
cp install_windows install_linux
sed -i "s/pushDocToDb.bat/.\/pushDocToDb.sh/" install_linux
sed -i 's#databases\\\\#databases/#' install_linux
# install nation
node install_linux http://127.0.0.1:$2
curl -X PUT 'http://127.0.0.1:'$2'/_config/httpd/allow_jsonp' -d '"true"'
#curl -X PUT 'http://127.0.0.1:'$2'/_config/httpd/enable_cors' -d '"true"'
#curl -X PUT 'http://127.0.0.1:'$2'/_config/cors/origins' -d '"*"'
curl -X PUT 'http://127.0.0.1:'$2'/_config/admins/nation' -d '"oleoleole"'
# overwrite some .couch with qa-content
#docker stop $1
#wget http://download.ole.org/.qa/content/collectionlist.couch -O /srv/data/$1/collectionlist.couch
#wget http://download.ole.org/.qa/content/coursestep.couch -O /srv/data/$1/coursestep.couch
#wget http://download.ole.org/.qa/content/groups.couch -O /srv/data/$1/groups.couch
#wget http://download.ole.org/.qa/content/publications.couch -O /srv/data/$1/publications.couch
#wget http://download.ole.org/.qa/content/resources.couch -O /srv/data/$1/resources.couch
#docker start $1
# add to '/boot/autorun.sh'
echo 'sleep 1' >> /boot/autorun.sh
echo 'docker start '$1 >> /boot/autorun.sh
}
echo '#!/bin/sh' > /boot/autorun.sh
echo '' >> /boot/autorun.sh
# http://git.local:5984/apps/_design/bell/MyApp/index.html
nation git 5984 dev
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment