Skip to content

Instantly share code, notes, and snippets.

@kordless
Forked from DoriftoShoes/stackstorm.json
Last active August 29, 2015 14:09
Show Gist options
  • Save kordless/c40a87c4f4759d435969 to your computer and use it in GitHub Desktop.
Save kordless/c40a87c4f4759d435969 to your computer and use it in GitHub Desktop.
This is the StackMonkey demo script for an OpenBazaar server. Demos can be found here: https://www.stackmonkey.com/demo/
{
"image": {
"url": "http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img",
"name": "Ubuntu Trusty",
"container_format": "bare",
"disk_format": "qcow2"
},
"callback_url": "",
"ssh_keys": [
""
],
"post_create": [
"#cloud-config",
"hostname: openbazzar",
"manage_etc_hosts: true",
"runcmd:",
" - [ wget, 'https://gist.githubusercontent.com/kordless/c40a87c4f4759d435969/raw/openbazaar_install.sh', -O, /tmp/install.sh ]",
" - chmod 755 /tmp/install.sh",
" - /tmp/install.sh"
]
}
#!/bin/bash
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "You need to be 'root' dude." 1>&2
exit 1
fi
clear
echo;
echo "##########################################################################################
This script is installing and configuring OpenBazaar for demo purposes.
##########################################################################################
";
echo;
# base directory
export BASE_DIR="/opt/OpenBazaar"
# install git
sudo apt-get -y install git
sudo apt-get -y install rng-tools
sudo apt-get -y install monit
# get the source
cd /opt/
git clone https://github.com/OpenBazaar/OpenBazaar.git ${BASE_DIR}
# deal with the random generator issues
sudo echo "HRNGDEVICE=/dev/urandom" >> /etc/default/rng-tools
sudo service rng-tools start
# hack the configurator for automation
cd /opt/OpenBazaar/
sudo sed -e "s/apt-get/apt-get -y /" configure.sh > configure_auto.sh
chmod 755 configure_auto.sh
# run the configurator
sudo ${BASE_DIR}/configure_auto.sh
# randomize port number
PORT=`shuf -i 10000-65000 -n 1`
# scripts to start and stop
cat <<EOF > ${BASE_DIR}/start.sh
#!/bin/bash
cd ${BASE_DIR}
./openbazaar -k 0.0.0.0 -q $PORT start
EOF
cat <<EOF > ${BASE_DIR}/stop.sh
#!/bin/bash
cd ${BASE_DIR}
./openbazaar stop
EOF
cat <<EOF > ${BASE_DIR}/cron_start.sh
#!/bin/bash
cd ${BASE_DIR}
./openbazaar -k 0.0.0.0 -q $PORT start
crontab -r
EOF
chmod 755 ${BASE_DIR}/stop.sh
chmod 755 ${BASE_DIR}/start.sh
chmod 755 ${BASE_DIR}/cron_start.sh
# monit config
cat <<EOF > /etc/monit/conf.d/openbazaar
set httpd port 5150 and
use address localhost
allow localhost
set daemon 30
with start delay 5
check process openbazaar matching "openbazaar"
start program = "/bin/bash ${BASE_DIR}/start.sh"
stop program = "/bin/bash ${BASE_DIR}/stop.sh"
EOF
# restart monit service
service monit restart
sleep 2
monit monitor all
# update the meta data on the pool directly
. /etc/utterio
curl -X PUT -d '{"openbazaar": "installed", "openbazaar_port": "'$PORT'"}' $MY_POOL_API_ADDRESS
# initial start using crontab (which wipes itself when it runs)
cat <<EOF > ${BASE_DIR}/crontab
* * * * * ${BASE_DIR}/cron_start.sh
EOF
crontab ${BASE_DIR}/crontab
echo;
echo "##########################################################################################
OpenBazaar setup complete.
##########################################################################################
";
echo;

OpenBazaar Demo Installer

This is the demo launcher for OpenBazaar used by StackMonkey. This URL is used by the demo:

https://gist.githubusercontent.com/kordless/c40a87c4f4759d435969/raw/openbazaar_install.sh

If you would like to start a OpenBazaar instance from the launcher, you will need to fork this gist and then use a URL for it that looks like this:

https://gist.githubusercontent.com/kordless/c40a87c4f4759d435969/raw/openbazaar.json

Be sure to put your SSH key in the first ssh_keys array string after you fork the gist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment