Author

Topic: Requesting a whitelist (Read 707 times)

legendary
Activity: 1204
Merit: 1015
December 31, 2011, 02:08:19 PM
#2
Sorry about the delay; I haven't had internet for several days.
hero member
Activity: 496
Merit: 500
December 27, 2011, 12:57:14 PM
#1
I have a useful LinuxCoin setup script that I'd like to post in the thread in Project Development.

You set this up to run automatically upon boot and it will create all of the miner scripts, the auto start script, the restart script, etc based upon the devices installed in your system.

Code:
#!/bin/bash

xhost +
echo $DISPLAY > /home/user/.display

echo "Configuring on first run..."

while [ -z $IP ]; do
  sleep 1
  IP=`/sbin/ifconfig | grep 192.168 | awk '{ split($2, ip, ".");  print ip[4] }'`
done

sudo awk '{
  if($3 == "linuxcoin") {
    print "127.0.0.1       localhost stimbo102" >> "/etc/hosts.new"
  } else {
    print $0 >> "/etc/hosts.new"
  }
}' /etc/hosts

sudo mv /etc/hosts.new /etc/hosts

sudo hostname stimbo$IP

AMDOverdriveCtrl -h | awk -v ip=$IP '
function append(data, file) {
  print data >> file
}

function write(data, file) {
  print data > file
}

function write_miner(device) {
  file = "/home/user/miner" device ".sh"
  write("#!/bin/bash", file)
  append("cd /opt/miners/phoenix", file)
  append("sudo ./phoenix.py -u http://stimbo10." ip ":[email protected]:8332/ -q 7 -k phatk BFI_INT VECTORS FASTLOOP=false AGGRESSION=11 DEVICE=" device, file)
  system("chmod +x " file)
}

function start_miner(device) {
  file = "/home/user/miner" device ".sh"
  system("lxterminal --title miner" device " --command sh " file)
}

function write_autostart() {
  file = "/home/user/.config/autostart/auto.desktop"
  write("[Desktop Entry]", file)
  append("Encoding=UTF-8", file)
  append("Name=coin", file)
  append("Exec=lxterminal --command \"sh /home/user/start.sh\"", file)
  append("Terminal=true", file)
}

function write_start() {
  file = "/home/user/start.sh"
  write("#!/bin/bash", file)
  append("sleep 20", file)
  append("xhost +", file)
  append("echo $DISPLAY > /home/user/.display", file)
  system("chmod +x " file)
}

function append_start(adapter, device) {
  file="/home/user/start.sh"
  append("AMDOverdriveCtrl -i " adapter " -b", file)
  append("lxterminal --title miner" device " --command sh /home/user/miner" device ".sh", file)
}

function write_restart() {
  file = "/home/user/restart.sh"
  write("#!/bin/bash", file)
  append("export DISPLAY=`cat /home/user/.display`", file)
  system("chmod +x " file)
}

function append_restart(adapter, device) {
  file="/home/user/restart.sh"
  append("pc=`ps waxuf | grep miner" device ".sh -c`", file)
  append("ld=`aticonfig --odgc --adapter=" device " | grep \"GPU load\" | cut -c 30-35 | cut -d % -f 1`", file)
  append("if [ $pc -lt \"2\" ] || [ $ld -lt \"50\" ] ; then", file)
  append(" kill `ps -ef | grep miner" device " | grep -v grep | awk \x27{print $2}\x27`", file)
  append(" lxterminal --title miner" device " --command sh /home/user/miner" device ".sh &", file)
  append(" date +\"%D %r miner" device " restarted\" >> /home/user/cron_job.log", file)
  append("fi", file)
}

BEGIN {
  n=0
  write_autostart()
  write_start()
  write_restart()
}
{
  if($5 ~ /active.*/) {
    device = substr($4, 1, length($4) - 1)
    devices[n++] = device
  }
}
END {
  for(device in devices) {
    print "Found device number " device " in adapter slot " devices[device]
    write_miner(device)
    append_start(devices[device], device)
    append_restart(devices[device], device)
    start_miner(device)
  }
}'

if [ -f /home/user/.config/autostart/firstrun.desktop ]; then
  rm /home/user/.config/autostart/firstrun.desktop
fi
Jump to: