cgminer.rockminer.init 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/sh /etc/rc.common
  2. #rockminer
  3. START=99
  4. APP=cgminer
  5. PID_FILE=/var/run/$APP.pid
  6. start() {
  7. local _pool1url
  8. local _pool1user
  9. local _pool1pw
  10. local _pool2url
  11. local _pool2user
  12. local _pool2pw
  13. local _pool3url
  14. local _pool3user
  15. local _pool3pw
  16. local _cf
  17. local _fan
  18. local _aa
  19. local _pb
  20. local _mo
  21. local _ntp_enable
  22. config_load cgminer
  23. config_get _pool1url default pool1url
  24. config_get _pool1user default pool1user
  25. config_get _pool1pw default pool1pw
  26. config_get _pool2url default pool2url
  27. config_get _pool2user default pool2user
  28. config_get _pool2pw default pool2pw
  29. config_get _pool3url default pool3url
  30. config_get _pool3user default pool3user
  31. config_get _pool3pw default pool3pw
  32. config_get _cf default chip_frequency
  33. config_get _fan default fan
  34. config_get _aa default api_allow
  35. config_get _pb default pool_balance
  36. config_get _mo default more_options
  37. config_get _ntp_enable default ntp_enable
  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. AVA4_OPTIONS=" --rock-freq $_cf "
  48. PARAMS=" $AVA4_OPTIONS $POOL1 $POOL2 $POOL3 --api-allow $_aa --api-listen $_mo --real-quiet"
  49. 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"
  50. ASIA="-p 1.cn.pool.ntp.org -p 3.asia.pool.ntp.org -p 2.asia.pool.ntp.org"
  51. # _ntp_enable: openwrt, asia, globle
  52. if [ "$_ntp_enable" == "asia" ]; then
  53. NTP_POOL="${ASIA}"
  54. fi
  55. if [ ! -f /tmp/cgminer-ntpd-done -a "$_ntp_enable" != "disable" ]; then
  56. while [ "$NTPD_RET" != "0" ]; do
  57. ntpd -d -n -q -N ${NTP_POOL}
  58. NTPD_RET=$?
  59. done
  60. touch /tmp/cgminer-ntpd-done
  61. fi
  62. # Make sure udevd run before cgminer start
  63. UDEVDCNT=`pidof udevd | wc -w`
  64. if [ "$UDEVDCNT" == "0" ]; then
  65. udevd --daemon
  66. fi
  67. sleep 2
  68. start-stop-daemon -S -x $APP -p $PID_FILE -m -b -- $PARAMS
  69. }
  70. stop() {
  71. start-stop-daemon -K -n $APP -p $PID_FILE -s TERM
  72. sleep 2
  73. }