Skip to content

Commit

Permalink
Merge pull request #2 from jstefanop/dev
Browse files Browse the repository at this point in the history
Bug Fixes, added front LED option
  • Loading branch information
jstefanop committed Apr 3, 2024
2 parents ff0d4df + f4b0164 commit baecf0d
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 71 deletions.
File renamed without changes.
8 changes: 6 additions & 2 deletions backend/image_install
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ cp $APOLLO_DIR/backend/default-configs/bitcoin.conf $APOLLO_DIR/backend/node/

### ckpool ###
#########################
#cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/ TODO UPDATE BINARIES
cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/
cp $APOLLO_DIR/backend/default-configs/ckpool.conf $APOLLO_DIR/backend/ckpool/

### TOR ###
Expand Down Expand Up @@ -218,14 +218,18 @@ systemctl daemon-reload

echo -e "${GREEN} ---> Reloaded systemd daemon${NC}"

#Disable Tor service until started by user
systemctl stop tor.service
systemctl disable tor.service

# Enable and start the services
systemctl enable apollo-api.service
systemctl enable apollo-ui-v2.service
systemctl enable swap.service
systemctl enable rc-local.service
systemctl enable apollo-miner.service
systemctl enable node.service
systemctl enable ckpool.service


systemctl disable serial-getty@ttyS2.service

Expand Down
10 changes: 7 additions & 3 deletions backend/install-v2
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ cp $APOLLO_DIR/backend/default-configs/bitcoin.conf $APOLLO_DIR/backend/node/

### ckpool ###
#########################
#cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/ TODO UPDATE BINARIES
cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/
cp $APOLLO_DIR/backend/default-configs/ckpool.conf $APOLLO_DIR/backend/ckpool/

### TOR ###
Expand All @@ -208,26 +208,30 @@ cp $APOLLO_DIR/backend/systemd/node.service /etc/systemd/system/

# Copy the ckpool.service file to /etc/systemd/system
cp $APOLLO_DIR/backend/systemd/ckpool.service /etc/systemd/system/
cp $APOLLO_DIR/backend/default-configs/ckpool.conf $APOLLO_DIR/backend/ckpool/

# Copy the apollo-miner.service file to /etc/systemd/system
cp $APOLLO_DIR/backend/systemd/apollo-miner.service /etc/systemd/system/


echo -e "${GREEN} ---> Copied apollo-api.service, apollo-ui-v2.service and ckpool.service to /etc/systemd/system${NC}"

# Reload systemd daemon to recognize the new service
systemctl daemon-reload

echo -e "${GREEN} ---> Reloaded systemd daemon${NC}"

#Disable Tor service until started by user
systemctl stop tor.service
systemctl disable tor.service

# Enable and start the services
systemctl enable apollo-api.service
systemctl start apollo-api.service
systemctl enable apollo-ui-v2.service
systemctl start apollo-ui-v2.service
systemctl enable apollo-miner.service
systemctl enable node.service
systemctl enable ckpool.service


echo -e "${GREEN} ---> Enabled and started apollo services${NC}"

Expand Down
5 changes: 3 additions & 2 deletions backend/update
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ if [ "$EUID" -ne 0 ]
exit
fi

echo "10" > $TMPFILE

systemctl stop ckpool
systemctl stop node
systemctl stop apollo-miner

Expand All @@ -23,8 +26,6 @@ git config --global --add safe.directory $APOLLO_DIR/apolloui-v2

chown -R futurebit $APOLLO_DIR

echo "10" > $TMPFILE

. /usr/local/nvm/nvm.sh

nvm use 21
Expand Down
29 changes: 14 additions & 15 deletions backend/update_system
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ echo -e "${YELLOW} ---> Updating System binaries${NC}"
arch=$(uname -m)

cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-miner $APOLLO_DIR/backend/apollo-miner/futurebit-miner
cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-miner-v2 $APOLLO_DIR/backend/apollo-miner/futurebit-miner-v2
cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-helper $APOLLO_DIR/backend/apollo-miner/

### Bitcoind ###
#########################
cp $APOLLO_DIR/backend/node/bin/$arch/bitcoind $APOLLO_DIR/backend/node/bitcoind
cp $APOLLO_DIR/backend/node/bin/bitcoin.conf $APOLLO_DIR/backend/node/bitcoin.conf
cp $APOLLO_DIR/backend/default-configs/bitcoin.conf $APOLLO_DIR/backend/node/

### Write back the Bitcoin RPC password on conf file
PASS=`sqlite3 $APOLLO_DIR/futurebit.sqlite "SELECT node_rpc_password FROM settings ORDER BY id DESC LIMIT 1;"`
### ckpool ###
#########################
cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/
cp $APOLLO_DIR/backend/default-configs/ckpool.conf $APOLLO_DIR/backend/ckpool/

if [ -z "$PASS" ]
then
echo "Bitcoin password is empty will be generated by the app"
else
sed -i s/rpcpassword=futurebit/rpcpassword=${PASS}/ $APOLLO_DIR/backend/node/bitcoin.conf
fi

# Don't touch below this line
echo "90" > $TMPFILE
Expand All @@ -40,22 +41,20 @@ cp $APOLLO_DIR/backend/systemd/apollo-ui-v2.service /etc/systemd/system/
cp $APOLLO_DIR/backend/systemd/apollo-miner.service /etc/systemd/system/
cp $APOLLO_DIR/backend/systemd/node.service /etc/systemd/system/
cp $APOLLO_DIR/backend/systemd/ckpool.service /etc/systemd/system/
cp $APOLLO_DIR/backend/systemd/swap.service /etc/systemd/system/
cp $APOLLO_DIR/backend/systemd/start_swap.sh $APOLLO_DIR/backend/start_swap.sh

echo -e "${YELLOW} ---> Reloading systemd${NC}"
systemctl daemon-reload

echo -e "${YELLOW} ---> Restarting APP${NC}"
systemctl enable swap
systemctl start swap
systemctl restart node
systemctl restart ckpool
systemctl restart apollo-miner
systemctl restart apollo-api
systemctl restart apollo-miner

#Restart UI after old version of UI finishes update progress
( sleep 1 ; systemctl restart apollo-ui-v2 )
sleep 1

systemctl restart apollo-ui-v2

sleep 3

Expand Down
11 changes: 11 additions & 0 deletions migrations/20240331094452_add_power_led_off.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.up = function (knex, Promise) {
return knex.schema.table('settings', function (t) {
t.boolean('power_led_off').notNull().defaultTo(false);
});
};

exports.down = function (knex, Promise) {
return knex.schema.table('settings', function (t) {
t.dropColumn('power_led_off');
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apolloapi-v2",
"version": "2.0.2",
"version": "2.0.3",
"main": "index.js",
"repository": "https://github.com/jstefanop/apolloapi-v2.git",
"author": "FutureBit LLC",
Expand Down
3 changes: 3 additions & 0 deletions src/configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const generate = async function (pools = null, settings = null ) {
'left_sidebar_extended as leftSidebarExtended',
'right_sidebar_visibility as rightSidebarVisibility',
'temperature_unit as temperatureUnit',
'power_led_off as powerLedOff',
])
.orderBy('created_at', 'desc')
.orderBy('id', 'desc')
Expand Down Expand Up @@ -68,6 +69,8 @@ const generate = async function (pools = null, settings = null ) {
if (fanLow) minerConfig += ` ${fanLow}`;
if (fanHigh) minerConfig += ` ${fanHigh}`;

if (settings.powerLedOff) minerConfig += ` -pwrled off`;

const confDir = `${__dirname}/../backend/apollo-miner`;

try {
Expand Down
10 changes: 5 additions & 5 deletions src/graphql/graphqlModules/Miner/MinerStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports.typeDefs = `
type MinerStatsResult {
stats: [MinerStats]
ckpool: MinerStatsCkpool
}
type MinerStats {
Expand All @@ -24,7 +25,6 @@ module.exports.typeDefs = `
temperature: MinerStatsTemperature
slots: MinerStatsSlots
slaves: [MinerStatsSlave]
ckpool: MinerStatsCkpool
}
type MinerStatsVersion {
Expand Down Expand Up @@ -202,10 +202,10 @@ module.exports.typeDefs = `
hashrate6hr: String
hashrate1d: String
hashrate7d: String
diff: Int
diff: Float
accepted: Int
rejected: Int
bestshare: Int
bestshare: Float
SPS1m: Float
SPS5m: Float
SPS15m: Float
Expand All @@ -222,7 +222,7 @@ module.exports.typeDefs = `
workers: Int
shares: Int
bestshare: Float
bestever: Int
bestever: Float
authorised: Int
worker: [MinerStatsCkpoolWorker]
}
Expand All @@ -237,7 +237,7 @@ module.exports.typeDefs = `
lastshare: Int,
shares: Int,
bestshare: Float,
bestever: Int
bestever: Float
}
`;

Expand Down
1 change: 1 addition & 0 deletions src/graphql/graphqlModules/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports.typeDefs = `
nodeEnableTor: Boolean
nodeUserConf: String
nodeEnableSoloMining: Boolean
powerLedOff: Boolean
}
`

Expand Down
1 change: 1 addition & 0 deletions src/graphql/graphqlModules/Settings/SettingsUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports.typeDefs = `
nodeEnableTor: Boolean
nodeUserConf: String
nodeEnableSoloMining: Boolean
powerLedOff: Boolean
}
type SettingsUpdateOutput {
Expand Down
2 changes: 1 addition & 1 deletion src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const createCkpoolConfigFile = async () => {

if (settings && settings.nodeRpcPassword) {
exec(
`sudo sed -i 's#"pass":.*#"pass": "${settings.nodeRpcPassword}"#g' ${configFilePath}`
`sudo sed -i 's#"pass":.*#"pass": "${settings.nodeRpcPassword}",#g' ${configFilePath}`
);
}
}
Expand Down
35 changes: 22 additions & 13 deletions src/store/api/mcu/mcuUpdateProgress.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
const { join } = require('path')
const { exec } = require('child_process')
const fs = require('fs').promises
const path = require('path')
const _ = require('lodash')
const { join } = require('path');
const { exec } = require('child_process');
const fs = require('fs').promises;
const path = require('path');
const _ = require('lodash');

module.exports = ({ define }) => {
define('updateProgress', async (payload, { knex, errors, utils }) => {
const data = await fs.readFile(`/tmp/update_progress`);
const progress = parseInt(data.toString());
return { value: progress }
}, {
auth: true
})
}
define(
'updateProgress',
async (payload, { knex, errors, utils }) => {
try {
const data = await fs.readFile(`/tmp/update_progress`);
const progress = parseInt(data.toString());
return { value: progress };
} catch (error) {
console.log('updateProgress', error);
return { value: 0 };
}
},
{
auth: true,
}
);
};
Loading

0 comments on commit baecf0d

Please sign in to comment.