cgminer.avalon4.init 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 _cv
  17. local _va
  18. local _fan
  19. local _aa
  20. local _pb
  21. local _mo
  22. local _ntp_enable
  23. config_load cgminer
  24. config_get _pool1url default pool1url
  25. config_get _pool1user default pool1user
  26. config_get _pool1pw default pool1pw
  27. config_get _pool2url default pool2url
  28. config_get _pool2user default pool2user
  29. config_get _pool2pw default pool2pw
  30. config_get _pool3url default pool3url
  31. config_get _pool3user default pool3user
  32. config_get _pool3pw default pool3pw
  33. config_get _mmode default mining_mode
  34. config_get _cf default chip_frequency
  35. config_get _cv default chip_voltage
  36. config_get _va default voltage_adjust
  37. config_get _fan default fan
  38. config_get _aa default api_allow
  39. config_get _pb default pool_balance
  40. config_get _mo default more_options
  41. config_get _ntp_enable default ntp_enable
  42. if [ "$_pool1url" != "" -a "$_pool1user" != "" -a "$_pool1pw" != "" ]; then
  43. POOL1="-o $_pool1url -O $_pool1user:$_pool1pw"
  44. fi
  45. if [ "$_pool2url" != "" -a "$_pool2user" != "" -a "$_pool2pw" != "" ]; then
  46. POOL2="-o $_pool2url -O $_pool2user:$_pool2pw"
  47. fi
  48. if [ "$_pool3url" != "" -a "$_pool3user" != "" -a "$_pool3pw" != "" ]; then
  49. POOL3="-o $_pool3url -O $_pool3user:$_pool3pw"
  50. fi
  51. AVA4_OPTIONS=" --avalon4-fan $_fan-100 --avalon4-freq $_cf "
  52. PARAMS=" --lowmem $AVA4_OPTIONS $POOL1 $POOL2 $POOL3 --api-allow $_aa --api-listen $_mo "
  53. NTP_POOL="-p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org -p 4.openwrt.pool.ntp.org"
  54. ASIA="-p 1.cn.pool.ntp.org -p 3.asia.pool.ntp.org -p 2.asia.pool.ntp.org"
  55. # _ntp_enable: openwrt, asia, globle
  56. if [ "$_ntp_enable" == "asia" ]; then
  57. NTP_POOL="${ASIA}"
  58. fi
  59. if [ ! -f /tmp/cgminer-ntpd-done -a "$_ntp_enable" != "disable" ]; then
  60. while [ "$NTPD_RET" != "0" ]; do
  61. ntpd -d -n -q -N ${NTP_POOL}
  62. NTPD_RET=$?
  63. done
  64. touch /tmp/cgminer-ntpd-done
  65. fi
  66. # Make sure udevd run before cgminer start
  67. UDEVDCNT=`pidof udevd | wc -w`
  68. if [ "$UDEVDCNT" == "0" ]; then
  69. udevd --daemon
  70. fi
  71. sleep 2
  72. start-stop-daemon -S -x $APP -p $PID_FILE -m -b -- $PARAMS
  73. }
  74. stop() {
  75. start-stop-daemon -K -n $APP -p $PID_FILE -s TERM
  76. sleep 2
  77. }