Last active
August 29, 2015 14:26
-
-
Save treehouse-su/90d2fe58e1d8e0dcbbd7 to your computer and use it in GitHub Desktop.
general nation qa raspberrypi script for BeLL
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 | |
# rename hostname from raspberrypi to qa | |
pirateship rename qa | |
# 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 = version | |
# 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 | |
wget https://github.com/open-learning-exchange/BeLL-Apps/archive/0.11.$3.zip | |
unzip *.zip | |
rm *.zip | |
ln -s BeLL-Apps-* BeLL-Apps | |
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://qa.local:5984/apps/_design/bell/MyApp/index.html | |
nation old 5984 52 | |
# http://qa.local:5985/apps/_design/bell/MyApp/index.html | |
nation new 5985 57 | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment