cgminer.dragon.init 2.3 KB

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