From 60bb54649d64208facc2d22478413e3fd1a7227f Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 24 Aug 2011 16:45:00 +0200 Subject: {btc -> gold} SC & co., we're ready --- gold/btcguild/index.js | 20 +++++++ gold/mining/CONFIGURE | 8 +++ gold/mining/Makefile | 20 +++++++ gold/mining/README | 9 +++ gold/mining/TODO | 2 + gold/mining/bin/archlinux-cruise-control | 70 ++++++++++++++++++++++ gold/mining/bin/ati_temper | 5 ++ gold/mining/bin/cleanup_tmp | 4 ++ gold/mining/bin/ensure-router | 36 +++++++++++ gold/mining/bin/ensure-wlan0 | 41 +++++++++++++ gold/mining/poll_btcguild | 2 + gold/mining/user/.config/autostart/startup.desktop | 6 ++ gold/mining/user/mining.ovdr | 16 +++++ gold/mining/user/startup.sh | 13 ++++ gold/mtgox/json_ticker_helper.py | 7 +++ gold/mtgox/mtgox.getDepth | 3 + gold/mtgox/mtgox.getTrades | 3 + gold/mtgox/mtgox.ticker | 4 ++ gold/mtgox/ticker_text.sh | 3 + 19 files changed, 272 insertions(+) create mode 100644 gold/btcguild/index.js create mode 100644 gold/mining/CONFIGURE create mode 100644 gold/mining/Makefile create mode 100644 gold/mining/README create mode 100644 gold/mining/TODO create mode 100755 gold/mining/bin/archlinux-cruise-control create mode 100755 gold/mining/bin/ati_temper create mode 100755 gold/mining/bin/cleanup_tmp create mode 100755 gold/mining/bin/ensure-router create mode 100755 gold/mining/bin/ensure-wlan0 create mode 100644 gold/mining/poll_btcguild create mode 100644 gold/mining/user/.config/autostart/startup.desktop create mode 100644 gold/mining/user/mining.ovdr create mode 100755 gold/mining/user/startup.sh create mode 100755 gold/mtgox/json_ticker_helper.py create mode 100755 gold/mtgox/mtgox.getDepth create mode 100755 gold/mtgox/mtgox.getTrades create mode 100755 gold/mtgox/mtgox.ticker create mode 100755 gold/mtgox/ticker_text.sh (limited to 'gold') diff --git a/gold/btcguild/index.js b/gold/btcguild/index.js new file mode 100644 index 00000000..1f33db06 --- /dev/null +++ b/gold/btcguild/index.js @@ -0,0 +1,20 @@ +api_key = process.env.api_key; + +var options = { + host: 'www.btcguild.com', + port: 80, + path: '/api.php?api_key=' + api_key +}; + +http = require('http'); +http.get(options, function(res) { + var data = ''; + res.on('data', function (chunk) { + data += chunk; + }); + res.on('end', function () { + console.log(JSON.parse(data)); + }); +}).on('error', function(e) { + console.error('Error: ' + e.message); +}); diff --git a/gold/mining/CONFIGURE b/gold/mining/CONFIGURE new file mode 100644 index 00000000..299cbd53 --- /dev/null +++ b/gold/mining/CONFIGURE @@ -0,0 +1,8 @@ +How to Configure +=============== + +1. change the mining-url in ~/startup.sh +2. in KDE - 'AMDOverdriveCtrl - configure profile +3. in KDE-Autostart - activate the startup script +2. sudo /etc/init.d/gdm restart + diff --git a/gold/mining/Makefile b/gold/mining/Makefile new file mode 100644 index 00000000..8701920f --- /dev/null +++ b/gold/mining/Makefile @@ -0,0 +1,20 @@ +.PHONY: all format install configure +select-target: + @echo "You are made of stupid!" + echo "look here" + @cat Makefile +format: + cat README +fix-linucCoin: configure + apt-get install --yes lm-sensors tmux + echo '#!/bin/bash' > /usr/bin/ati_license + echo '#!/bin/sh' > /etc/init.d/live-boot + echo 'wall "going down"' >> /etc/init.d/live-boot + chmod 755 /etc/init.d/live-boot + echo 'sudo tar xvf /opt/AMD-APP-SDK-v2.4-lnx64/icd-registration.tgz -C /' >> /usr/bin/ati_license + cp -r user /home +configure: + yes '' | sensors-detect + @cat CONFIGURE +archlinux: + bin/archlinux-cruise-control diff --git a/gold/mining/README b/gold/mining/README new file mode 100644 index 00000000..ad8c3468 --- /dev/null +++ b/gold/mining/README @@ -0,0 +1,9 @@ +What to do: +format the usb-stick: +Device Boot Start End Blocks Id System +/dev/sda1 * 1 254 976345 c W95 FAT32 (LBA) +/dev/sda2 255 1017 2932972 83 Linux + +1. install coinlinux live system on sda1. +2. mkfs.ext3 /dev/sda2 -L live-rw +3. install grub on /dev/sda diff --git a/gold/mining/TODO b/gold/mining/TODO new file mode 100644 index 00000000..bafaa72a --- /dev/null +++ b/gold/mining/TODO @@ -0,0 +1,2 @@ +- fix the sed script in "make archlinux" to replace only the first occurrence +- test the amdoverdrive stuff from the home dir (user) diff --git a/gold/mining/bin/archlinux-cruise-control b/gold/mining/bin/archlinux-cruise-control new file mode 100755 index 00000000..de5a0fa4 --- /dev/null +++ b/gold/mining/bin/archlinux-cruise-control @@ -0,0 +1,70 @@ +#!/bin/bash +set -euf +export EDITOR=vim +echo "!! ARCHLINUX Cruise Control Mining installer !!" +echo "** adding main network profile" +cp /etc/network.d/examples/ethernet-dhcp /etc/network.d/main +echo 'POST_UP="sed -i \"1i nameserver 8.8.8.8\" /etc/resolv.conf"' >> /etc/network.d/main +echo "** adding worker account" +grep -q worker /etc/passwd || adduser worker +gpasswd -a worker wheel +gpasswd -a worker tty +gpasswd -a worker audio +gpasswd -a worker video +gpasswd -a worker network +gpasswd -a worker power + +echo "** adding archlinuxfr to pacman.conf" +grep -q archlinuxfr /etc/pacman.conf || echo "[archlinuxfr]" >> /etc/pacman.conf && echo "Server = http://repo.archlinux.fr/x86_64" >> /etc/pacman.conf +echo "** installing all the required parts" +pacman --needed --noconfirm -Syu rsync git openssh yajl sudo tmux lm_sensors vim yaourt kernel26-headers beep +echo "** doing some tweaks" +rm /usr/bin/python -f +ln -s /usr/bin/python2 /usr/bin/python +echo "syntax on" > /home/worker/.vimrc +echo "syntax on" > /root/.vimrc +echo "** installing tinc" +[ "`yaourt -Q tinc`" ] || yaourt -S --noconfirm tinc +sed -i -e 's/.*\%wheel.*/%wheel ALL=(ALL) NOPASSWD: ALL/1' /etc/sudoers +echo "** Installing ATI drivers" +[ "`yaourt -Q catalyst-utils`" ] || yaourt -S --noconfirm catalyst-utils +[ "`yaourt -Q catalyst-hook`" ] || yaourt -S --noconfirm catalyst-hook +[ "`yaourt -Q amdstream`" ] || yaourt -S --noconfirm amdstream +echo "** installing X" +pacman --needed -S --noconfirm xorg-server xorg-apps xorg-appres xorg-xinit xautolock xlockmore xorg-fonts xorg-xhost xorg-xauth xterm rxvt-unicode fluxbox slim +echo "** editing slim configuration" +sed -i 's/.*default_user.*/default_user worker/' /etc/slim.conf +sed -i 's/.*auto_login.*/auto_login yes/' /etc/slim.conf +echo "** Installing mining tools and overclocking stuff" +[ "`yaourt -Q phoenix-miner-svn`" ] || yaourt -S --noconfirm phoenix-miner-svn +echo "!! warning, you might need to adjust the version number of AMDOverdriveCTRL !!" +[ "`yaourt -Q amdoverdrivectrl`" ] || yaourt -S amdoverdrivectrl +echo "** copying bin folder" +cp -r $(readlink -f `dirname $0`)/ /home/worker +echo "** creating new .Xauthority for worker" +sudo -u worker /home/worker/bin/newkey.sh +mkdir -p /home/worker/.fluxbox +cp /krebs/mining/user/startup.sh /home/worker/startup.sh +chmod a+x /home/worker/startup.sh +cp /krebs/mining/user/startup.sh /home/worker/.fluxbox/startup +chmod a+x /home/worker/.fluxbox/startup +cp /krebs/mining/user/mining.ovdr /home/worker/ +chown -R worker:users /home/worker +echo "configuring X" +echo "!! ACTION REQUIRED, write down the first number of your ATI Graphics Adapter." +echo "!! i will open /etc/X11/xorg.conf for you, change the BusID of every Device to the numbers you see here" +echo "!! press enter to continue" +lspci|grep VGA +read +aticonfig --initial=dual-head +vim /etc/X11/xorg.conf +echo "** creating xinitrc and start x" +echo 'setxkbmap -option terminate:ctrl_alt_bksp' > /home/worker/.xinitrc +echo 'xautolock -corners +-+- -locker "xlock -mode blank"&' >> /home/worker/.xinitrc +echo '/home/worker/startup.sh &' >> /home/worker/.xinitrc +echo 'xterm &' >> /home/worker/.xinitrc +echo 'exec fluxbox' >> /home/worker/.xinitrc +echo '!! start x with `xinit `' +echo 'add "x:5:respawn:/usr/bin/slim >/dev/null 2>&1" to /etc/inittab to start slim" + + diff --git a/gold/mining/bin/ati_temper b/gold/mining/bin/ati_temper new file mode 100755 index 00000000..283a6024 --- /dev/null +++ b/gold/mining/bin/ati_temper @@ -0,0 +1,5 @@ +#displays: CARD1TEMP CARD2TEMP CPUTEMP OUTSIDE +echo -n "`DISPLAY=:0 aticonfig --adapter=1 --od-gettemperature | grep Temperature | sed -n 's/.*Temperature - \([0-9.]*\) C/\1/;p'` " +echo -n "`DISPLAY=:0 aticonfig --adapter=2 --od-gettemperature | grep Temperature | sed -n 's/.*Temperature - \([0-9.]*\) C/\1/;p'` " +echo -n "`sensors | grep temp1 | sed -e 's/temp1: *+\([0-9.]*\).*/\1/'` " +echo "`temper`" diff --git a/gold/mining/bin/cleanup_tmp b/gold/mining/bin/cleanup_tmp new file mode 100755 index 00000000..e1395b19 --- /dev/null +++ b/gold/mining/bin/cleanup_tmp @@ -0,0 +1,4 @@ +#! /bin/sh +ls -lAtr /tmp/ | sed -rn ' + /\.so$/{$!{s/.* ([A-Za-z0-9]+\.so)$/rm -v \/tmp\/\1/p}} +' | sudo sh diff --git a/gold/mining/bin/ensure-router b/gold/mining/bin/ensure-router new file mode 100755 index 00000000..5eedabc9 --- /dev/null +++ b/gold/mining/bin/ensure-router @@ -0,0 +1,36 @@ +#! /bin/sh + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +if=eth2 + +rc() { + for x in /etc/init.d/$1 /etc/rc.d/$1; do + if test -x $x; then + $x restart + break + fi + done +} + +if ! ifconfig $if | grep -q 'inet addr'; then + beep -l 50 -f 2500; ifconfig $if 0.0.0.0 down || : + beep -l 50 -f 2500; ifconfig $if 23.0.0.1/8 up || : + beep -l 50 -f 2500; rc dnsmasq restart + beep -l 50 -f 2500; iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE + beep -l 50 -f 2500; iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE + if ifconfig $if | grep -q 'inet addr'; then + beep -l 50 -f 2500 -n -l 100 -f 3000 + else + beep -l 50 -f 2500 -n -l 100 -f 1000 + fi +else + case "${1-}" in + (--quiet) : ;; + (*) beep -l 50 -f 2500 -n -l 100 -f 2500 ;; + esac +fi diff --git a/gold/mining/bin/ensure-wlan0 b/gold/mining/bin/ensure-wlan0 new file mode 100755 index 00000000..fa92c4f5 --- /dev/null +++ b/gold/mining/bin/ensure-wlan0 @@ -0,0 +1,41 @@ +#! /bin/sh + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo -E "$0" "$@" + exit 23 # go to hell +fi + +has_internet() { + curl -sS google.com >/dev/null +} + +if test "${force-false}" = true || ! has_internet; then + + ## get rid of the fuckers + for fucker in NetworkManager nm-applet; do + pkill -9 $fucker + (IFS=:; for dir in $PATH; do rm -vf $dir/$fucker; done) + done + + beep -l 50 -f 2000; pkill wpa + beep -l 50 -f 2000; rm -vf /var/run/wpa_supplicant/* + beep -l 50 -f 2000; wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf & + while ! wpa_cli status | grep -q wpa_state=COMPLETED; do + beep -l 50 -f 2000 -D 50 -n -l 50 -f 2000 + sleep 1 + done + beep -l 50 -f 2000; dhcpcd -x wlan0 + beep -l 50 -f 2000; dhcpcd wlan0 + #echo nameserver 8.8.8.8 >/etc/resolv.conf + if has_internet; then + beep -l 50 -f 2000 -n -l 100 -f 3000 + else + beep -l 50 -f 2000 -n -l 100 -f 1000 + fi +else + case "${1-}" in + (--quiet) : ;; + (*) beep -l 50 -f 2000 -n -l 100 -f 2000 ;; + esac +fi diff --git a/gold/mining/poll_btcguild b/gold/mining/poll_btcguild new file mode 100644 index 00000000..92a02657 --- /dev/null +++ b/gold/mining/poll_btcguild @@ -0,0 +1,2 @@ +API_KEY= +curl http://www.btcguild.com/api.php\?api_key\=${API_KEY} | python -mjson.tool diff --git a/gold/mining/user/.config/autostart/startup.desktop b/gold/mining/user/.config/autostart/startup.desktop new file mode 100644 index 00000000..67c35ef8 --- /dev/null +++ b/gold/mining/user/.config/autostart/startup.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=LXDE Autostart +Exec=/home/user/startup.sh +Terminal=true +Type=Application +Categories=Configuration diff --git a/gold/mining/user/mining.ovdr b/gold/mining/user/mining.ovdr new file mode 100644 index 00000000..d6cf6fec --- /dev/null +++ b/gold/mining/user/mining.ovdr @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/gold/mining/user/startup.sh b/gold/mining/user/startup.sh new file mode 100755 index 00000000..6274a892 --- /dev/null +++ b/gold/mining/user/startup.sh @@ -0,0 +1,13 @@ +sudo pkill tmux +sleep 5 +source ~/.profile +export DISPLAY=:0 +export URL="${URL-http://txgen_chinaman:lolwut@uk.btcguild.com:8332}" +#export URL="http://txgen:qJrXefWX@bitcoinpool.com:8334" +tmux start-server +tmux new-session -d -s mining -n mining +tmux new-window -t mining:1 'cd ~;AMDOverdriveCtrl -i 0 mining.ovdr' +tmux new-window -t mining:2 'cd ~;AMDOverdriveCtrl -i 3 mining.ovdr' +sleep 5 +tmux new-window -t mining:3 "cd /usr/src/phoenix-miner/; while sleep 1; do sudo ./phoenix.py -u $URL -k phatk DEVICE=0 VECTORS BFI_INT WORKSIZE=256 AGGRESSION=12 FASTLOOPS=false;done" +tmux new-window -t mining:4 "cd /usr/src/phoenix-miner/; while sleep 1; do sudo ./phoenix.py -u $URL -k phatk DEVICE=1 VECTORS BFI_INT WORKSIZE=256 AGGRESSION=12 FASTLOOPS=false;done" diff --git a/gold/mtgox/json_ticker_helper.py b/gold/mtgox/json_ticker_helper.py new file mode 100755 index 00000000..727dd594 --- /dev/null +++ b/gold/mtgox/json_ticker_helper.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +import json,sys + +result = json.load(sys.stdin) + +print "High: " + str(result["ticker"]["high"]) + " Low: " + str(result["ticker"]["low"]) + " Last: " + str(result["ticker"]["last"]) diff --git a/gold/mtgox/mtgox.getDepth b/gold/mtgox/mtgox.getDepth new file mode 100755 index 00000000..9a607979 --- /dev/null +++ b/gold/mtgox/mtgox.getDepth @@ -0,0 +1,3 @@ +#! /bin/sh +# get mtgox market depth +$ curl -ksS https://mtgox.com/code/data/getDepth.php diff --git a/gold/mtgox/mtgox.getTrades b/gold/mtgox/mtgox.getTrades new file mode 100755 index 00000000..73e5a68d --- /dev/null +++ b/gold/mtgox/mtgox.getTrades @@ -0,0 +1,3 @@ +#! /bin/sh +# get mtgox last trades +$ curl -ksS https://mtgox.com/code/data/getTrades.phl diff --git a/gold/mtgox/mtgox.ticker b/gold/mtgox/mtgox.ticker new file mode 100755 index 00000000..b24dfb35 --- /dev/null +++ b/gold/mtgox/mtgox.ticker @@ -0,0 +1,4 @@ +#! /bin/sh +# get mtgox ticker data +set -euf +curl -ksS https://mtgox.com/code/data/ticker.php diff --git a/gold/mtgox/ticker_text.sh b/gold/mtgox/ticker_text.sh new file mode 100755 index 00000000..2bcac134 --- /dev/null +++ b/gold/mtgox/ticker_text.sh @@ -0,0 +1,3 @@ +#!/bin/sh +dirname=`dirname $(readlink -f $0)` +$dirname/mtgox.ticker | python $dirname/json_ticker_helper.py -- cgit v1.2.3