From 2f791c20ae45e7030c1b27d65f69186309a8ef8c Mon Sep 17 00:00:00 2001
From: root <root@chinaman.(none)>
Date: Fri, 8 Jul 2011 17:24:48 +0200
Subject: mining: added archlinux cruise control

mining/Makefile: added archlinux cruise control (auto installer) which always does the right thing.
	loosely after http://rubyists.github.com/2011/06/08/how-to-build-a-namecoin-or-bitcoin-miner-in98-easy-steps.html
mining/{user/,}/bin:renamed
mining/bin/newkey.sh: add policy Xorg keygen
---
 btc/mining/bin/ati_temper    |  5 +++++
 btc/mining/bin/cleanup_tmp   |  4 ++++
 btc/mining/bin/ensure-router | 27 +++++++++++++++++++++++++++
 btc/mining/bin/ensure-wlan0  | 32 ++++++++++++++++++++++++++++++++
 btc/mining/bin/newkey.sh     | 15 +++++++++++++++
 5 files changed, 83 insertions(+)
 create mode 100755 btc/mining/bin/ati_temper
 create mode 100755 btc/mining/bin/cleanup_tmp
 create mode 100755 btc/mining/bin/ensure-router
 create mode 100755 btc/mining/bin/ensure-wlan0
 create mode 100755 btc/mining/bin/newkey.sh

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/ati_temper b/btc/mining/bin/ati_temper
new file mode 100755
index 00000000..283a6024
--- /dev/null
+++ b/btc/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/btc/mining/bin/cleanup_tmp b/btc/mining/bin/cleanup_tmp
new file mode 100755
index 00000000..e1395b19
--- /dev/null
+++ b/btc/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/btc/mining/bin/ensure-router b/btc/mining/bin/ensure-router
new file mode 100755
index 00000000..ec78f610
--- /dev/null
+++ b/btc/mining/bin/ensure-router
@@ -0,0 +1,27 @@
+#! /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
+
+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; /etc/init.d/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/btc/mining/bin/ensure-wlan0 b/btc/mining/bin/ensure-wlan0
new file mode 100755
index 00000000..92839a13
--- /dev/null
+++ b/btc/mining/bin/ensure-wlan0
@@ -0,0 +1,32 @@
+#! /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 ! ifconfig wlan0 | grep -q 'inet addr'; then
+  if ! grep -q wlan0 /etc/network/interfaces; then
+    cat >> /etc/network/interfaces <<EOF
+# generated by rc.local
+auto wlan0
+iface wlan0 inet dhcp
+wpa_conf /etc/wpa_supplicant/wpa_supplicant.conf
+EOF
+  fi
+
+  beep -l 50 -f 2000; /etc/init.d/network-manager restart
+  beep -l 50 -f 2000; ifdown wlan0
+  beep -l 50 -f 2000; ifup wlan0
+  if ifconfig wlan0 | grep -q 'inet addr'; 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/btc/mining/bin/newkey.sh b/btc/mining/bin/newkey.sh
new file mode 100755
index 00000000..e71ab85b
--- /dev/null
+++ b/btc/mining/bin/newkey.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+auth=$HOME/.Xauthority
+cp /dev/null $auth
+
+if [ "$1" = "-md5" ]; then
+  key=`pstat -pfS | md5`
+else
+  key=`perl -e 'srand; printf int(rand(10000000000000))'`
+  key=$key$key
+fi
+
+xauth add unix:0 . $key
+
+xauth add ${HOST}:0 . $key
-- 
cgit v1.2.3


From ebf5d05740a0f15fb3140af5229c820f8cfd008a Mon Sep 17 00:00:00 2001
From: Chinaman <root@chinaman>
Date: Fri, 8 Jul 2011 18:02:29 +0200
Subject: mining/bin/archlinux-cruise-control added

script is pulled out from the original Makefile.
added TODO file(because every project needs one
---
 btc/mining/bin/archlinux-cruise-control | 44 +++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100755 btc/mining/bin/archlinux-cruise-control

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/archlinux-cruise-control b/btc/mining/bin/archlinux-cruise-control
new file mode 100755
index 00000000..d455d10e
--- /dev/null
+++ b/btc/mining/bin/archlinux-cruise-control
@@ -0,0 +1,44 @@
+#!/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
+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 
+pacman --needed --noconfirm -Syu rsync git openssh yajl sudo tmux lm_sensors vim yaourt kernel26-headers 
+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 xorg-twm
+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
+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 'xterm &' >> /home/worker/.xinitrc	
+echo 'exec twm' >> /home/worker/.xinitrc	
+echo '!! start x with `xinit -- -auth ~/.Xauthority`'
+
-- 
cgit v1.2.3


From 1211423de9c83265dd6065444b353ecbd03e697f Mon Sep 17 00:00:00 2001
From: user <user@bergwerk>
Date: Sat, 9 Jul 2011 07:12:45 +0000
Subject: enable-wlan0: handle the nightmare applet

---
 btc/mining/bin/ensure-wlan0 | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/ensure-wlan0 b/btc/mining/bin/ensure-wlan0
index 92839a13..77587156 100755
--- a/btc/mining/bin/ensure-wlan0
+++ b/btc/mining/bin/ensure-wlan0
@@ -6,20 +6,28 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then
   exit 23 # go to hell
 fi
 
-if ! ifconfig wlan0 | grep -q 'inet addr'; then
-  if ! grep -q wlan0 /etc/network/interfaces; then
-    cat >> /etc/network/interfaces <<EOF
-# generated by rc.local
-auto wlan0
-iface wlan0 inet dhcp
-wpa_conf /etc/wpa_supplicant/wpa_supplicant.conf
-EOF
+has_internet() {
+  curl -sS google.com >/dev/null
+}
+
+if ! has_internet; then
+
+  ## get rid of the nightmare applet
+  pkill -9 nm-applet
+  if test -x "`type -p nm-applet`"; then
+    rm -vf "`type -p nm-applet`"
   fi
 
-  beep -l 50 -f 2000; /etc/init.d/network-manager restart
-  beep -l 50 -f 2000; ifdown wlan0
-  beep -l 50 -f 2000; ifup wlan0
-  if ifconfig wlan0 | grep -q 'inet addr'; then
+  beep -l 50 -f 2000; pkill 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
-- 
cgit v1.2.3


From c049ca0c58ba063422d6eccd70c58c1aa4293975 Mon Sep 17 00:00:00 2001
From: user <user@bergwerk>
Date: Sat, 9 Jul 2011 07:53:10 +0000
Subject: ensure-wlan0: try harder

---
 btc/mining/bin/ensure-wlan0 | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/ensure-wlan0 b/btc/mining/bin/ensure-wlan0
index 77587156..95d626d2 100755
--- a/btc/mining/bin/ensure-wlan0
+++ b/btc/mining/bin/ensure-wlan0
@@ -12,13 +12,16 @@ has_internet() {
 
 if ! has_internet; then
 
-  ## get rid of the nightmare applet
-  pkill -9 nm-applet
-  if test -x "`type -p nm-applet`"; then
-    rm -vf "`type -p nm-applet`"
-  fi
+  ## get rid of the fuckers
+  for fucker in NetworkManager nm-applet; do
+    pkill -9 $fucker
+    if test -x "`type -p $fucker`"; then
+      rm -vf "`type -p $fucker`"
+    fi
+  done
 
-  beep -l 50 -f 2000; pkill wpa_supplicant
+  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
-- 
cgit v1.2.3


From 89bafc22e43cefec51a77de36fd0ce64c01452da Mon Sep 17 00:00:00 2001
From: user <user@bergwerk>
Date: Sat, 9 Jul 2011 08:09:58 +0000
Subject: kill fuckers with even more hate

---
 btc/mining/bin/ensure-wlan0 | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/ensure-wlan0 b/btc/mining/bin/ensure-wlan0
index 95d626d2..fa92c4f5 100755
--- a/btc/mining/bin/ensure-wlan0
+++ b/btc/mining/bin/ensure-wlan0
@@ -2,7 +2,7 @@
 
 if test "${nosudo-false}" != true -a `id -u` != 0; then
   echo "we're going sudo..." >&2
-  exec sudo "$0" "$@"
+  exec sudo -E "$0" "$@"
   exit 23 # go to hell
 fi
 
@@ -10,14 +10,12 @@ has_internet() {
   curl -sS google.com >/dev/null
 }
 
-if ! has_internet; then
+if test "${force-false}" = true || ! has_internet; then
 
   ## get rid of the fuckers
   for fucker in NetworkManager nm-applet; do
     pkill -9 $fucker
-    if test -x "`type -p $fucker`"; then
-      rm -vf "`type -p $fucker`"
-    fi
+    (IFS=:; for dir in $PATH; do rm -vf $dir/$fucker; done)
   done
 
   beep -l 50 -f 2000; pkill wpa
-- 
cgit v1.2.3


From b71b1f984f0dfc9049e689707e64927c73ac6879 Mon Sep 17 00:00:00 2001
From: Chinaman <root@chinaman>
Date: Sun, 10 Jul 2011 06:23:22 +0200
Subject: updated cruise control, now incompatible with linucCoin!

mining/bin/newkey.sh: unused because slime is now in place
mining/user/startup.sh: edited paths to miner, NOW INCOMPATIBLE with linucCoin (sucked anyway)
temper/Makefile: fixed issue when installing temper (lose suid bit)
---
 btc/mining/bin/archlinux-cruise-control | 34 +++++++++++++++++++++++++++++----
 btc/mining/bin/newkey.sh                | 15 ---------------
 2 files changed, 30 insertions(+), 19 deletions(-)
 delete mode 100755 btc/mining/bin/newkey.sh

(limited to 'btc/mining/bin')

diff --git a/btc/mining/bin/archlinux-cruise-control b/btc/mining/bin/archlinux-cruise-control
index d455d10e..de5a0fa4 100755
--- a/btc/mining/bin/archlinux-cruise-control
+++ b/btc/mining/bin/archlinux-cruise-control
@@ -7,9 +7,22 @@ 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 
-pacman --needed --noconfirm -Syu rsync git openssh yajl sudo tmux lm_sensors vim yaourt kernel26-headers 
+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
@@ -18,7 +31,10 @@ echo "** Installing ATI drivers"
 [ "`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 xorg-twm
+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 !!"
@@ -27,6 +43,13 @@ 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"
@@ -38,7 +61,10 @@ 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 twm' >> /home/worker/.xinitrc	
-echo '!! start x with `xinit -- -auth ~/.Xauthority`'
+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/btc/mining/bin/newkey.sh b/btc/mining/bin/newkey.sh
deleted file mode 100755
index e71ab85b..00000000
--- a/btc/mining/bin/newkey.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-auth=$HOME/.Xauthority
-cp /dev/null $auth
-
-if [ "$1" = "-md5" ]; then
-  key=`pstat -pfS | md5`
-else
-  key=`perl -e 'srand; printf int(rand(10000000000000))'`
-  key=$key$key
-fi
-
-xauth add unix:0 . $key
-
-xauth add ${HOST}:0 . $key
-- 
cgit v1.2.3