Pages:
Author

Topic: How to run your own P2Pool in Ubuntu 14.04 LTS with merged mining - page 3. (Read 54246 times)

member
Activity: 112
Merit: 10
Just a note about the install script from Kryos - might need to either document or change how the code for p2pool itself is grabbed.

Going through building a node here, and we're behind a corporate firewall.  In the script, you're using a git:// repo.  Here that's blocked, and I'm sure other places, so when running the script you get this:

:~$ git clone git://github.com/forrestv/p2pool.git
Cloning into 'p2pool'...
fatal: unable to connect to github.com:
github.com[0: 192.30.252.128]: errno=Connection refused

I missed this in the initial install, and it took me a while to realize what had happened since that step flew by pretty quick.

Most of the other git clones are using http or https, which is much more standard firewall friendly.  I did this instead, and now all is well:

:~$ git clone https://github.com/forrestv/p2pool

Other than that, everything is going swimmingly.  Awesome script and tutorial both of you, thanks a bunch!
legendary
Activity: 996
Merit: 1013
full member
Activity: 196
Merit: 100
Updated letuslook addnodes.

Also put a note to check KyrosKrane page as it is more complete.

Kyros i have updated binaries!
HUC had some changes and I include bitcoin 0.9.2.1 (ppa still has older version).
So you might change to ~/bin/bitcoind or stick with ppa and hopefully it will get updated to 0.9.2.1.

576f0bdc8659cdd36f627402e1d79b12  p2pool-files.tar.gz

Please update the md5sum in your script.
full member
Activity: 146
Merit: 100
Thank you so much for the tutorial! Got my own EU (Amsterdam) p2pool running @ 149.210.172.171:9332

p.s. you might add the following nodes for every coin in the config files (coin.conf):

Ixcoin
Code:
addnode=198.154.60.183
addnode=50.116.37.18

Namecoin
Code:
addnode=212.71.251.113
addnode=192.241.171.45

Devcoin
Code:
addnode=dvc.rpwt.org:52333
addnode=devcoin.rpwt.org:52333
addnode=dvc.rpwt.org:52333
addnode=devcoin.rpwt.org:52333
addnode=devcoin.rpwt.org:52333
addnode=dvc.us.public.txn.co.in
addnode=dvc.eu.public.txn.co.in

I0coin
Code:
addnode=85.17.248.211:7333
addnone=198.154.60.61:7333
addnode=188.165.216.59:7333

Fusioncoin
Code:
addnode=54.193.11.95
addnode=54.255.130.210
addnode=198.23.242.92
addnode=121.199.12.227
addnode=54.185.94.219

Huntercoin
Code:
addnode=162.243.175.205
sr. member
Activity: 295
Merit: 250
Yes it can. Use the --address parameter on your command line that starts p2pool, so it looks something like this:

Code:
screen -d -m -S p2pool 
~/p2pool/run_p2pool.py $Bitcoin_User $Bitcoin_Password \
--merged http://$Namecoin_User:[email protected]:7333 \
--merged http://$Ixcoin_User:[email protected]:8338 \
--merged http://$Devcoin_User:[email protected]:6333 \
--merged http://$i0coin_User:[email protected]:7338 \
--merged http://$Fusioncoin_User:[email protected]:18491 \
--merged http://$Huntercoin_User:[email protected]:8399 \
--address 1YourBitcoinAddress

(Code's taken from my script, so obviously your version will have different usernames and passwords.)
hero member
Activity: 700
Merit: 504
Run a Bitcoin node.
Wonderful, thanks! At some stage I want to try this (got to get a server first).

Noob question: can p2pool be set up to mine to a bitcoin address? I like to mine to a cold-storage address, not to a local wallet.
sr. member
Activity: 295
Merit: 250
Thanks for that! The post is a few months old, so I want to test it in a VM first and see how it can be added to my existing script.

Quick preview of what I'm working on: http://bitcoin.kyros.info/preview.html
hero member
Activity: 924
Merit: 1000
Watch out for the "Neg-Rep-Dogie-Police".....
Slightly odd question.  Can someone please point me to (or provide me with) a set of copy/paste instructions for compiling bitcoind on a clean install of Ubuntu 14.04? I tried to wade through the readme, honestly I did, but it left my head spinning about what is and isn't a required dependency.

https://gist.github.com/yubrew/5571485
sr. member
Activity: 295
Merit: 250
Slightly odd question.  Can someone please point me to (or provide me with) a set of copy/paste instructions for compiling bitcoind on a clean install of Ubuntu 14.04? I tried to wade through the readme, honestly I did, but it left my head spinning about what is and isn't a required dependency.
full member
Activity: 196
Merit: 100
Thanks Kyros,

great stuff. of course your not hijacking!

When you post your thread let me know so I put a link on the first post!
sr. member
Activity: 295
Merit: 250
replace it in both occasions:
eg
sudo chmod -R murdof:murdof .*
sudo chmod -R murdof:murdof *

To make this generic for everyone, you could do this:

Code:
sudo chown -R $(whoami):$(whoami) .*
sudo chown -R $(whoami):$(whoami) *

Edit: Corrected the command to chown.
sr. member
Activity: 434
Merit: 250
you guys are great, I think you should just leave it all in this thread... all us; important people, have been following every word anyway  Cheesy
sr. member
Activity: 295
Merit: 250
It would be awesome if KyrosKrane's script could be accessed by the wget method you used as that was easy. I'll have to figure out how to get that bash script into the VM and work out how to run it. Having the wget would make unix noobs setup of the P2Pool sooo much easier.

Ask and ye shall receive! Smiley

Code:
### To download ###
wget http://bitcoin.kyros.info/install-merged-mining.sh

### To run, without downloading the blockchain via http ###
./install-merged-mining.sh --compile
### OR ###
./install-merged-mining.sh --download

### To run, WITH downloading the blockchain via http ###
./install-merged-mining.sh --compile --http
### OR ###
./install-merged-mining.sh --download --http

I also threw up a little info page where you can download it through a browser, if you're on Ubuntu Desktop.  You can see that here:

http://bitcoin.kyros.info/

Murdof, sorry to hijack your thread. Sad I'll post my own thread about this shortly, but I'm doing a few additional updates to the script that I want to complete first.
full member
Activity: 196
Merit: 100
You are right

chown should be run with sudo in front.

i hope you replace (youruser) with your username

you can find your username by just typing:
whoami

replace it in both occasions:
eg
sudo chmod -R murdof:murdof .*
sudo chmod -R murdof:murdof *

Kyros has done great work but unfortunately I don't have the time to implement everything in the guide this week as I'm working and I will be away for the weekend.
sr. member
Activity: 297
Merit: 250
Hi and thanks for a well written guide.

I noticed a couple of things while working through it that had me stuck for a bit as I'm not a linux user and am setting this up in a VM so I can run my own P2Pool node.

In the following I've highlighted what I think are errors in red:

After you install Linux Ubuntu 14.04 LTS, login and execute the following commands:
Code:

wget http://pool.nitro.gr/install-p2pool.sh
sudo sh ./install-p2pool.sh
chmod -R (youruser):(youruser) .*
chmod -R (youruser):(youruser) *

It will install everything (it will use the binaries not compile everything again) and you just have to wait...
Do a reboot and you are done.
Double check with "ls -al" that all files have owner/group your user. If it says root then do "chown -R (user):(group) *" and then "chown -R (user):(group) .*"

Should the chmod be chown as chmod says that format is incorrect?

Should ls -al be ls -la ?

Also I had to do sudo chown -R (user):(group) * & sudo chown -R (user):(group) .* as they were owned by root and wouldn't allow a chown without sudo first.

Sorry if this is wrong, like I said I'm not a unix personal so picking this up as I go.

Without your guide I wouldn't know where to start so thank you once again.

It would be awesome if KyrosKrane's script could be accessed by the wget method you used as that was easy. I'll have to figure out how to get that bash script into the VM and work out how to run it. Having the wget would make unix noobs setup of the P2Pool sooo much easier.

Cheers to both you guys for sharing your work with everyone!
legendary
Activity: 1148
Merit: 1000
I finally got around to setting up an Ubuntu machine today. It's downloading the blockchain and hopefully I will get to work on this tomorrow. Looking forward to tinkering.  I have some USBs for testing so go me!

ig
hero member
Activity: 798
Merit: 1000
www.DonateMedia.org
Excellent guide, thank you! After going through so many others this is by far the most complete.
sr. member
Activity: 295
Merit: 250
I've been thinking about your proposal for the last day or so. In that time, I've come to realize a few things.

1) Your guide is still necessary. My script is the technical solution, but your guide is the human solution. It does a far better job of explaining what's going on to a relatively new user.

2) The June 21 version of my script, which is basically just glomming all the code from your guide into one script with a little scripting glue, is probably better for you to use. It's clearer to read, and it follows the human-readable guide much more closely.

3) I like to keep adding bells and whistles to my scripts. At some point, that will likely break backwards compatibility (e.g., requiring a new launch command) which would require you to modify your guide. That adds complexity to what should be a simple guide, and it adds to your maintenance overhead to keep the script and the guide in sync.

4) While I'm happy to publish my scripts, they're ultimately written because they're something I use or would likely use. I know I'm not a particularly good representative of the general community, so perhaps I'm not the best candidate to write a guide.

5) I know very little about the practical realities of compiling code on Linux (or any OS, for that matter). I can copy/paste code snippets and compile commands with the best of them, but if you just hand me a git URL and tell me, "go build this," I'd likely be lost.

So, based on all that, my suggestion is that you maintain your guide as the beginner's entry point into p2pool, and use my script from June 21.  Feel free to customize it as you update your guide, or to use the June 23 script if it's better for you. I'll update my June 23 script into a more advanced tool and post a new topic about it in the near future. I've already got some ideas on how to advance it, including having a Web page that essentially generates a custom script for you to download and use.
full member
Activity: 196
Merit: 100
KyrosKrane this is great stuff!

I haven't updated the guide yet cause I want to try it on a fresh vps in order to see the experience to update the guide.

One other solution is to start a new thread with you taking over since most of the work is yours now and we point people to the new thread so you can update it.

What do you think?
sr. member
Activity: 295
Merit: 250
I've finished the revisions to the script.  I've made it much more modular, and it's now easy to expand it for any future merge-mined coins.

It's majorly revised from the last version.  It can now be used to both download for the first time, or to update an existing install.  I put in some logic in there to preserve the RPC username and password for the various coins, too, in case you have other tools that need to use them.

Murdof, if you do adopt this version of the script, you'll have to remove the config files from your download archive (or at least the username and password lines).  The script will add them back in.

Feedback greatly appreciated! This one isn't as thoroughly bug-tested as my last script, but I've squashed all the bugs I was able to find.

Code:
#!/bin/bash

# A function to display help and exit.
Usage()
{
echo "$(basename $0): Downloads and installs bitcoind, p2pool, and other coins for merged mining." >&2
echo "Usage:" >&2
echo "To download precompiled binaries (faster but less secure):" >&2
echo "        $(basename $0) --download" >&2
echo "To download the source code and compile yourself (slower but more secure):" >&2
echo "        $(basename $0) --compile" >&2
echo "You may also choose to download the bitcoin blockchain via http. Add the following to the command line:" >&2
echo "        --http" >&2
echo "If you don't use this, the blockchain will instead download using the (much slower) built-in peer-to-peer process." >&2
echo >&2
exit 1
} # Usage()


################################################
# Coin Settings
################################################


# Create arrays for storing the various coin RPC usernames, passwords, and other settings.
declare -A CoinUser
declare -A CoinPassword
declare -A CoinPort
declare -A CoinRPCPort
declare -A CoinSourceDownload
declare -A CoinSourceUpdate
declare -A CoinCompileCommand
declare -A CoinSymbol

# Set the default values for all the coins.
# These will be overridden by existing values in the config files.
# Note that you never need to remember the various RPC usernames and passwords; they just have to exist and be unguessable.
# Also note that the path to the config file is always of the form ~/coinname/coinname.conf. If you ever add a coin that doesn't meet this assumption, you'll have to add another array to track the config file location.
CoinUser["bitcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["bitcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["bitcoin"]=8333
CoinRPCPort["bitcoin"]=8332
CoinSourceDownload["bitcoin"]="" # @TODO: Fill this out.
CoinSourceUpdate["bitcoin"]="" # @TODO: Fill this out.
CoinCompileCommand["bitcoin"]="" # @TODO: Fill this out.
CoinSymbol["bitcoin"]=BTC

CoinUser["namecoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["namecoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["namecoin"]=8334
CoinRPCPort["namecoin"]=7333
CoinSourceDownload["namecoin"]="git clone https://github.com/namecoin/namecoin"
CoinSourceUpdate["namecoin"]="git pull"
CoinCompileCommand["namecoin"]="make -f Makefile"
CoinSymbol["namecoin"]=NMC

CoinUser["ixcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["ixcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["ixcoin"]=8337
CoinRPCPort["ixcoin"]=8338
CoinSourceDownload["ixcoin"]="git clone https://github.com/FrictionlessCoin/iXcoin ixcoin"
CoinSourceUpdate["ixcoin"]="git pull"
CoinCompileCommand["ixcoin"]="make -f makefile.unix"
CoinSymbol["ixcoin"]=IXC

CoinUser["devcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["devcoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["devcoin"]=6334
CoinRPCPort["devcoin"]=6333
CoinSourceDownload["devcoin"]="git clone git://gitorious.org/devcoin/devcoin.git"
CoinSourceUpdate["devcoin"]="git pull"
CoinCompileCommand["devcoin"]="make -f makefile.unix USE_PNP=1 devcoind"
CoinSymbol["devcoin"]=DVC

CoinUser["i0coin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["i0coin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["i0coin"]=7337
CoinRPCPort["i0coin"]=7338
CoinSourceDownload["i0coin"]="git clone http://github.com/rsnel/i0coin/"
CoinSourceUpdate["i0coin"]="git pull"
CoinCompileCommand["i0coin"]="make -f makefile.unix i0coind"
CoinSymbol["i0coin"]=I0C

CoinUser["fusioncoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["fusioncoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["fusioncoin"]=8492
CoinRPCPort["fusioncoin"]=18491
CoinSourceDownload["fusioncoin"]="git clone https://github.com/fusioncoin/fusioncoin"
CoinSourceUpdate["fusioncoin"]="git pull"
CoinCompileCommand["fusioncoin"]="make -f makefile.unix"
CoinSymbol["fusioncoin"]=FSC

CoinUser["huntercoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPassword["huntercoin"]=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
CoinPort["huntercoin"]=8398
CoinRPCPort["huntercoin"]=8399
CoinSourceDownload["huntercoin"]="git clone https://github.com/chronokings/huntercoin"
CoinSourceUpdate["huntercoin"]="git pull"
CoinCompileCommand["huntercoin"]="make -f Makefile"
CoinSymbol["huntercoin"]=HUC


# This is the list of coins that should be compiled (if the user selects that option) -- this should be all coins except Bitcoin.
CompileCoins="namecoin ixcoin devcoin i0coin fusioncoin huntercoin"

# This is the list of all coins, both compiled and non-compiled. Generally this should be only Bitcoin that's unique here.
AllCoins="bitcoin $CompileCoins"


################################################
# Utility functions
################################################


#
# Gets the settings for a given coin and adds them to the Coin*[] global arrays.
#
# Parameters:
# $1: Coin name (string literal, used in the associative array. No spaces.)
# $2: (optional) Path and filename of the config file. If not specified, the default path is used.
#
# Return value:
# 0: Settings already exist, retrieved and added to global arrays.
# 1: One or more settings do not exist in the file.
# Settings that do exist were retrieved and added to global arrays.
# 98: Parameter error.
# 99: Error in reading file (not found or no read permission).
#
# Output:
# None
#
GetSettings()
{
# Make sure we have the right number of parameters, and that a coin name is specified.
if [ $# -lt 1 -o $# -gt 2 -o -z "$1" ] ; then
return 98
fi

# Get the path and filename of the config file
local filepath
if [ -n "$2" ] ; then
filepath="$2"
else
filepath="$HOME/.$1/$1.conf"
fi

# Make sure the config file exists and is readable.
if [ ! -r "$filepath" ] ; then
return 99
fi

# Read the values from the file.
local user password port rpcport retval
user="$(grep -i "rpcuser" "$filepath" | awk -F= '{print $2}')"
password="$(grep -i "rpcpassword" "$filepath" | awk -F= '{print $2}')"
port="$(grep -ie "^port" "$filepath" | awk -F= '{print $2}')"
rpcport="$(grep -i "rpcport" "$filepath" | awk -F= '{print $2}')"

# Update the appropriate arrays, if the value was read from the file.
[ -n "$user" ] && CoinUser["$1"]="$user"
[ -n "$password" ] && CoinPassword["$1"]="$password"
[ -n "$port" ] && CoinPort["$1"]="$port"
[ -n "$rpcport" ] && CoinRPCPort["$1"]="$rpcport"

# The global arrays now contain all the settings, either read from the file or the global defaults, for the given coin.

# Return the appropriate value.
[ -z "$user" -o -z "$password" -o -z "$port" -o -z "$rpcport" ] && return 1
return 0
} # GetSettings()



#
# Adds a line to a settings file if it doesn't already exist.
#
# Parameters:
# $1: Coin name (string literal, used in the associative array. No spaces.)
# $2: The line to add.
# $3: (optional) Path and filename of the config file. If not specified, the default path is used.
#
# Return value:
# 0: Line added.
# 1: Line already exists.
# 98: Parameter error.
# 99: Error in reading file (not found or no read permission).
#
# Output:
# None
#
AddLine()
{
# Make sure we have the right number of parameters, and that a coin name is specified.
if [ $# -lt 1 -o $# -gt 3 -o -z "$1" -o -z "$2" ] ; then
return 98
fi

# Get the path and filename of the config file
local filepath
if [ -n "$3" ] ; then
filepath="$3"
else
filepath="$HOME/.$1/$1.conf"
fi

# Make sure the config file exists and is readable.
if [ ! -r "$filepath" ] ; then
return 99
fi

# Add the line if it doesn't already exist.
local matchstring=$(echo "$2" | sed -e 's/[]\/$*.^|[]/\\&/g')
if ! grep -qe "^$matchstring\$" "$filepath" ; then
echo "$2" >> "$filepath"
return 0
fi
return 1
} # AddLine()



#
# Updates the settings file for a given coin.
#
# Parameters:
# $1: Coin name (string literal, used in the associative array. No spaces.)
# $2: (optional) Path and filename of the config file. If not specified, the default path is used.
#
# Return value:
# 0: Settings updated.
# 98: Parameter error.
# 99: Error in reading file (not found or no read permission).
#
# Output:
# None
#
UpdateSettings()
{
# Make sure we have the right number of parameters, and that a coin name is specified.
if [ $# -lt 1 -o $# -gt 2 -o -z "$1" ] ; then
return 98
fi

# Get the path and filename of the config file
local filepath
if [ -n "$2" ] ; then
filepath="$2"
else
filepath="$HOME/.$1/$1.conf"
fi

# Make sure the config file exists and is readable.
if [ ! -r "$filepath" ] ; then
return 99
fi

# Make sure the three static lines always exist in the file
local Line
for Line in "server=1" "daemon=1" "rpcallowip=127.0.0.1"
do
AddLine "$1" "$Line" "$filepath"
done

# Remove the four parametric lines, then add in the correct values
grep -ve "^rpcuser=" "$filepath" | grep -ve "^rpcpassword="  | grep -ve "^port="  | grep -ve "^rpcport=" > "$filepath.tmp"
mv "$filepath.tmp" "$filepath"
AddLine "$1" "rpcuser=${CoinUser[$1]}" "$filepath"
AddLine "$1" "rpcpassword=${CoinPassword[$1]}" "$filepath"
AddLine "$1" "port=${CoinPort[$1]}" "$filepath"
AddLine "$1" "rpcport=${CoinRPCPort[$1]}" "$filepath"
echo "" >> "$filepath"

} # UpdateSettings()



################################################
# Main Script Start
################################################


# Determine what the user wants to do, or display help
if [ $# -eq 0 ] ; then
Usage
else
while [ $# -gt 0 ] ; do
if [ "--download" = "$1" ] ; then
Method="download"
elif [ "--compile" = "$1" ] ; then
Method="compile"
# elif [ "--torrent" = "$1" ] ; then
# Blockchain="torrent"
elif [ "--http" = "$1" ] ; then
Blockchain="http"
else
echo "Error: Unrecognized parameter on command line. Aborting" >2
Usage
fi
shift
done
fi

# Make sure the user specified where to compile or download
if [ -z "$Method" ] ; then
echo "Error: No installation method specified (compile or download). Aborting" >2
Usage
fi



################################################
# Sudo Script Creation and Run
################################################


# Create a script to update the system.  This requires sudo, so we can't run it directly.
cat <~/sudoscript.sh
#!/bin/sh

# Install the pre-req for add-apt-repository
apt-get -y install software-properties-common

# Add the bitcoin repository
add-apt-repository -y ppa:bitcoin/bitcoin

# Update installed packages
apt-get -y update
apt-get -y dist-upgrade

# Install the needed prerequisites
# Note that bitcoind is always installed as a binary, not compiled.
apt-get -y install bitcoind python-software-properties screen git python-rrdtool python-pygame python-scipy python-twisted python-twisted-web python-imaging build-essential libglib2.0-dev libglibmm-2.4-dev libqt4-dev python-dev libssl-dev libdb5.1++-dev libboost1.55-all-dev dh-autoreconf libcurl4-openssl-dev libminiupnpc-dev ufw p7zip-full

# Set up and configure a firewall, if it isn't already there.
# Note that we do NOT enable the RPC port for any coins!
ufw default deny    # Deny everything unless expressly permitted
ufw allow 22/tcp    # SSH
ufw allow 8333/tcp  # bitcoin peer to peer
ufw allow 8334/tcp  # namecoin peer to peer
ufw allow 8337/tcp  # ixcoin peer to peer
ufw allow 6334/tcp  # devcoin peer to peer
ufw allow 7337/tcp  # i0coin peer to peer
ufw allow 8492/tcp  # fusioncoin peer to peer
ufw allow 8398/tcp  # huntercoin peer to peer
ufw allow 9333/tcp  # P2pool peer to peer
ufw allow 9332/tcp  # P2Pool connections and Web interface
ufw --force enable  # Turn it on

EOF

echo "About to update your system.  This requires elevated privileges. Please enter your password when prompted."
sleep  2 # pause so the user has a chance to see and read the message.
sudo sh ~/sudoscript.sh
rm ~/sudoscript.sh



################################################
# P2Pool Installation or Update
################################################


# Install p2pool
if [ -d ~/p2pool/ ] ; then
cd ~/p2pool
git pull
else
cd
git clone git://github.com/forrestv/p2pool.git
fi



################################################
# Coin Binaries Setup
################################################


# Now either download or compile the binaries.
if [ "$Method" = "download" ] ; then


################################################
# Binary Download
################################################

# Download and unpack scripts and binaries for other coins
cd
wget http://pool.nitro.gr/p2pool-files.tar.gz

# Ensure the compiled binaries archive is valid! This checksum has to be updated each time the binaries are repackaged.
# Too much manual work, Murdof can enable this if he wants to maintain it. (Switch "false" to "true")
if false; then
checksum="$(md5sum p2pool-files.tar.gz | awk '{print $1;}')"
if [ "$checksum" != "0e35d6a1ee234b1a90975588917275eb" ] ;  then
echo "ERROR: Downloaded binaries are corrupt or have been tampered with! Please try running this script again.  If this error repeats, please contact the script author here:" >&2
echo "https://bitcointalk.org/index.php?topic=651819.0" >&2
exit 3
fi
fi

Status="$Status\nDownload succeeded."

# Unpack the binaries and delete the downloaded archive.
tar xvzf p2pool-files.tar.gz
rm p2pool-files.tar.gz

elif [ "$Method" = "compile" ] ; then


################################################
# Compile from Coin Source
################################################

# Make the local binaries directory
mkdir -p ~/bin

# Make a directory to download and store all the alt-coin sources
mkdir -p ~/coin_source

for Coin in $CompileCoins ; do

cd ~/coin_source
if [ -d ~/coin_source/$Coin/ ] ; then
cd ~/coin_source/$Coin
${CoinSourceUpdate[$Coin]}
else
${CoinSourceDownload[$Coin]}
fi
cd ~/coin_source/$Coin/src
${CoinCompileCommand[$Coin]}
if [ -f ${Coin}d ] ; then
Status="$Status\n${Coin} compilation succeeded."
strip ${Coin}d
cp ${Coin}d ~/bin
else
Status="$Status\n${Coin} compilation FAILED."
fi
done

else
# This should never happen! It means there's an error in this script itself.
echo "Unhandled error! Bad programmer! No cookie!" >&2
exit 2
fi


################################################
# Script settings creation
################################################


for Coin in $AllCoins ; do

# Make directories for everything
mkdir -p ~/.${Coin}

# Create an empty config file, if it doesn't already exist.
ConfigFile=$HOME/.${Coin}/${Coin}.conf
touch "$ConfigFile"

# Read the old settings from the config file, if any.
GetSettings "$Coin" "$ConfigFile"

# Update the settings.
UpdateSettings "$Coin" "$ConfigFile"
done



################################################
# "Batch Files" Creation
################################################


# Create the startup script for all coins and p2pool.
cat >~/start-p2pool <#!/bin/sh
/usr/bin/bitcoind -daemon
~/bin/namecoind -daemon
~/bin/ixcoind -daemon
~/bin/devcoind -daemon >/dev/null # For some reason, devcoin writes to the terminal, even when started as a daemon.
~/bin/i0coind -daemon
~/bin/fusioncoind -daemon
~/bin/huntercoind -daemon
screen -d -m -S p2pool \\
~/p2pool/run_p2pool.py ${CoinUser["bitcoin"]} ${CoinPassword["bitcoin"]} \\
EOF


for Coin in $CompileCoins
do
echo " --merged http://${CoinUser[$Coin]}:${CoinPassword[$Coin]}@127.0.0.1:${CoinRPCPort[$Coin]} \\" >>~/start-p2pool
done
echo "" >>~/start-p2pool
echo "" >>~/start-p2pool
chmod 755 ~/start-p2pool


# Create a script to list the value of all coin wallets.
cat >~/listallcoins <#!/bin/sh
echo "BTC: \$(/usr/bin/bitcoind -rpcpassword=${CoinPassword[bitcoin]} listaccounts | awk '{getline; print \$NF;exit;}')"
EOF

for Coin in $CompileCoins
do
cat >>~/listallcoins <echo "${CoinSymbol[$Coin]}: \$($HOME/bin/${Coin}d -rpcpassword=${CoinPassword[$Coin]} listaccounts | awk '{getline; print \$NF; exit;}')"
EOF

done

chmod 755 ~/listallcoins



################################################
# Bitcoin Blockchain Download
################################################


# If requested, download the blockchain.
if [ "$Blockchain" = "http" ] ; then
cd ~/.bitcoin

#wget https://bitfetch.com/static/bootstrap.7z
# Note: as of this writing, the SSL certificate for bitfetch.com has expired.
# If you just try to wget the file, wget will fail, complaining about it.
# So, we have to force wget to ignore the expired certificate. Once the
# certificate on the site has been properly renewed, delete the line below
# and uncomment the line above.
wget --no-check-certificate https://bitfetch.com/static/bootstrap.7z

# unzip it.
7z x bootstrap.7z
#elif [ "$Blockchain" = "torrent" ] ; then
# @TODO: No clue how torrenting works on Unix. Someone else can fill this in.
fi


################################################
# Wrap up and exit
################################################


# Wrap up; tell the user we succeeded, and ask him to reboot.
echo
echo
echo
echo "Installation results:"
echo -e "$Status"
echo
echo "It is strongly advised that you reboot at this point. After rebooting,"
echo "start p2pool and all the coin daemons with this command:"
echo "      ~/start-p2pool"
echo
echo "You may also add this line to your cron so it starts automatically:"
echo "      @reboot $HOME/start-p2pool"
echo
echo "You may check your coin balances at any time with this command:"
echo "      ~/listallcoins"
echo
echo "Thank you for helping to protect the bitcoin network by participating"
echo "in p2pool, and good luck with your mining!"


Edit: v1.1 - Fixed a bug with listallcoins, and a potential bug in AddLines. Also documentation updates.
Pages:
Jump to: