mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-21 17:42:33 +02:00
Added latest configs
This commit is contained in:
parent
6ff00e78cc
commit
891e46b842
@ -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 .
|
||||
|
@ -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) {
|
||||
|
@ -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"
|
||||
|
@ -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
|
@ -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\":
|
||||
{
|
||||
|
@ -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":
|
||||
{
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -6,6 +6,7 @@ module.exports.typeDefs = `
|
||||
type Pool {
|
||||
id: Int!
|
||||
enabled: Boolean!
|
||||
donation: Int
|
||||
url: String!
|
||||
username: String
|
||||
password: String
|
||||
|
@ -5,6 +5,7 @@ module.exports.typeDefs = `
|
||||
|
||||
input PoolCreateInput {
|
||||
enabled: Boolean!
|
||||
donation: Int
|
||||
url: String!
|
||||
username: String
|
||||
password: String
|
||||
|
@ -6,6 +6,7 @@ module.exports.typeDefs = `
|
||||
input PoolUpdateInput {
|
||||
id: Int!
|
||||
enabled: Boolean
|
||||
donation: Int
|
||||
url: String
|
||||
username: String
|
||||
password: String
|
||||
|
@ -5,6 +5,7 @@ module.exports.typeDefs = `
|
||||
|
||||
input PoolUpdateAllInputItem {
|
||||
index: Int!
|
||||
donation: Int
|
||||
enabled: Boolean!
|
||||
url: String!
|
||||
username: String
|
||||
|
@ -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!
|
||||
|
@ -8,6 +8,7 @@ module.exports.typeDefs = `
|
||||
voltage: Float,
|
||||
frequency: Int,
|
||||
fan: Int
|
||||
customApproval: Boolean
|
||||
connectedWifi: String
|
||||
leftSidebarVisibility: Boolean
|
||||
leftSidebarExtended: Boolean
|
||||
|
@ -1,6 +1,7 @@
|
||||
const updateFields = {
|
||||
id: 'id',
|
||||
enabled: 'enabled',
|
||||
donation: 'donation',
|
||||
url: 'url',
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
|
@ -16,6 +16,7 @@ module.exports = ({ define }) => {
|
||||
readQ.select(
|
||||
'id',
|
||||
'enabled',
|
||||
'donation',
|
||||
'url',
|
||||
'username',
|
||||
'password',
|
||||
|
@ -1,6 +1,7 @@
|
||||
const updateFields = {
|
||||
id: 'id',
|
||||
enabled: 'enabled',
|
||||
donation: 'donation',
|
||||
url: 'url',
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user