#!/bin/bash
Set the miner settings
POOL_URL="pool_url"
WALLET_ADDRESS="wallet_address"
Install dependencies
sudo apt-get update
sudo apt-get install -y opencl-headers ocl-icd-libopencl1 opencl-clhpp-headers
clinfo ocl-icd-opencl-dev
Clone and build the cgminer software
git clone https://github.com/ckolivas/cgminer.git
cd cgminer
./autogen.sh
./configure --enable-opencl
make
Get the maximum values for thread-concurrency, shaders, and worksize
MAX_THREAD_CONCURRENCY=$(clinfo | grep "Max compute units" | awk '{print $4}')
MAX_SHADERS=$(clinfo | grep "Max compute units" | awk '{print $4}')
MAX_WORKSIZE=$(clinfo | grep "Max work group size" | awk '{print $5}')
Create a config file with all desired settings
echo "scrypt
url=$POOL_URL
user=$WALLET_ADDRESS
pass=x
no-submit-stale
coinbase-addr=$WALLET_ADDRESS
fee=0
expiry=60
intensity=31
worksize=$MAX_WORKSIZE
thread-concurrency=$MAX_THREAD_CONCURRENCY
shaders=$MAX_SHADERS" > ~/.cgminer/cgminer.conf
Run the GPU miner in the background with the specified config file
nohup ./cgminer --config ~/.cgminer/cgminer.conf &
Create a system service to run the mining script on startup
echo "[Unit]
Description=Mining Service
[Service]
Type=simple
ExecStart=$(pwd)/start-mining.sh
[Install]
WantedBy=default.target" | sudo tee /etc/systemd/system/mining.service
Enable the mining service
sudo systemctl enable mining.service