cgminer.bitmain.init 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh /etc/rc.common
  2. #set -x
  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 _pb
  17. local _ow
  18. local _bec
  19. local _aa
  20. local _mo
  21. local _freq
  22. local _volt
  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 _pb default pool_balance
  34. config_get _ow default bitmain_tempoverctrl
  35. config_get _bec default bitmain_beeper
  36. config_get _aa default api_allow
  37. config_get _mo default more_options
  38. config_get _xn default xnsub_options
  39. config_get _freq default freq
  40. config_get _volt default voltage
  41. if [ "$_volt" != "" ]; then
  42. VOPT="--bitmain-voltage $_volt"
  43. fi
  44. if [ "$_pool1url" != "" -a "$_pool1user" != "" -a "$_pool1pw" != "" ]; then
  45. POOL1="-o $_pool1url -O $_pool1user:$_pool1pw"
  46. fi
  47. if [ "$_pool2url" != "" -a "$_pool2user" != "" -a "$_pool2pw" != "" ]; then
  48. POOL2="-o $_pool2url -O $_pool2user:$_pool2pw"
  49. fi
  50. if [ "$_pool3url" != "" -a "$_pool3user" != "" -a "$_pool3pw" != "" ]; then
  51. POOL3="-o $_pool3url -O $_pool3user:$_pool3pw"
  52. fi
  53. BITOPT="--bitmain-options 115200:32:8 --bitmain-freq $_freq"
  54. POOLOPT="$POOL1 $POOL2 $POOL3 $_pb"
  55. APIOPT="--api-listen --api-allow $_aa"
  56. OTHEROPT="--bitmain-checkn2diff --bitmain-hwerror $_ow $_bec"
  57. PARAMS="$BITOPT $VOPT $POOLOPT $APIOPT $OTHEROPT $_mo $_xn"
  58. sleep 1
  59. cnt=0
  60. while [ "$cnt" != "3" -a "$NTPD_RET" != "0" ] ; do
  61. ntpd -d -n -q -N \
  62. -p 0.openwrt.pool.ntp.org \
  63. -p 1.openwrt.pool.ntp.org \
  64. -p 2.openwrt.pool.ntp.org \
  65. -p 3.openwrt.pool.ntp.org &> /dev/null
  66. NTPD_RET="$?"
  67. cnt=$(($cnt+1))
  68. sleep 1
  69. done
  70. echo $cnt
  71. echo $PARAMS
  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. }