Last active
May 4, 2019 12:10
-
-
Save daxxog/8389a1540bb3b69366a892d0a4613257 to your computer and use it in GitHub Desktop.
Install clamd on the Raspberry PI 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# clampi.sh | |
# CLAM easy install script for Raspberry PI | |
# curl -L https://gist.githubusercontent.com/daxxog/8389a1540bb3b69366a892d0a4613257/raw/clam-install-pi.sh | sh | |
# Copyright (c) 2014-2018 The CLAM developers | |
#setup dev working directory | |
cd ~ | |
mkdir dev | |
cd dev | |
#download clam source and build prerequisites | |
curl -L https://github.com/nochowderforyou/clams/archive/v1.4.17.tar.gz | tar xvz | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get remove -y openssl | |
sudo apt-get install -y build-essential libtool autotools-dev autoconf pkg-config libboost-all-dev db4.8-util libssl1.0-dev libminiupnpc-dev | |
cd clams-1.4.17/ | |
#--> | |
#copy pasted from -> https://github.com/nochowderforyou/clams/blob/master/doc/build-unix.md | |
#modded by daXXog | |
#------------------------------------------------------------------------------------------ | |
CLAM_ROOT=$(pwd) | |
#go back to clam-root | |
cd ${CLAM_ROOT} | |
#patch chainparams.cpp -dXg | |
cp "${CLAM_ROOT}/src/chainparams.cpp.bak" "${CLAM_ROOT}/src/chainparams.cpp" | |
cp "${CLAM_ROOT}/src/chainparams.cpp" "${CLAM_ROOT}/src/chainparams.cpp.bak" | |
curl -L https://gist.githubusercontent.com/daxxog/ec49ac381c22ed1c60a579a13d44d1aa/raw/44f93da0698a023fa396f9b4d76e210dd9304f80/chainparams.cpp.patch | patch "${CLAM_ROOT}/src/chainparams.cpp" | |
#patch system swapfile from 100 to 1024 -dXg | |
cd ~ | |
echo "cat $(pwd)/.dphys-swapfile.bak > /etc/dphys-swapfile" > ~/.restore.dphys-swapfile.sh | |
chmod +x ~/.restore.dphys-swapfile.sh | |
sudo ~/.restore.dphys-swapfile.sh | |
cat /etc/dphys-swapfile > ~/.dphys-swapfile.bak | |
curl -L https://gist.githubusercontent.com/daxxog/3b5f9dd13b174b440102a6ea93f00edf/raw/272246cbc706ac0e5ce08548df14d8d7d69622a4/swap.patch | sudo patch /etc/dphys-swapfile | |
cat /etc/dphys-swapfile | |
sudo /etc/init.d/dphys-swapfile restart | |
#BDB4.8.30.NC | |
cd $CLAM_ROOT | |
# Pick some path to install BDB to, here we create a directory within the clam directory | |
BDB_PREFIX="${CLAM_ROOT}/db4" | |
mkdir -p $BDB_PREFIX | |
# just Fetch the source | |
curl -L http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz | tar xvz | |
# Build the library and install to our prefix | |
cd db-4.8.30.NC/build_unix/ | |
# Note: Do a static build so that it can be embedded into the exectuable, instead of having to find a .so at runtime | |
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX | |
make -j3 | |
make install | |
# Configure Clam Core to use our own-built instance of BDB & SSL | |
cd $CLAM_ROOT | |
./autogen.sh | |
./configure --enable-upnp-default LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" | |
#------------------------------------------------------------------------------------------ | |
#copy pasted from -> https://github.com/nochowderforyou/clams/blob/master/doc/build-unix.md | |
#modded by daXXog | |
#<-- | |
#build and install | |
make -j2 | |
sudo make install | |
#setup config | |
#backup any clam data dirs | |
mv ~/.clam ~/.clam-backup-$(date +%s) | |
clamd | |
cd ~/.clam/ | |
CLAM_DATA_DIR=$(pwd) | |
cd ~ | |
USER_HOME_DIR=$(pwd) | |
#install rtorrent | |
curl -L https://s3.amazonaws.com/dooglus/bootstrap.dat?torrent > ${CLAM_DATA_DIR}/bootstrap.torrent | |
sudo apt-get install -y rtorrent tmux | |
#config rtorrent | |
rm -rf ~/.rtsession | |
mkdir ~/.rtsession | |
echo "directory = ${CLAM_DATA_DIR}" > ~/.rtorrent.rc | |
echo "session = ${USER_HOME_DIR}/.rtsession" >> ~/.rtorrent.rc | |
echo "schedule = watch_directory_1,10,10,\"load_start=${CLAM_DATA_DIR}/*.torrent,d.set_directory=${CLAM_DATA_DIR}/\"" >> ~/.rtorrent.rc | |
echo "system.method.set_key = event.download.finished,clam_touchdown,\"execute=touch,${CLAM_DATA_DIR}/touched\"" >> ~/.rtorrent.rc | |
echo "port_random = yes" >> ~/.rtorrent.rc | |
echo "check_hash = yes" >> ~/.rtorrent.rc | |
echo "dht = auto" >> ~/.rtorrent.rc | |
echo "dht_port = 6881" >> ~/.rtorrent.rc | |
echo "peer_exchange = yes" >> ~/.rtorrent.rc | |
#download the bootstrap.dat file | |
tmux new-session -s rtorrent -d rtorrent | |
echo downloading bootstrap.dat .. | |
echo via https://s3.amazonaws.com/dooglus/bootstrap.dat?torrent | |
while [ ! -f ${CLAM_DATA_DIR}/touched ]; do sleep 10; done | |
echo bootstrap.dat download complete | |
#generate rpc password | |
echo generating secure password .. | |
CLAM_RPC_PASS=$(curl -L https://gist.githubusercontent.com/daxxog/adaf9b38ecc4a82ce3ee846f5632801b/raw/randompass.sh | bash) | |
#setup rpc | |
echo "rpcuser=clamrpc" > ${CLAM_DATA_DIR}/clam.conf | |
echo "rpcpassword=${CLAM_RPC_PASS}" >> ${CLAM_DATA_DIR}/clam.conf | |
#provide more useful logs | |
echo "logtimestamps=1" >> ${CLAM_DATA_DIR}/clam.conf | |
#help combat blockchain spam attack | |
echo "mininput=0.01" >> ${CLAM_DATA_DIR}/clam.conf | |
#setup good settings for staking | |
echo "combineany=1" >> ${CLAM_DATA_DIR}/clam.conf | |
echo "splitsize=45" >> ${CLAM_DATA_DIR}/clam.conf | |
#let the user know what the settings are | |
echo "${CLAM_DATA_DIR}/clam.conf" | |
cat ${CLAM_DATA_DIR}/clam.conf | |
#daemonize clam and run clam on startup | |
sudo touch /etc/init.d/clamd | |
curl -L https://gist.githubusercontent.com/daxxog/33cf309fec8c586cc66195b85509ca7d/raw/clamd-p1.sh > ~/._tmpclamd | |
echo "sudo -u ${USER} nohup clamd >> /dev/null &" >> ~/._tmpclamd | |
curl -L https://gist.githubusercontent.com/daxxog/eb206c3ec6f53c5226f65f4f612ec62d/raw/clamd-p2.sh >> ~/._tmpclamd | |
sudo chown root ~/._tmpclamd | |
sudo mv ${USER_HOME_DIR}/._tmpclamd /etc/init.d/clamd | |
sudo chmod 755 /etc/init.d/clamd | |
sudo update-rc.d clamd defaults | |
cat /etc/init.d/clamd | |
#start the clam client | |
sudo /etc/init.d/clamd start | |
echo install finished! | |
echo clam is running, to view logs type: | |
echo tail -f ${CLAM_DATA_DIR}/debug.log | |
echo you can now reboot the system with | |
echo sudo reboot | |
echo clamd will now start at bootup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment