cgminer.gekko.init 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 _2pacf default 2pac_frequency
  32. config_set _gek1f default gek1_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=" --gekko-2pac-freq $_2pacf --gekko-compac-freq $_gek1f "
  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. }