crazydownloaded

Untitled

Dec 2nd, 2012
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Switch to root
  2. sudo passwd root
  3. sudo su -
  4.  
  5. #Enable testing updates
  6. nano /etc/apt/sources.list
  7.     deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi
  8.  
  9. nano /etc/apt/sources.list.d/raspi.list
  10.     no change (testing not available here, nor stable, only wheezy)
  11.  
  12. #Update the system
  13. aptitude update
  14. aptitude dist-upgrade
  15.  
  16. #Enable automatic (security) upgrades
  17. aptitude install unattended-upgrades apticron
  18. nano /etc/apt/apt.conf.d/50unattended-upgrades
  19. nano /etc/apt/apt.conf.d/02periodic
  20.     // Enable the update/upgrade script (0=disable)
  21.     APT::Periodic::Enable "1";
  22.    
  23.     // Do "apt-get update" automatically every n-days (0=disable)
  24.     APT::Periodic::Update-Package-Lists "1";
  25.    
  26.     // Do "apt-get upgrade --download-only" every n-days (0=disable)
  27.     APT::Periodic::Download-Upgradeable-Packages "1";
  28.    
  29.     // Run the "unattended-upgrade" security upgrade script
  30.     // every n-days (0=disabled)
  31.     // Requires the package "unattended-upgrades" and will write
  32.     // a log in /var/log/unattended-upgrades
  33.     APT::Periodic::Unattended-Upgrade "1";
  34.    
  35.     // Do "apt-get autoclean" every n-days (0=disable)
  36.     APT::Periodic::AutocleanInterval "7";
  37. nano /etc/apticron/apticron.conf
  38.     #Security updates are enabled by default, feel free to accept more
  39.  
  40. #FSCK repair when HD have inconistencies
  41. nano /etc/default/rcS
  42.     FSCKFIX=yes
  43.  
  44. #Let's configure the system for cgminer
  45. groupadd btc
  46. useradd -g btc btc
  47. mkdir /home/btc/
  48. cp -R .ssh /home/btc/
  49. cp -R .ssh /home/pi/
  50. echo "#!/bin/sh\n\ncgminer -c /home/btc/cgminer.conf -S auto\nsleep 300\n" > /home/btc/cgminer.sh
  51. echo "#!/bin/sh\n\nscreen -dmS cgminer /home/btc/cgminer.sh\n" > /home/btc/cgminer-screen.sh
  52. echo "#!/bin/sh\n\nsu btc -c /home/btc/cgminer-screen.sh\n" > /home/btc/cgminer-screen-as-btc.sh
  53. echo "#!/bin/sh\n\necho "Press CTRL+A then D to leave cgminer running"\necho "Run ls -laR /var/run/screen/S-btc to see all running screens for user btc"\nsleep 2\nscreen -r btc/cgminer\n" > /home/btc/view-cgminer-screen.sh
  54. echo "if [ -f ~/.bashrc ]; then\n        . ~/.bashrc\nfi\n" > /home/btc/.bash_profile
  55. echo "~/view-cgminer-screen.sh" > /home/btc/.bashrc
  56. echo "multiuser on\nacladd root\nacladd pi" > /home/btc/.screenrc
  57. ln -s /home/btc/cgminer.sh /root/cgminer.sh
  58. ln -s /home/btc/cgminer.sh /home/pi/cgminer.sh
  59. ln -s /home/btc/cgminer-screen.sh /root/cgminer-screen.sh
  60. ln -s /home/btc/cgminer-screen.sh /home/pi/cgminer-screen.sh
  61. ln -s /home/btc/cgminer-screen-as-btc.sh /root/cgminer-screen-as-btc.sh
  62. ln -s /home/btc/cgminer-screen-as-btc.sh /home/pi/cgminer-screen-as-btc.sh
  63. ln -s /home/btc/view-cgminer-screen.sh /root/view-cgminer-screen.sh
  64. ln -s /home/btc/view-cgminer-screen.sh /home/pi/view-cgminer-screen.sh
  65. ln -s /home/btc/cgminer.conf /root/cgminer.conf
  66. ln -s /home/btc/cgminer.conf /home/pi/cgminer.conf
  67. chmod +x /home/btc/*.sh
  68. chmod +x /root/*.sh
  69. chmod +x /home/pi/*.sh
  70. chown -R pi:pi /home/pi/
  71. chown -R btc:btc /home/btc/
  72.  
  73. #Enable cgminer to start with system
  74. nano /etc/rc.local
  75.     sleep 10
  76.     /home/btc/cgminer-screen-as-btc.sh
  77.  
  78. #Install things :) Some are required by cgminer to compile, others will be used later
  79. aptitude install fail2ban autoconf libtool libncurses-dev yasm curl libcurl4-openssl-dev pkg-config git screen mailx watchdog chkconfig
  80.  
  81. #Retrieve and install cgminer
  82. cd /root
  83. git clone https://github.com/ckolivas/cgminer.git cgminer
  84. cd cgminer
  85. aclocal
  86. ./autogen.sh
  87. export LIBCURL_CFLAGS='-I/usr/include/curl'
  88. export LIBCURL_LIBS='-L/usr/lib -lcurl'
  89. ./configure --enable-bitforce
  90. make
  91. make install
  92.  
  93.  
  94. #Watch dog the system
  95. #Enable automatic hard reboot in case of system freeze: use the hardware Raspberry Watchdog
  96. Load watchdog drivers:
  97. modprobe bcm2708_wdog
  98. nano /etc/modules
  99.     bcm2708_wdog
  100.  
  101. #Software watchdog, that will also feed the hardware watchdog
  102. nano /etc/watchdog.conf
  103.     #ping = 8.8.8.8 #doesn't work, make the system to reboot continuously
  104.     watchdog-device = /dev/watchdog
  105.     max-load-15 = 18
  106. chkconfig watchdog on
  107. /etc/init.d/watchdog start
  108.  
  109. #Cron job that will ensure cgminer is always running and will restart it if not
  110. echo "#!/bin/bash\n#\n# watchdog\n#\n# Run as a cron job to keep an eye on what_to_monitor which should always\n# be running. Restart what_to_monitor and send notification as needed.\n#\n# This needs to be run as root or a user that can start system services.\n#\n# Revisions: 0.1 (20100506), 0.2 (20100507)\n\nNAME=cgminer.sh\nSTART=/home/btc/cgminer-screen-as-btc.sh\n#NOTIFY=person1email\n#NOTIFYCC=person2email\nGREP=/bin/grep\nPS=/bin/ps\nNOP=/bin/true\nDATE=/bin/date\n#MAIL=/usr/bin/mail\n#RM=/bin/rm\n\n$PS -ef|$GREP -v grep|$GREP $NAME >/dev/null 2>&1\ncase \"$?\" in\n0)\n# It is running in this case so we do nothing.\necho \"$NAME is running, nothing to do\"\n$NOP\n;;\n1)\necho \"$NAME is NOT RUNNING. Starting $NAME and sending notices.\"\n$START 2>&1 >/dev/null &\nNOTICE=/tmp/cgminer-watchdog.log\necho \"$NAME was not running and was started on `$DATE`\" >> $NOTICE\n#$MAIL -n -s \"watchdog notice\" -c $NOTIFYCC $NOTIFY < $NOTICE\n#$RM -f $NOTICE\n;;\nesac\n\nexit\n" > /root/cgminer-watchdog.sh
  111.  
  112. chmod +x /root/cgminer-watchdog.sh
  113. crontab -e
  114.     * * * * * /root/cgminer-watchdog.sh
  115.  
  116.  
  117. #Update script that will upgrade cgminer. It won't run automatically, so run it when you want to upgrade your cgminer
  118. echo "#!/bin/sh\n\naptitude update\n\ncd /root/cgminer\ngit remote update\ngit pull\naclocal\n./autogen.sh\nexport LIBCURL_CFLAGS='-I/usr/include/curl'\nexport LIBCURL_LIBS='-L/usr/lib -lcurl'\n./configure --enable-bitforce\nmake\nmake install\n" > /root/Update.sh
  119.  
  120.  
  121. #Check BFL boxes are recognized:
  122. ls -l /dev/ttyUSB*
  123.  
  124.  
  125. #Make the image public compatible, clean some things
  126. passwd
  127. passwd pi
  128. passwd btc
  129.  
  130. echo "{\n\"pools\": [\n        {\n                \"url\": \"http://eu.ozco.in:8332\",\n                \"user\": \"crazydownloaded.raspi\",\n                \"pass\": \"x\"\n        },\n        {\n                \"url\": \"http://mining.bitcoin.cz:8332\",\n                \"user\": \"crazydownloaded.raspi\",\n                \"pass\": \"x\"\n        },\n        {\n                \"url\": \"http://mergedmining.btcguild.com:8332\",\n                \"user\": \"crazydownloaded_raspi\",\n                \"pass\": \"x\"\n        }\n],\n\n\"donation\": \"false\"\n}\n" > /home/btc/cgminer.conf
  131.  
  132. echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\n" > /etc/wpa_supplicant/wpa_supplicant.conf
  133.  
  134. rm /home/btc/.bash_history
  135. rm /home/pi/.bash_history
  136. rm /root/.bash_history
  137.  
  138. rm -rf /home/btc/.ssh
  139. rm -rf /home/pi/.ssh
  140. rm -rf /root/.ssh
  141.  
  142. rm /var/log/*.gz
  143. rm /var/log/*.0
  144. rm /var/log/*.1
  145. rm /var/log/*.old
  146. echo "" | tee /var/log/*.log
  147. echo "" | tee /var/log/apt/*.log
  148. echo "" | tee /var/log/*.log
  149. echo "" | tee /var/log/*.err
  150. echo "" | tee /var/log/*.info
  151. echo "" > /var/log/debug
  152. echo "" > /var/log/dmesg
  153. echo "" > /var/log/syslog
  154. echo "" > /var/log/btmp
  155. echo "" > /var/log/messages
  156. echo "" > /var/log/wtmp
  157. echo "" > /var/log/faillog
  158. echo "" > /var/log/lastlog
  159. echo "" > /var/log/aptitude
  160. echo "" > /var/log/ConsoleKit/history
Advertisement
Add Comment
Please, Sign In to add comment