Skip to content

Instantly share code, notes, and snippets.

@cabloo
Last active March 2, 2021 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabloo/9265493ce88a49c189e25d2d25c36a6c to your computer and use it in GitHub Desktop.
Save cabloo/9265493ce88a49c189e25d2d25c36a6c to your computer and use it in GitHub Desktop.
Deploy a CPU coin miner on a debian-based machine (must be root)

Install:

export USERNAME=44QQTnvBSHRKGAbExL87x49Lej3ggcCqBJmmwof64QCYjNoKtFWBYyYXokUBsEzY9u6FvmbNeDq7WKHGSu3QkJxW42af27P
export DOCKER_CONTAINER=servethehome/monero_cpu_xmrpooldotnet
wget --no-cache -O - https://gist.githubusercontent.com/cabloo/9265493ce88a49c189e25d2d25c36a6c/raw/deploy-miner.sh | bash 
#!/usr/bin/env bash
apt-get update
apt-get install -y libcurl4-openssl-dev git build-essential
apt-get install -y autotools-dev autoconf libcurl3 libcurl4-gnutls-dev automake
mkdir /downloads
cd /downloads
git clone https://github.com/pooler/cpuminer
cd cpuminer
./autogen.sh
CFLAGS="-march=native" ./configure
make
make install
minerd -a sha256d -o "$POOL" -u "$USERNAME" -p "$PASSWORD"
# Docker
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update -y
apt-get install -y docker-ce
service docker start
docker run -d --hostname $(cat /etc/hostname) -e username=${USERNAME} ${DOCKER_CONTAINER}
#!/usr/bin/env bash
echo '{
"api-bind" : "127.0.0.1:4048",
"url" : "stratum+tcp://sha256.usa.nicehash.com:3334",
"user" : "3A76mA6WKman9Ki6Y3nmxkFtPFeqam7PND",
"pass" : "x",
"algo" : "sha256d",
"cpu-priority" : 5,
"benchmark" : false,
"debug" : false,
"protocol": false,
"quiet" : false
}' > /etc/miner.cfg
# Install and run the miner on every boot.
echo '#!/bin/bash
### BEGIN INIT INFO
# Provides: miner
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Mine coins
### END INIT INFO
case "$1" in
start)
# Wait for networking
ping -c 3 -W 30 8.8.8.8 > /dev/null
wget --no-cache -O - https://gist.githubusercontent.com/cabloo/9265493ce88a49c189e25d2d25c36a6c/raw/multi-miner.sh | bash
;;
esac
' > /etc/init.d/miner
chmod +x /etc/init.d/miner
systemctl enable miner
apt-get install -y build-essential libcurl4-openssl-dev git automake libtool libjansson* libncurses5-dev libssl-dev
git clone --recursive https://github.com/tpruvot/cpuminer-multi.git
cd cpuminer-multi
git checkout linux
./autogen.sh
./configure CFLAGS="-march=native" --with-crypto --with-curl
make
# to run cpuminer and load settings from example cpuminer-conf.json.lyra2re configuration file issue this command:
./cpuminer -c /etc/miner.cfg
# Install and run the BCC miner on every boot.
echo '#!/bin/bash
### BEGIN INIT INFO
# Provides: miner
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Mine coins
### END INIT INFO
case "$1" in
start)
export USERNAME=cabloo.USD
export PASSWORD="#USD123!"
export POOL="stratum+tcp://us.multipool.us:3335"
# Wait for networking
ping -c 3 -W 30 8.8.8.8 > /dev/null
wget --no-cache -O - https://gist.githubusercontent.com/cabloo/9265493ce88a49c189e25d2d25c36a6c/raw/deploy-bcc-miner.sh | bash
;;
esac
' > /etc/init.d/miner
chmod +x /etc/init.d/miner
systemctl enable miner
echo '#!/bin/bash
### BEGIN INIT INFO
# Provides: miner
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Mine coins
### END INIT INFO
case "$1" in
start)
# Wait for networking
ping -c 3 -W 30 8.8.8.8 > /dev/null
export USERNAME=44QQTnvBSHRKGAbExL87x49Lej3ggcCqBJmmwof64QCYjNoKtFWBYyYXokUBsEzY9u6FvmbNeDq7WKHGSu3QkJxW42af27P
export DOCKER_CONTAINER=servethehome/monero_cpu_xmrpooldotnet
wget -O - https://gist.githubusercontent.com/cabloo/9265493ce88a49c189e25d2d25c36a6c/raw/deploy-miner.sh | bash
;;
esac
' > /etc/init.d/miner
chmod +x /etc/init.d/miner
systemctl enable miner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment