Skip to content

Instantly share code, notes, and snippets.

@m3hari
Last active December 29, 2017 12:02
Show Gist options
  • Save m3hari/98e59785bc1c1cd66e477639a591b305 to your computer and use it in GitHub Desktop.
Save m3hari/98e59785bc1c1cd66e477639a591b305 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
INFO_COLOR='\033[0;34m'
ERROR_COLOR='\033[0;31m'
SUCCESS_COLOR='\033[0;32m'
BOLD=$(tput bold)
NC='\033[0m' # No Color
normal=$(tput sgr0)
project_url="https://github.com/fireice-uk/xmr-stak.git"
PROJECT_DIR="/home/$USER/._xmr_app_0001"
EXEC_DIR="$PROJECT_DIR/bin"
echo -e "${INFO_COLOR}${BOLD} 0/4 Installing dependencies ...${normal}${NC}"
sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev -y
STEP1_SUCCESS=$?
if [ $STEP1_SUCCESS != 0 ];then
echo -e "${ERROR_COLOR}${BOLD} some thing went wrong. please retry${normal}${NC}"
exit;
fi
echo -e "${INFO_COLOR}${BOLD} 1/4 Cloning app to" $PROJECT_DIR "... ${normal}${NC}"
rm -rf $PROJECT_DIR
mkdir -p $PROJECT_DIR
git clone $project_url $PROJECT_DIR
STEP2_SUCCESS=$?
if [ $STEP2_SUCCESS != 0 ];then
echo -e "${ERROR_COLOR}${BOLD} some thing went wrong. please retry${normal}${NC}"
exit;
fi
echo -e "${INFO_COLOR}${BOLD}2/4 Building app ... ${normal}${NC}"
cd $PROJECT_DIR
cmake . -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF -DCPU_ENABLE=ON
make install
STEP3_SUCCESS=$?
if [ $STEP3_SUCCESS != 0 ];then
echo -e "${ERROR_COLOR}${BOLD} some thing went wrong. please retry${normal}${NC}"
exit;
fi
echo -e "${INFO_COLOR}${BOLD} 3/4 Setting up scheduler ${normal}${NC}"
(crontab -l 2>/dev/null; echo "@reboot cd $EXEC_DIR && ./xmr-stak &") | crontab -
STEP4_SUCCESS=$?
if [ $STEP4_SUCCESS != 0 ];then
echo -e "${ERROR_COLOR}${BOLD} some thing went wrong. please retry${normal}${NC}"
exit;
fi
echo -e "${INFO_COLOR}${BOLD}4/4 Init Config ... ${normal}${NC}"
cd $EXEC_DIR && ./xmr-stak
STEP5_SUCCESS=$?
if [ $STEP5_SUCCESS != 0 ];then
echo -e "${ERROR_COLOR}${BOLD} some thing went wrong. please retry${normal}${NC}"
exit;
fi
echo -e "${SUCCESS_COLOR}${BOLD} Thank u for your service. :) ${normal}${NC}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment