Browse Source

Merge pull request #89 from kmpm/vagrant

Added support for building in vagrant
miguelfreitas
miguelfreitas 11 years ago
parent
commit
9a789ec988
  1. 4
      .gitignore
  2. 20
      Vagrantfile
  3. 29
      doc/building-on-vagrant.md
  4. 30
      scripts/activate
  5. 37
      scripts/bin/twister
  6. 88
      scripts/vagrant_bootstrap.sh

4
.gitignore vendored

@ -11,6 +11,10 @@ src/test_bitcoin @@ -11,6 +11,10 @@ src/test_bitcoin
*.patch
.bitcoin
#vagrant part
vagrant
.vagrant
# Compilation and Qt preprocessor part
*.qm
Makefile

20
Vagrantfile vendored

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = 'debian7'
config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210.box'
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
end
#config.vm.synced_folder '.', '/srv/Mailpile'
config.vm.network :public_network
config.vm.network :forwarded_port, guest: 28332, host: 28332, guest_ip: '127.0.0.1'
config.vm.provision :shell, :path => 'scripts/vagrant_bootstrap.sh'
end

29
doc/building-on-vagrant.md

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
# Vagrant + Debian building instructions
This will run a virtual machine with all tools required to build and run twister
using Vagrant.
This will probably work wherever vagrant can be installed.
## Dependencies
* http://www.vagrantup.com/
* https://www.virtualbox.org/
## Install
1. git clone https://github.com/miguelfreitas/twister-core.git
1. cd twister-core
1. vagrant up
## Tweeking
If you have lots of ram in your machine, feel free to use it
edit the twister-core/Vagrantfile and change the line
```
v.customize ["modifyvm", :id, "--memory", 1024]
```
and write 2048, 4096 or whatever you feel resonable
before running vagrant up.
This will make compile time and life in general much
better in the virtual machine.

30
scripts/activate

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TWISTER_CORE_PATH='/home/vagrant/twister-core'
export TWISTER_HOME='/home/vagrant/.twister'
alias twisterd='$TWISTER_CORE_PATH/src/twisterd'
if [ ! -n "$TWISTER_OLD_PATH" ]; then
echo 'setting up the environment'
export TWISTER_OLD_PATH=$PATH
export TWISTER_OLD_PS1=$PS1
export PATH=$DIR/bin:$PATH
export PS1="(twister)$PS1\n> "
else
echo 'already active'
fi
function deactivate {
if [ -n "$TWISTER_OLD_PATH" ]; then
echo 'cleaning up the environment'
export PATH=$TWISTER_OLD_PATH
export PS1=$TWISTER_OLD_PS1
unset TWISTER_OLD_PATH
unset TWISTER_OLD_PS1
unset -f deactivate
fi
}

37
scripts/bin/twister

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
#!/bin/bash
RPCUSER='user'
RPCPASSWORD='pwd'
RPCALLOWIP='127.0.0.1'
BIN=$TWISTER_CORE_PATH/src/twisterd
CONFFILE="$TWISTER_HOME/twister.conf"
OPTS="-daemon -debug"
if [ ! -f "$CONFFILE" ]; then
OPTS='$OPTS -pid=$PIDFILE -rpcuser=$RPCUSER -rpcpassword=$RPCPASSWORD -rpcallowip=$RPCALLOWIP'
fi
function usage {
echo "Usage : $(basename $0) start|stop"
echo
exit
}
if [ $# -lt 1 ]
then
usage $@
fi
case "$1" in
start) $BIN $OPTS
echo
;;
stop) $BIN stop
;;
*) echo "Invalid option: $1"
usage $@
;;
esac

88
scripts/vagrant_bootstrap.sh

@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
#!/bin/bash
TWISTER_CORE_PATH='/home/vagrant/twister-core'
TWISTER_HOME='/home/vagrant/.twister'
AS_VAGRANT='sudo -u vagrant'
function failed {
echo
echo 'Something failed !!!!!'
echo
exit 1
}
function checkfail {
if [ ! $? -eq 0 ]; then
failed
fi
sleep 3
}
echo
echo 'Running bootstrap for twister-core'
echo
$AS_VAGRANT ln -s /vagrant $TWISTER_CORE_PATH
echo '.. fixing permissions'
cd $TWISTER_CORE_PATH
find $TWISTER_CORE_PATH/scripts -type d -exec chmod 755 {} \;
find $TWISTER_CORE_PATH/scripts -type f -exec chmod 644 {} \;
chmod 755 $TWISTER_CORE_PATH/scripts/bin/*
apt-get update
echo '.. installing tools and libraries'
apt-get install -y git build-essential autoconf libtool libssl-dev libboost-all-dev libdb++-dev libminiupnpc-dev openssl
checkfail
echo '.. bootstrapping libtorrent'
cd $TWISTER_CORE_PATH/libtorrent
$AS_VAGRANT ./bootstrap.sh
checkfail
$AS_VAGRANT ./configure --enable-logging --enable-debug --enable-dht
checkfail
echo '.. compiling'
cd $TWISTER_CORE_PATH/src
$AS_VAGRANT make -f makefile.unix
checkfail
echo '.. configuration & web gui'
$AS_VAGRANT mkdir $TWISTER_HOME
cd $TWISTER_HOME
$AS_VAGRANT touch twister.conf
echo -e "rpcuser=user\nrpcpassword=pwd\nrpcallowip=127.0.0.1" > twister.conf
chmod 600 twister.conf
git clone https://github.com/miguelfreitas/twister-html.git html
checkfail
if [ $? -eq 0 ]; then
echo
echo '=================================================================='
echo "
Done.
To start the web interface, enter the following command:
$ vagrant ssh -c '$TWISTER_CORE_PATH/src/twisterd -daemon -debug'
Open http://127.0.0.1:28332/index.html and use the user/pwd credentials
Create your account !
If you want to do some development or other stuff then...
$ vargrant ssh
$ source twister-core/scripts/activate
This will give you some nice to have commands like
* twister start|stop - to start and stop the server
* twisted - alias to ~/twisted-core/src/twisted
Good luck!
"
else
failed
fi
Loading…
Cancel
Save