KyrosKrane
|
|
June 19, 2014, 10:23:00 PM |
|
OK, so I threw together a VM and loaded Ubuntu Desktop 14.04 on it. Next I ran the two "lazy install" commands -- but they failed. ./install-p2pool.sh: 5: ./install-p2pool.sh: aptitude: not found ./install-p2pool.sh: 6: ./install-p2pool.sh: git: not found So, two things. First, use apt-get, not aptitude. apt-get will work fine on both server and desktop versions of Ubuntu. (I'm guessing that aptitude is installed by default on the server version; but it's not on the desktop version.) Second, I'd suggest reordering the commands in the script as follows. Yes, I added comments. #!/bin/bash
# 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 bitcoind and other needed prerequisites 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
# Install p2pool git clone git://github.com/forrestv/p2pool.git
# Download and unpack scripts and binaries for other coins wget http://pool.nitro.gr/p2pool-files.tar.gz tar xvzf p2pool-files.tar.gz rm p2pool-files.tar.gz
My one biggest concern is that the RPC passwords are hardcoded in your config files. While it's true you limit connections to 127.0.0.1, that still makes me nervous. I really suggest randomizing the passwords. You can use something similar to what I have in my script; I'd be happy to adapt the logic for your script if you like. I'd also strongly suggest that you incorporate the bootstrap download logic I have in my script -- that will shave off days of download time for the bitcoin blockchain. I'd even suggest you consider setting it up as a bittorrent download, although if someone uses this script on a VPS, they could get in trouble if their VPS provider doesn't allow torrents. Http is safer in that sense, but less "polite" on the network. Maybe prompt the user whether they'd like to download the blockchain via torrent, via http, or via the normal bitcoind client download? And set the client download as the default option, as that's the "safest." Finally, I'd suggest putting the "screen" commands and other useful scripts you mention later in your guide into shell scripts that are also included in the tar file. Essentially you want it to be similar to a Windows install -- download the installer, run it, and magically p2pool works, with easy-to-use commands all ready to use. More as I play further with this setup.
|
|
|
|
murdof (OP)
|
|
June 20, 2014, 04:28:00 AM |
|
Thanks Kyros!
Please do go ahead and make the changes.
Post them here and I will be happy to integrate them!
|
|
|
|
Acejam
|
|
June 20, 2014, 03:32:29 PM |
|
Murdof, how much of your RAM are you actually using on p2pool and Bitcoin client (aswell as the server OS)?
If you plan to run a P2Pool node with merged mining that actually gets a decent amount of traffic, plan on at least 4GB, minimum. In fact, you might out of memory on that pretty easily. I know I certainly have. Most VPS providers allow you to exceed the allocated memory by atleast 10-20% anyway If you're using a VPS provider that allows you to go over your set RAM limit, I would stay far far away from them.
|
|
|
|
PatMan
|
|
June 20, 2014, 04:10:29 PM |
|
I was merge mining BTC, NMC, FSC, DVC, I0C, IXC, GRP & HUC using 16GB RAM on a unlocked & OC'd 65W Phenom Quad-core quite comfortably with a constant 0.2 sec bitcoind latency. I say "was" because I have recently sold my last remaining p2pool compatible hardware (S1's) due to the cost of electricity here in the UK making them non profitable at the current BTC rate. All my remaining hardware - S2's, Dragons etc don't work with p2pool - so I am now forced to ditch running my node after nearly 3 years of p2pool mining....... Sad days indeed I suggest inserting "--give-author 0" into the code on this guide, as it is because of the lack of development that I am forced to quit mining with p2pool after all this time. Unless Kano can work his magic, or something remarkable happens to the p2pool code, it's not looking like I or many others will be able to get back to supporting & mining with p2pool. Peace.
|
|
|
|
KyrosKrane
|
|
June 20, 2014, 06:46:39 PM |
|
Caught another error. In the section for creating start-p2pool, you have this: cat >~/start-p2pool /usr/bin/bitcoind /home/mine/bin/ixcoind /home/mine/bin/namecoind /home/mine/bin/devcoind
You should change the paths from /home/mine to ~. Also you should add -daemon after each one; otherwise the process will terminate as soon as you log out of that machine. Finally, you forgot to start i0coin. So, something like this: /usr/bin/bitcoind -daemon ~/bin/namecoind -daemon ~/bin/ixcoind -daemon ~/bin/devcoind -daemon ~/bin/i0coind -daemon ~/bin/fusioncoind -daemon # only if you enabled that too
|
|
|
|
KyrosKrane
|
|
June 20, 2014, 07:04:52 PM |
|
Also just noticed you added a section on the firewall. Two things there. 1) You never actually install ufw. You have to add it to the apt-get line. 2) You don't open ports for any of the alt-coins. They won't connect to peers if you don't do that. Here's the revised list. # Set up and configure a firewall # Note that we do NOT enable the RPC port for any coins! sudo ufw default deny # Deny everything unless expressly permitted sudo ufw allow 22/tcp # SSH sudo ufw allow 8333/tcp # bitcoin peer to peer sudo ufw allow 8334/tcp # namecoin peer to peer sudo ufw allow 8337/tcp # ixcoin peer to peer sudo ufw allow 6334/tcp # devcoin peer to peer sudo ufw allow 7337/tcp # i0coin peer to peer sudo ufw allow 8492/tcp # fusioncoin peer to peer sudo ufw allow 9333/tcp # P2pool peer to peer sudo ufw allow 9332/tcp # P2Pool connections and Web interface sudo ufw --force enable # Turn it on
That said, you might want to consider sticking all that in a shell script and calling that with sudo, rather than using sudo on each individual command.
|
|
|
|
murdof (OP)
|
|
June 21, 2014, 09:31:47 AM |
|
Hey KyrosKrane, i integrated your suggestions. About daemon i don't think it is needed cause i declare it in the config files. I've been using it like that and of course i'm not logged in all day long Thanks for the feedback - keep it coming. Also about the rpcpasswords since this is something that is used only locally i don't think it really matters. But on the other hands everyone can just edit the password and set up their own. So I don't know if it is worth it to add randomized passwords.
|
|
|
|
zvs
Legendary
Offline
Activity: 1680
Merit: 1000
https://web.archive.org/web/*/nogleg.com
|
|
June 21, 2014, 11:20:33 AM |
|
You could run it on a VPS w/ 2 GB of (dedicated, not shared) RAM, but I suspect you'd have to edit the source to block all transactions, or set the correct variables (limitfreerelay in bitcoin?).... limitfreerelay I believe is what would stop the transactions from even entering memory, unlike maxblocksize.
|
|
|
|
KyrosKrane
|
|
June 21, 2014, 12:08:25 PM |
|
The huntercoin bug appears to be fixed in git. I cloned the repository, and the missing include file is now in there.
|
|
|
|
Stery
Member
Offline
Activity: 118
Merit: 100
|
|
June 21, 2014, 12:15:01 PM |
|
Do you need miners to run this ?
|
|
|
|
murdof (OP)
|
|
June 21, 2014, 12:16:41 PM |
|
The huntercoin bug appears to be fixed in git. I cloned the repository, and the missing include file is now in there.
Year already have updated binaries and included the guise how to compile it.
|
|
|
|
KyrosKrane
|
|
June 21, 2014, 12:38:41 PM Last edit: June 21, 2014, 04:46:04 PM by KyrosKrane |
|
And behold! The entire guide, compressed into one install script. Murdof, this basically replaces your download script. It doesn't need sudo to run; instead, it handles the sudo requirement inside the script itself, and only for the system update portion. I also put all the source code downloads for the various daemons into a subdirectory, so they don't clutter the user's home dir. You can also update your .gz file to only include the compiled binaries. The "batch files" and config files are created by this script; they'll overwrite what's in your archive. It's self-documenting, and fairly clear. I've been using it over and over on a VM I made, to test different configurations, and I can't find any bugs. #!/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 }
# 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
# Create a script to update the system. This requires sudo, so we can't run it directly.
cat <<EOF >~/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 # 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 3 # pause so the user has a chance to see and read the message. sudo sh ~/sudoscript.sh rm ~/sudoscript.sh
# Install p2pool git clone git://github.com/forrestv/p2pool.git
# Now either download or compile the binaries. if [ "$Method" = "download" ] ; then # Download and unpack scripts and binaries for other coins 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 # Make the local binaries directory mkdir -p ~/bin
# Make a directory to download and store all the alt-coin sources mkdir -p ~/coin_source
# Download and compile Namecoin. cd ~/coin_source git clone https://github.com/namecoin/namecoin cd ~/coin_source/namecoin/src make -f Makefile if [ -f namecoind ] ; then Status="$Status\nNamecoin compilation succeeded." strip namecoind cp namecoind ~/bin else Status="$Status\nNamecoin compilation FAILED." fi
# Download and compile iXcoin. cd ~/coin_source git clone https://github.com/FrictionlessCoin/iXcoin cd ~/coin_source/iXcoin/src make -f makefile.unix if [ -f ixcoind ] ; then Status="$Status\nIxcoin compilation succeeded." strip ixcoind cp ixcoind ~/bin else Status="$Status\nIxcoin compilation FAILED." fi
# Download and compile Devcoin. cd ~/coin_source git clone git://gitorious.org/devcoin/devcoin.git cd ~/coin_source/devcoin/src make -f makefile.unix USE_PNP=1 devcoind if [ -f devcoind ] ; then Status="$Status\nDevcoin compilation succeeded." strip devcoind cp devcoind ~/bin else Status="$Status\nDevcoin compilation FAILED." fi
# Download and compile i0coin. cd ~/coin_source git clone http://github.com/rsnel/i0coin/ cd ~/coin_source/i0coin/src make -f makefile.unix i0coind if [ -f i0coind ] ; then Status="$Status\ni0coin compilation succeeded." strip i0coind cp i0coind ~/bin else Status="$Status\ni0coin compilation FAILED." fi
# Download and compile Fusioncoin. cd ~/coin_source git clone https://github.com/fusioncoin/fusioncoin cd ~/coin_source/fusioncoin/src make -f makefile.unix if [ -f fusioncoind ] ; then Status="$Status\nFusioncoin compilation succeeded." strip fusioncoind cp fusioncoind ~/bin else Status="$Status\nFusioncoin compilation FAILED." fi
# Download and compile Huntercoin. cd ~/coin_source git clone https://github.com/chronokings/huntercoin cd ~/coin_source/huntercoin/src make -f Makefile if [ -f huntercoind ] ; then Status="$Status\nHuntercoin compilation succeeded." strip huntercoind cp huntercoind ~/bin else Status="$Status\nHuntercoin compilation FAILED." fi
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
# Make directories for everything mkdir -p ~/.bitcoin mkdir -p ~/.namecoin mkdir -p ~/.ixcoin mkdir -p ~/.devcoin mkdir -p ~/.i0coin mkdir -p ~/.fusioncoin mkdir -p ~/.huntercoin
# Set up the various RPC usernames and passwords. Note that you never need to remember these; they just have to exist and be unguessable. Bitcoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Bitcoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
Namecoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Namecoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
Ixcoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Ixcoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
Devcoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Devcoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
i0coin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` i0coin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
Fusioncoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Fusioncoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
Huntercoin_User=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40` Huntercoin_Password=`< /dev/urandom tr -dc A-Za-z0-9 | head -c40`
# Create the various configuration files cat >~/.bitcoin/bitcoin.conf <<EOF server=1 daemon=1 rpcuser=$Bitcoin_User rpcpassword=$Bitcoin_Password rpcallowip=127.0.0.1
EOF
cat >~/.namecoin/namecoin.conf <<EOF server=1 daemon=1 rpcuser=$Namecoin_User rpcpassword=$Namecoin_Password port=8334 rpcport=7333 rpcallowip=127.0.0.1
EOF
cat >~/.ixcoin/ixcoin.conf <<EOF server=1 daemon=1 rpcuser=$Ixcoin_User rpcpassword=$Ixcoin_Password port=8337 rpcport=8338 rpcallowip=127.0.0.1
EOF
cat >~/.devcoin/devcoin.conf <<EOF server=1 daemon=1 rpcuser=$Devcoin_User rpcpassword=$Devcoin_Password rpcport=6333 port=6334 rpcallowip=127.0.0.1
EOF
cat >~/.i0coin/i0coin.conf <<EOF server=1 daemon=1 rpcuser=$i0coin_User rpcpassword=$i0coin_Password port=7337 rpcport=7338 rpcallowip=127.0.0.1
EOF
cat >~/.fusioncoin/fusioncoin.conf <<EOF server=1 daemon=1 rpcuser=$Fusioncoin_User rpcpassword=$Fusioncoin_Password port=8492 rpcport=18491 rpcallowip=127.0.0.1
EOF
cat >~/.huntercoin/huntercoin.conf <<EOF server=1 daemon=1 rpcuser=$Huntercoin_User rpcpassword=$Huntercoin_Password port=8398 rpcport=8399 rpcallowip=127.0.0.1
EOF
# Create the startup script for all coins and p2pool. cat >~/start-p2pool <<EOF #!/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 $Bitcoin_User $Bitcoin_Password \ --merged http://$Namecoin_User:$Namecoin_Password@127.0.0.1:7333 \ --merged http://$Ixcoin_User:$Ixcoin_Password@127.0.0.1:8338 \ --merged http://$Devcoin_User:$Devcoin_Password@127.0.0.1:6333 \ --merged http://$i0coin_User:$i0coin_Password@127.0.0.1:7338 \ --merged http://$Fusioncoin_User:$Fusioncoin_Password@127.0.0.1:18491 \ --merged http://$Huntercoin_User:$Huntercoin_Password@127.0.0.1:8399
EOF chmod 755 ~/start-p2pool
# Create a script to list the value of all coin wallets. cat >~/listallcoins <<EOF #!/bin/sh echo "BTC: \$(/usr/bin/bitcoind -rpcpassword=$Bitcoin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "NMC: \$(~/bin/namecoind -rpcpassword=$Namecoin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "IXC: \$(~/bin/ixcoind -rpcpassword=$Ixcoin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "DVC: \$(~/bin/devcoind -rpcpassword=$Devcoin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "I0C: \$(~/bin/i0coind -rpcpassword=$i0coin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "FSC: \$(~/bin/fusioncoind -rpcpassword=$Fusioncoin_Password listaccounts | awk '{getline; print \$NF;exit;}')" echo "Huntercoin: \$(~/bin/huntercoind -rpcpassword=$Huntercoin_Password listaccounts | awk '{getline; print \$NF;exit;}')"
EOF chmod 755 ~/listallcoins
# 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; 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: This script also removes the need for the chmod commands you added to the lazy install. Edit 2: I've been testing this with Ubuntu 14.04 desktop, so yup, it does work with that. It should be identical on a server install, too.
|
|
|
|
murdof (OP)
|
|
June 21, 2014, 12:50:54 PM |
|
Great stuff Kyros!
Will update the guide with your script sometime tomorrow!
Thanks for all your feedback.
|
|
|
|
KyrosKrane
|
|
June 21, 2014, 04:48:02 PM |
|
*sigh* I'm really starting to get irritated at the taste of humble pie ... fixed some display bugs in the script's output. New code in my post above.
Also, I just realized I can make this script work for updates, not just the initial installation. That is, if you run it a second time, it will just download and process updates, instead of resetting everything. I'll start working on that too.
|
|
|
|
KyrosKrane
|
|
June 22, 2014, 09:15:26 PM Last edit: June 23, 2014, 05:41:57 AM by KyrosKrane |
|
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. #!/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 <<EOF >~/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 <<EOF #!/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 <<EOF #!/bin/sh echo "BTC: \$(/usr/bin/bitcoind -rpcpassword=${CoinPassword[bitcoin]} listaccounts | awk '{getline; print \$NF;exit;}')" EOF
for Coin in $CompileCoins do cat >>~/listallcoins <<EOF 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.
|
|
|
|
murdof (OP)
|
|
June 23, 2014, 08:16:53 AM |
|
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?
|
|
|
|
KyrosKrane
|
|
June 24, 2014, 05:51:03 AM |
|
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.
|
|
|
|
Operatr
|
|
June 24, 2014, 04:43:13 PM |
|
Excellent guide, thank you! After going through so many others this is by far the most complete.
|
|
|
|
iglasses
Legendary
Offline
Activity: 1148
Merit: 1000
|
|
June 25, 2014, 02:12:53 AM |
|
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
|
I only have a signature because I'm allowed.
|
|
|
coinme.info
|
|
June 26, 2014, 06:33:14 AM Last edit: July 31, 2014, 08:25:51 AM by coinme.info |
|
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.shsudo 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!
|
|
|
|
|