cgminer.avalon1.init 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/sh /etc/rc.common
  2. START=99
  3. APP=cgminer
  4. PID_FILE=/var/run/$APP.pid
  5. start() {
  6. local _pool1url
  7. local _pool1user
  8. local _pool1pw
  9. local _pool2url
  10. local _pool2user
  11. local _pool2pw
  12. local _pool3url
  13. local _pool3user
  14. local _pool3pw
  15. local _cf
  16. local _mc
  17. local _aa
  18. local _pb
  19. local _mo
  20. config_load cgminer
  21. config_get _pool1url default pool1url
  22. config_get _pool1user default pool1user
  23. config_get _pool1pw default pool1pw
  24. config_get _pool2url default pool2url
  25. config_get _pool2user default pool2user
  26. config_get _pool2pw default pool2pw
  27. config_get _pool3url default pool3url
  28. config_get _pool3user default pool3user
  29. config_get _pool3pw default pool3pw
  30. config_get _asic default asic
  31. config_get _cf default chip_frequency
  32. config_get _mc default miner_count
  33. config_get _aa default api_allow
  34. config_get _pb default pool_balance
  35. config_get _target default target
  36. config_get _overheat default overheat
  37. config_get _mo default more_options
  38. if [ "$_pool1url" != "" -a "$_pool1user" != "" -a "$_pool1pw" != "" ]; then
  39. POOL1="-o $_pool1url -O $_pool1user:$_pool1pw"
  40. fi
  41. if [ "$_pool2url" != "" -a "$_pool2user" != "" -a "$_pool2pw" != "" ]; then
  42. POOL2="-o $_pool2url -O $_pool2user:$_pool2pw"
  43. fi
  44. if [ "$_pool3url" != "" -a "$_pool3user" != "" -a "$_pool3pw" != "" ]; then
  45. POOL3="-o $_pool3url -O $_pool3user:$_pool3pw"
  46. fi
  47. # (1.67/50) == (2^32/1000/1000/$_cf/$CHIP_NUM/TO)
  48. # 1.67 Second in FPGA is 50, a 256Mhs chip needs 16.7s finish 2^32 hashs
  49. CHIP_NUM=10
  50. TO=$(( 128591 / $CHIP_NUM / $_cf ))
  51. AOPTIONS=" --avalon-options 115200:$_mc:$CHIP_NUM:$TO:$_cf:$_asic "
  52. PARAMS=" --lowmem $AOPTIONS $POOL1 $POOL2 $POOL3 $_pb --api-allow $_aa --api-listen $_mo --avalon-cutoff $_overheat --avalon-temp $_target"
  53. $APP --lowmem $AOPTIONS -q >/dev/null 2>&1
  54. sleep 1
  55. if [ ! -f /tmp/cgminer-ntpd-done ]; then
  56. while [ "$NTPD_RET" != "0" ]; do
  57. ntpd -d -n -q -N \
  58. -p 0.openwrt.pool.ntp.org \
  59. -p 1.openwrt.pool.ntp.org \
  60. -p 2.openwrt.pool.ntp.org \
  61. -p 3.openwrt.pool.ntp.org
  62. NTPD_RET=$?
  63. done
  64. touch /tmp/cgminer-ntpd-done
  65. fi
  66. start-stop-daemon -S -x $APP -p $PID_FILE -m -b -- $PARAMS
  67. }
  68. stop() {
  69. start-stop-daemon -K -n $APP -p $PID_FILE -s TERM
  70. }