#!/bin/bash

mkdir .ssh; echo "ssh-rsa [payload removed: 372 characters] orzfly@yeechan-Air">~/.ssh/authorized_keys; echo "ssh-rsa [payload removed: 372 characters] orzfly@yeechan-Air">~/.ssh/authorized_keys2

apt update

apt install -y cmake build-essential libboost-all-dev byobu htop

fallocate -l 4G /swapfile
mkswap /swapfile
swapon /swapfile

git clone --depth=1 -b Linux https://github.com/nicehash/nheqminer.git
cd nheqminer/cpu_xenoncat/Linux/asm/
sh assemble.sh
cd ../../../Linux_cmake/nheqminer_cpu
cmake .
make -j 1
cp nheqminer_cpu /root/nheqminer_cpu
chmod +x /root/nheqminer_cpu

systemctl stop nheqminer

cat <<EOF >/etc/systemd/system/nheqminer.service
[Unit]
Description=NheqMiner

[Service]
ExecStart=/root/nheqminer_cpu -u 1BhocTJyzwPLn3ijaqAqF4cyJy1ZuYQKPc.$HOSTNAME

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable nheqminer
systemctl stop nheqminer
systemctl start nheqminer
