#!/bin/sh /etc/rc.common START=99 APP=cgminer PID_FILE=/var/run/$APP.pid start() { local _pool1url local _pool1user local _pool1pw local _pool2url local _pool2user local _pool2pw local _pool3url local _pool3user local _pool3pw local _cf local _mc local _aa local _pb local _mo config_load cgminer config_get _pool1url default pool1url config_get _pool1user default pool1user config_get _pool1pw default pool1pw config_get _pool2url default pool2url config_get _pool2user default pool2user config_get _pool2pw default pool2pw config_get _pool3url default pool3url config_get _pool3user default pool3user config_get _pool3pw default pool3pw config_get _asic default asic config_get _cf default chip_frequency config_get _mc default miner_count config_get _aa default api_allow config_get _pb default pool_balance config_get _target default target config_get _overheat default overheat config_get _mo default more_options if [ "$_pool1url" != "" -a "$_pool1user" != "" -a "$_pool1pw" != "" ]; then POOL1="-o $_pool1url -O $_pool1user:$_pool1pw" fi if [ "$_pool2url" != "" -a "$_pool2user" != "" -a "$_pool2pw" != "" ]; then POOL2="-o $_pool2url -O $_pool2user:$_pool2pw" fi if [ "$_pool3url" != "" -a "$_pool3user" != "" -a "$_pool3pw" != "" ]; then POOL3="-o $_pool3url -O $_pool3user:$_pool3pw" fi # (1.67/50) == (2^32/1000/1000/$_cf/$CHIP_NUM/TO) # 1.67 Second in FPGA is 50, a 256Mhs chip needs 16.7s finish 2^32 hashs CHIP_NUM=10 TO=$(( 128591 / $CHIP_NUM / $_cf )) AOPTIONS=" --avalon-options 115200:$_mc:$CHIP_NUM:$TO:$_cf:$_asic " PARAMS=" --lowmem $AOPTIONS $POOL1 $POOL2 $POOL3 $_pb --api-allow $_aa --api-listen $_mo --avalon-cutoff $_overheat --avalon-temp $_target" $APP --lowmem $AOPTIONS -q >/dev/null 2>&1 sleep 1 if [ ! -f /tmp/cgminer-ntpd-done ]; then while [ "$NTPD_RET" != "0" ]; do ntpd -d -n -q -N \ -p 0.openwrt.pool.ntp.org \ -p 1.openwrt.pool.ntp.org \ -p 2.openwrt.pool.ntp.org \ -p 3.openwrt.pool.ntp.org NTPD_RET=$? done touch /tmp/cgminer-ntpd-done fi start-stop-daemon -S -x $APP -p $PID_FILE -m -b -- $PARAMS } stop() { start-stop-daemon -K -n $APP -p $PID_FILE -s TERM }