Skip to content

Instantly share code, notes, and snippets.

@mariodian
Created May 8, 2016 09:44
Show Gist options
  • Save mariodian/e6f50acd4d0264927d602e18777d7d11 to your computer and use it in GitHub Desktop.
Save mariodian/e6f50acd4d0264927d602e18777d7d11 to your computer and use it in GitHub Desktop.
OpenBazaar Server installation script for Ubuntu
#!/bin/bash
# Run: "chmod u+x obsetup.sh" before running the script
user=$(whoami)
dir=$(pwd)
if [ $user = 'root' ]; then
echo "Please run this script as a regular user."
exit;
fi
echo "Running the OB setup script to install a OpenBazaar server."
echo
echo "Do you wish to install it? (type the number)"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit;;
esac
done
echo
echo "Please create your server username and password."
read -p "OB Username: " username
while true
do
read -s -p "OB Password: " password
echo
read -s -p "Password (again): " password2
echo
[ "$password" = "$password2" ] && break
echo "Passwords didn't match. Please try again."
done
echo "Username and password saved!"
echo
sudo ls > /dev/null
echo "Instalation initialized, please wait, it may take a while to finish."
echo
# Add a repository and update the system
sudo add-apt-repository ppa:chris-lea/libsodium -y
sudo apt-get update -y && sudo apt-get upgrade -y
# Install all necessary apps, dev-tools and libraries
sudo apt-get install git build-essential libssl-dev libffi-dev python-dev openssl python-pip autoconf pkg-config libtool libzmq3-dev libsodium-dev -y
# Install crypto package
sudo pip install cryptography
echo
# Install libzmq from source
cd $dir
git clone https://github.com/zeromq/libzmq
cd libzmq
./autogen.sh && ./configure && make -j 4
make check && sudo make install && sudo ldconfig
echo
# Install the server
cd $dir
git clone https://github.com/OpenBazaar/OpenBazaar-Server.git
cd OpenBazaar-Server
sudo pip install -r requirements.txt
echo
echo "Setting up your username and password."
sed -i -e "s/username/$username/g; s/password/$password/g" ob.cfg
sed -i -e "s/#USERNAME/USERNAME/g; s/#PASSWORD/PASSWORD/g" ob.cfg
echo
echo "Creating the upstart script."
# Create an upstart script
cd /etc/init
upstart_script='openbazaar.conf'
sudo wget https://gist.githubusercontent.com/mariodian/d2f3e20b9e83d3bf339cf7da66b33f1f/raw/bde389b5810dd007a1c760bc316b93a6c39d7d68/openbazaar.conf
sudo sed -i -e "s#/home/ubuntu#$dir#g;" $upstart_script
sudo sed -i -e "s/ubuntu/$user/g;" $upstart_script
sudo chmod 644 $upstart_script
cd $dir
echo
echo "OpenBazaar server is sucessfully installed!"
echo
echo "Please open these ports on your firewall:"
echo "UDP on port 18467"
echo "TCP on ports 18466, 18469-18470"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment