Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Switch to root
- sudo passwd pi
- sudo passwd root
- sudo su -
- #Enable testing updates
- nano /etc/apt/sources.list
- deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi
- nano /etc/apt/sources.list.d/raspi.list
- no change (testing not available here, nor stable, only wheezy)
- #Update the system
- aptitude update
- aptitude dist-upgrade
- #Enable automatic (security) upgrades
- aptitude install unattended-upgrades apticron
- nano /etc/apt/apt.conf.d/50unattended-upgrades
- #Security updates are enabled by default, feel free to accept more
- nano /etc/apt/apt.conf.d/02periodic (new file)
- // Enable the update/upgrade script (0=disable)
- APT::Periodic::Enable "1";
- // Do "apt-get update" automatically every n-days (0=disable)
- APT::Periodic::Update-Package-Lists "1";
- // Do "apt-get upgrade --download-only" every n-days (0=disable)
- APT::Periodic::Download-Upgradeable-Packages "1";
- // Run the "unattended-upgrade" security upgrade script
- // every n-days (0=disabled)
- // Requires the package "unattended-upgrades" and will write
- // a log in /var/log/unattended-upgrades
- APT::Periodic::Unattended-Upgrade "1";
- // Do "apt-get autoclean" every n-days (0=disable)
- APT::Periodic::AutocleanInterval "7";
- nano /etc/apticron/apticron.conf
- #FSCK repair when HD have inconistencies
- nano /etc/default/rcS
- FSCKFIX=yes
- #Let's configure the system for cgminer
- groupadd btc
- useradd -g btc btc
- usermod -a -G dialout btc
- passwd btc
- groups btc
- mkdir /home/btc/
- echo '#!/bin/sh
- cgminer -c /home/btc/cgminer.conf -S auto
- sleep 300'> /home/btc/cgminer.sh
- echo '#!/bin/sh
- screen -dmS cgminer /home/btc/cgminer.sh' > /home/btc/cgminer-screen.sh
- echo '#!/bin/sh
- su btc -c /home/btc/cgminer-screen.sh' > /home/btc/cgminer-screen-as-btc.sh
- echo '#!/bin/sh
- echo "Press CTRL+A then D to leave cgminer running"
- echo "Run ls -laR /var/run/screen/S-btc to see all running screens for user btc"
- sleep 2
- screen -r btc/cgminer' > /home/btc/view-cgminer-screen.sh
- echo 'if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi' > /home/btc/.bash_profile
- echo '~/view-cgminer-screen.sh' > /home/btc/.bashrc
- echo 'multiuser on
- acladd root
- acladd pi' > /home/btc/.screenrc
- ln -s /home/btc/cgminer.sh /root/cgminer.sh
- ln -s /home/btc/cgminer.sh /home/pi/cgminer.sh
- ln -s /home/btc/cgminer-screen.sh /root/cgminer-screen.sh
- ln -s /home/btc/cgminer-screen.sh /home/pi/cgminer-screen.sh
- ln -s /home/btc/cgminer-screen-as-btc.sh /root/cgminer-screen-as-btc.sh
- ln -s /home/btc/cgminer-screen-as-btc.sh /home/pi/cgminer-screen-as-btc.sh
- ln -s /home/btc/view-cgminer-screen.sh /root/view-cgminer-screen.sh
- ln -s /home/btc/view-cgminer-screen.sh /home/pi/view-cgminer-screen.sh
- ln -s /home/btc/cgminer.conf /root/cgminer.conf
- ln -s /home/btc/cgminer.conf /home/pi/cgminer.conf
- chmod +x /home/btc/*.sh
- chmod +x /root/*.sh
- chmod +x /home/pi/*.sh
- chown -R pi:pi /home/pi/
- chown -R btc:btc /home/btc/
- #Install things :) Some are required by cgminer to compile, others will be used later
- aptitude install fail2ban autoconf libtool libncurses-dev yasm curl libcurl4-openssl-dev pkg-config git screen mailx watchdog chkconfig libusb-1.0-0-dev
- #Update RPI firmware (needs git, that's why we didn't did it before)
- wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update
- rpi-update
- #Retrieve and install cgminer
- cd /root
- git clone https://github.com/ckolivas/cgminer.git cgminer
- cd cgminer
- aclocal
- ./autogen.sh
- export LIBCURL_CFLAGS='-I/usr/include/curl'
- export LIBCURL_LIBS='-L/usr/lib -lcurl'
- ./configure --enable-bitforce --enable-icarus --enable-modminer --enable-ztex
- make
- make install
- #Watch dog the system
- #Enable automatic hard reboot in case of system freeze: use the hardware Raspberry Watchdog
- #Load watchdog drivers:
- modprobe bcm2708_wdog
- nano /etc/modules
- bcm2708_wdog
- #Software watchdog, that will also feed the hardware watchdog
- nano /etc/watchdog.conf
- #ping = 8.8.8.8 #doesn't work, make the system to reboot continuously
- watchdog-device = /dev/watchdog
- max-load-15 = 18
- chkconfig watchdog on
- /etc/init.d/watchdog start
- #Cron job that will ensure cgminer is always running and will restart it if not
- echo '#!/bin/bash
- #
- # watchdog
- #
- # Run as a cron job to keep an eye on what_to_monitor which should always
- # be running. Restart what_to_monitor and send notification as needed.
- #
- # This needs to be run as root or a user that can start system services.
- #
- # Revisions: 0.1 (20100506), 0.2 (20100507)
- NAME=cgminer.sh
- START=/home/btc/cgminer-screen-as-btc.sh
- #NOTIFY=person1email
- #NOTIFYCC=person2email
- GREP=/bin/grep
- PS=/bin/ps
- NOP=/bin/true
- DATE=/bin/date
- #MAIL=/usr/bin/mail
- #RM=/bin/rm
- $PS -ef|$GREP -v grep|$GREP $NAME >/dev/null 2>&1
- case "$?" in
- 0)
- # It is running in this case so we do nothing.
- echo "$NAME is running, nothing to do"
- $NOP
- ;;
- 1)
- echo "$NAME is NOT RUNNING. Starting $NAME and sending notices."
- $START 2>&1 >/dev/null &
- NOTICE=/tmp/cgminer-watchdog.log
- echo "$NAME was not running and was started on `$DATE`" >> $NOTICE
- #$MAIL -n -s "watchdog notice" -c $NOTIFYCC $NOTIFY < $NOTICE
- #$RM -f $NOTICE
- ;;
- esac
- exit' > /root/cgminer-watchdog.sh
- chmod +x /root/cgminer-watchdog.sh
- crontab -e
- * * * * * /root/cgminer-watchdog.sh
- #Enable cgminer to start with system
- #Let the watchdog start it, to prevent multiple executions
- nano /etc/rc.local
- sleep 10
- /root/cgminer-watchdog.sh
- #Update script that will upgrade cgminer. It won't run automatically, so run it when you want to upgrade your cgminer
- echo '#!/bin/sh
- aptitude update
- #/usr/bin/rpi-update
- cd /root/cgminer
- git remote update
- git pull
- aclocal
- ./autogen.sh
- export LIBCURL_CFLAGS="-I/usr/include/curl"
- export LIBCURL_LIBS="-L/usr/lib -lcurl"
- ./configure --enable-bitforce --enable-icarus --enable-modminer --enable-ztex
- make
- make install' > /root/Update.sh
- chmod +x /root/Update.sh
- #Check BFL boxes are recognized:
- ls -l /dev/ttyUSB*
- #Make the image public compatible, clean some things
- passwd
- passwd pi
- passwd btc
- echo '{
- "pools": [
- {
- "url": "http://eu.ozco.in:8332",
- "user": "crazydownloaded.raspi",
- "pass": "x"
- },
- {
- "url": "http://mining.bitcoin.cz:8332",
- "user": "crazydownloaded.raspi",
- "pass": "x"
- },
- {
- "url": "http://mergedmining.btcguild.com:8332",
- "user": "crazydownloaded_raspi",
- "pass": "x"
- }
- ],
- "donation": "false"
- }' > /home/btc/cgminer.conf
- echo 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
- update_config=1' > /etc/wpa_supplicant/wpa_supplicant.conf
- rm /home/btc/.bash_history
- rm /home/pi/.bash_history
- rm /root/.bash_history
- rm -rf /home/btc/.ssh
- rm -rf /home/pi/.ssh
- rm -rf /root/.ssh
- rm /var/log/*.gz
- rm /var/log/*.0
- rm /var/log/*.1
- rm /var/log/*.old
- echo "" | tee /var/log/*.log
- echo "" | tee /var/log/apt/*.log
- echo "" | tee /var/log/*.log
- echo "" | tee /var/log/*.err
- echo "" | tee /var/log/*.info
- echo "" > /var/log/debug
- echo "" > /var/log/dmesg
- echo "" > /var/log/syslog
- echo "" > /var/log/btmp
- echo "" > /var/log/messages
- echo "" > /var/log/wtmp
- echo "" > /var/log/faillog
- echo "" > /var/log/lastlog
- echo "" > /var/log/aptitude
- echo "" > /var/log/ConsoleKit/history
Advertisement
Add Comment
Please, Sign In to add comment