diff --git a/Dockerfile b/Dockerfile index 586146c..07bef87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,5 +6,5 @@ COPY ./package.json /app/package.json COPY ./yarn.lock /app/yarn.lock ENV NODE_ENV=production RUN ./node_modules/.bin/yarn --production -COPY . /app -RUN tar -zcvf futurebit.tar.gz . +RUN rm ./*.json ./yarn.lock +RUN tar -zcf ../futurebit.tar.gz . diff --git a/migrations/20180629144344_initial.js b/migrations/20180629144344_initial.js index 23559db..6bc74b0 100644 --- a/migrations/20180629144344_initial.js +++ b/migrations/20180629144344_initial.js @@ -10,7 +10,7 @@ exports.up = async function (knex) { await knex.schema.createTable('settings', table => { table.increments('id') table.timestamps(false, true) - table.enum('miner_mode', ['eco', 'turbo', 'custom']).notNullable() + table.enum('miner_mode', ['eco', 'balanced', 'turbo', 'custom']).notNullable() table.float('voltage').notNullable() table.integer('frequency').notNullable() table.integer('fan').notNullable() @@ -19,6 +19,7 @@ exports.up = async function (knex) { table.boolean('left_sidebar_extended').notNullable() table.boolean('right_sidebar_visibility').notNullable() table.enum('temperature_unit', ['f', 'c']).notNullable() + table.boolean('custom_approval').notNull().defaultTo(false) }) // default settings @@ -39,12 +40,23 @@ exports.up = async function (knex) { table.increments('id') table.timestamps(false, true) table.boolean('enabled').notNullable() + table.integer('donation').notNullable() table.text('url').notNullable() table.text('username') table.text('password') table.text('proxy') table.integer('index').notNullable() }) + + // default pool + await knex('pools').insert({ + enabled: true, + donation: 1, + url: 'stratum+tcp://us.litecoinpool.org:3333', + username: 'jstefanop.x2', + password: 'x', + index: 0 + }) } exports.down = async function (knex) { diff --git a/scripts/build b/scripts/build index 92348fa..b14fe70 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ APP_PATH="$SCRIPT_PATH/.." mkdir -p "$APP_PATH/build" && \ docker build $APP_PATH -t orange && \ -docker run --rm -v "${APP_PATH}":/hostdir orange /bin/bash -c "cp ./futurebit.tar.gz /hostdir/build" +docker run --rm -v "${APP_PATH}":/hostdir orange /bin/bash -c "cp ../futurebit.tar.gz /hostdir/build" diff --git a/scripts/install b/scripts/install index 7344258..e7f8ede 100755 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,5 @@ #!/bin/bash -iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT && \ -iptables -A INPUT -i eth0 -p tcp --dport 5000 -j ACCEPT && \ -iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000 +iptables -A INPUT -p tcp --dport 80 -j ACCEPT && \ +iptables -A INPUT -p tcp --dport 5000 -j ACCEPT && \ +iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 5000 \ No newline at end of file diff --git a/scripts/os_stats b/scripts/os_stats index f987a56..9e76b8e 100755 --- a/scripts/os_stats +++ b/scripts/os_stats @@ -31,6 +31,8 @@ LOADAVG=$(cat /proc/loadavg) ARCHITECTURE=$(uname -m) TEMP=$(cat /sys/class/thermal/thermal_zone*/temp) ACTIVE_WIFI=$(nmcli -t c show --active | grep wireless | cut -d":" -f1) +MINER_TEMP=$(cat /var/local/apollo/hwmon/pcb_temp) +MINER_FAN_SPEED=$(cat /var/local/apollo/hwmon/fan_speed) # Memory memTotal=$(egrep '^MemTotal:' /proc/meminfo | awk '{print $2}') @@ -60,6 +62,8 @@ JSON="{ \"loadAverage\": \"$LOADAVG\", \"architecture\": \"$ARCHITECTURE\", \"temperature\": \"$TEMP\", + \"minerTemperature\": \"MINER_TEMP\", + \"minerFanSpeed\": \"MINER_FAN_SPEED\", \"activeWifi\": \"$ACTIVE_WIFI\", \"memory\": { diff --git a/scripts/os_stats_fake b/scripts/os_stats_fake index c7efd03..4b2ee90 100755 --- a/scripts/os_stats_fake +++ b/scripts/os_stats_fake @@ -8,6 +8,8 @@ cat << EOF "loadAverage": "0.00 0.00 0.00 1/120 2859", "architecture": "armv7l", "temperature": "40656", + "minerTemperature": "76", + "minerFanSpeed": "4567", "activeWifi": "befree", "memory": { diff --git a/src/configurator.js b/src/configurator.js index d9aeb26..b7b2db1 100644 --- a/src/configurator.js +++ b/src/configurator.js @@ -73,16 +73,46 @@ const generate = async function (pools = null, settings = null ) { 'ALL' ], 'set-device' : [ - 'APL:clock=' + settings.frequency, - 'APL:voltage=' + settings.voltage, - 'APL:mode=' + settings.minerMode, - 'APL:fan=' + settings.fan + 'APL:clock=' + settings.frequency ] }; + + const confDir = (process.env.NODE_ENV === 'production') ? '/var/local/apollo/hwmon' : '/tmp/hwmon'; + let minerMode = 0; + + switch (settings.minerMode) { + case 'eco': + minerMode = 1 + break; + case 'balanced': + minerMode = 2 + break; + case 'turbo': + minerMode = 3 + break; + default: + minerMode = 0 + } + + const voltageStep = parseInt((settings.voltage - 644) / 4.15); + + // Write all configuration files + // Bfgminer fs.writeFile('/opt/bfgminer.conf', JSON.stringify(configuration, null, 4), (err) => { - // console.log(configuration); - console.log('Configuration saved'); + // Conf dir + fs.mkdir(confDir, { recursive: true }, (err) => { + // Mode + fs.writeFile(confDir + '/hwmon_state', minerMode, (err) => { + // Fan + fs.writeFile(confDir + '/fan_speed', settings.fan, (err) => { + // Voltage + fs.writeFile(confDir + '/reg_voltage', parseInt(voltageStep), (err) => { + console.log('Configuration saved'); + }); + }); + }); + }); }); } diff --git a/src/graphql/graphqlModules/Mcu/McuStats.js b/src/graphql/graphqlModules/Mcu/McuStats.js index 3bfa24a..255afd2 100644 --- a/src/graphql/graphqlModules/Mcu/McuStats.js +++ b/src/graphql/graphqlModules/Mcu/McuStats.js @@ -19,7 +19,9 @@ module.exports.typeDefs = ` uptime: String loadAverage: String, architecture: String - temperature: String + temperature: Int + minerTemperature: Int + minerFanSpeed: Int activeWifi: String memory: MemoryStats cpu: CpuStats diff --git a/src/graphql/graphqlModules/Pool/Pool.js b/src/graphql/graphqlModules/Pool/Pool.js index 1287c86..1995eb3 100644 --- a/src/graphql/graphqlModules/Pool/Pool.js +++ b/src/graphql/graphqlModules/Pool/Pool.js @@ -6,6 +6,7 @@ module.exports.typeDefs = ` type Pool { id: Int! enabled: Boolean! + donation: Int url: String! username: String password: String diff --git a/src/graphql/graphqlModules/Pool/PoolCreate.js b/src/graphql/graphqlModules/Pool/PoolCreate.js index 0f6f3ac..fa05e96 100644 --- a/src/graphql/graphqlModules/Pool/PoolCreate.js +++ b/src/graphql/graphqlModules/Pool/PoolCreate.js @@ -5,6 +5,7 @@ module.exports.typeDefs = ` input PoolCreateInput { enabled: Boolean! + donation: Int url: String! username: String password: String diff --git a/src/graphql/graphqlModules/Pool/PoolUpdate.js b/src/graphql/graphqlModules/Pool/PoolUpdate.js index 573dfd4..a6b2baf 100644 --- a/src/graphql/graphqlModules/Pool/PoolUpdate.js +++ b/src/graphql/graphqlModules/Pool/PoolUpdate.js @@ -6,6 +6,7 @@ module.exports.typeDefs = ` input PoolUpdateInput { id: Int! enabled: Boolean + donation: Int url: String username: String password: String diff --git a/src/graphql/graphqlModules/Pool/PoolsUpdate.js b/src/graphql/graphqlModules/Pool/PoolsUpdate.js index 2a114db..1661bd2 100644 --- a/src/graphql/graphqlModules/Pool/PoolsUpdate.js +++ b/src/graphql/graphqlModules/Pool/PoolsUpdate.js @@ -5,6 +5,7 @@ module.exports.typeDefs = ` input PoolUpdateAllInputItem { index: Int! + donation: Int enabled: Boolean! url: String! username: String diff --git a/src/graphql/graphqlModules/Settings/Settings.js b/src/graphql/graphqlModules/Settings/Settings.js index 9a26d16..0bf471b 100644 --- a/src/graphql/graphqlModules/Settings/Settings.js +++ b/src/graphql/graphqlModules/Settings/Settings.js @@ -3,7 +3,7 @@ module.exports.typeDefs = ` Settings: SettingsActions } - enum MinerMode { eco, turbo, custom } + enum MinerMode { eco, balanced, turbo, custom } enum TemperatureUnit { f, c } type Settings { @@ -13,6 +13,7 @@ module.exports.typeDefs = ` voltage: Float! frequency: Int! fan: Int! + customApproval: Boolean connectedWifi: String leftSidebarVisibility: Boolean! leftSidebarExtended: Boolean! diff --git a/src/graphql/graphqlModules/Settings/SettingsUpdate.js b/src/graphql/graphqlModules/Settings/SettingsUpdate.js index d5ce272..10dfd1e 100644 --- a/src/graphql/graphqlModules/Settings/SettingsUpdate.js +++ b/src/graphql/graphqlModules/Settings/SettingsUpdate.js @@ -8,6 +8,7 @@ module.exports.typeDefs = ` voltage: Float, frequency: Int, fan: Int + customApproval: Boolean connectedWifi: String leftSidebarVisibility: Boolean leftSidebarExtended: Boolean diff --git a/src/store/api/pools/collection/poolInsert.js b/src/store/api/pools/collection/poolInsert.js index 8fa913e..6e5c9b3 100644 --- a/src/store/api/pools/collection/poolInsert.js +++ b/src/store/api/pools/collection/poolInsert.js @@ -1,6 +1,7 @@ const updateFields = { id: 'id', enabled: 'enabled', + donation: 'donation', url: 'url', username: 'username', password: 'password', diff --git a/src/store/api/pools/collection/poolRead.js b/src/store/api/pools/collection/poolRead.js index d2a3d48..86bc4ca 100644 --- a/src/store/api/pools/collection/poolRead.js +++ b/src/store/api/pools/collection/poolRead.js @@ -16,6 +16,7 @@ module.exports = ({ define }) => { readQ.select( 'id', 'enabled', + 'donation', 'url', 'username', 'password', diff --git a/src/store/api/pools/collection/poolUpdate.js b/src/store/api/pools/collection/poolUpdate.js index 770d387..dcad15d 100644 --- a/src/store/api/pools/collection/poolUpdate.js +++ b/src/store/api/pools/collection/poolUpdate.js @@ -1,6 +1,7 @@ const updateFields = { id: 'id', enabled: 'enabled', + donation: 'donation', url: 'url', username: 'username', password: 'password', diff --git a/src/store/api/settings/collection/settingsList.js b/src/store/api/settings/collection/settingsList.js index abb66e8..3afc0cb 100644 --- a/src/store/api/settings/collection/settingsList.js +++ b/src/store/api/settings/collection/settingsList.js @@ -20,6 +20,7 @@ module.exports = ({ define }) => { 'voltage', 'frequency', 'fan', + 'custom_approval as customApproval', 'connected_wifi as connectedWifi', 'left_sidebar_visibility as leftSidebarVisibility', 'left_sidebar_extended as leftSidebarExtended', diff --git a/src/store/api/settings/collection/settingsRead.js b/src/store/api/settings/collection/settingsRead.js index 5a2fba3..b0b7a9d 100644 --- a/src/store/api/settings/collection/settingsRead.js +++ b/src/store/api/settings/collection/settingsRead.js @@ -5,6 +5,7 @@ module.exports = ({ define }) => { 'voltage', 'frequency', 'fan', + 'custom_approval as customApproval', 'connected_wifi as connectedWifi', 'left_sidebar_visibility as leftSidebarVisibility', 'left_sidebar_extended as leftSidebarExtended', diff --git a/src/store/api/settings/collection/settingsUpdate.js b/src/store/api/settings/collection/settingsUpdate.js index c086242..570e08d 100644 --- a/src/store/api/settings/collection/settingsUpdate.js +++ b/src/store/api/settings/collection/settingsUpdate.js @@ -3,6 +3,7 @@ const updateFields = { voltage: 'voltage', frequency: 'frequency', fan: 'fan', + 'customApproval': 'custom_approval', connectedWifi: 'connected_wifi', leftSidebarVisibility: 'left_sidebar_visibility', leftSidebarExtended: 'left_sidebar_extended',