-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1459 from OriginTrail/prerelease/testnet
OriginTrail Testnet Release v4.1.17
- Loading branch information
Showing
7 changed files
with
151 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const fs = require('fs'); | ||
require('dotenv').config(); | ||
const defaultConfigJson = require('../config/config.json'); | ||
|
||
const nodercConfigPath = '/ot-node/.origintrail_noderc'; | ||
const v5ConfigPath = '/ot-node/data/.v5_configuration'; | ||
|
||
try { | ||
console.log('Starting configuration update'); | ||
const defaultConfig = defaultConfigJson[process.env.NODE_ENV]; | ||
const configFile = fs.readFileSync(nodercConfigPath); | ||
const config = JSON.parse(configFile); | ||
const { blockchain } = config; | ||
blockchain.blockchain_title = defaultConfig.blockchain.blockchain_title; | ||
blockchain.network_id = defaultConfig.blockchain.network_id; | ||
blockchain.node_wallet = config.node_wallet; | ||
delete config.node_wallet; | ||
blockchain.node_private_key = config.node_private_key; | ||
delete config.node_private_key; | ||
blockchain.management_wallet = config.management_wallet; | ||
delete config.management_wallet; | ||
if (config.erc725_identity_filepath) { | ||
blockchain.identity_filepath = config.erc725_identity_filepath; | ||
delete config.erc725_identity_filepath; | ||
} else { | ||
blockchain.identity_filepath = defaultConfig.erc725_identity_filepath; | ||
} | ||
delete config.blockchain; | ||
|
||
config.blockchain = { | ||
implementations: [blockchain], | ||
}; | ||
fs.writeFileSync(v5ConfigPath, JSON.stringify(config, null, 4)); | ||
console.log('Configuration version 5 generated in data/.v5_configuration'); | ||
} catch (error) { | ||
console.log('Failed to generate configuration version 5', error.message); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function printUsage() { | ||
echo "" | ||
echo "Usage:" | ||
echo " migrate_to_v5.sh [--node_rc_path=<path_to_node_rc_configuration_file>] [--node_container_name=<node_docker_container_name>]" | ||
echo "Options:" | ||
echo " --node_rc_path=<path_to_node_rc_configuration_file> | ||
Specify the path to the node rc configuration file. If node_rc_path option is not passed default one will be used: .origintrail_noderc" | ||
echo " --node_container_name=<node_docker_container_name> | ||
Specify the name of docker container running ot-node. If node_container_name option is not passed default one will be used: otnode" | ||
echo "" | ||
} | ||
|
||
NODE_RC_PATH=".origintrail_noderc" | ||
DOCKER_CONTAINER_NAME="otnode" | ||
|
||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
-h | --help) | ||
printUsage | ||
exit 0 | ||
;; | ||
--node_rc_path=*) | ||
NODE_RC_PATH="${1#*=}" | ||
;; | ||
--node_container_name=*) | ||
DOCKER_CONTAINER_NAME="${1#*=}" | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ ! -f "$NODE_RC_PATH" ]; then | ||
echo "$NODE_RC_PATH does not exist. Please check file path provided. Use -h for help." | ||
exit 0 | ||
fi | ||
|
||
if [ ! "$(docker ps -a --filter status=running | grep $DOCKER_CONTAINER_NAME)" ]; then | ||
echo "Docker container with name: $DOCKER_CONTAINER_NAME, not running or doesn't exists. Use -h for help." | ||
exit 0 | ||
fi | ||
|
||
docker exec ${DOCKER_CONTAINER_NAME} node /ot-node/current/scripts/generate_v5_configuration.js | ||
if [ ! $? -eq 0 ]; then | ||
echo "Failed to generate v5 configuration file" | ||
exit 0 | ||
fi | ||
|
||
cp ${NODE_RC_PATH} .origintrail_noderc_v4_backup | ||
echo "Old configuration saved as .origintrail_noderc_v4_backup." | ||
docker cp ${DOCKER_CONTAINER_NAME}:/ot-node/data/.v5_configuration ./${NODE_RC_PATH} | ||
echo "Starting manual node update to version 5. Please be patient this can take up to 10 minutes." | ||
docker exec ${DOCKER_CONTAINER_NAME} node /ot-node/current/scripts/start_v5_update.js | ||
if [ ! $? -eq 0 ]; then | ||
echo "Failed to manually start v5 update. Restoring old configuration" | ||
mv .origintrail_noderc_v4_backup ${NODE_RC_PATH} | ||
exit 0 | ||
fi | ||
echo "Manual update finalized. Restarting otnode node..." | ||
docker restart ${DOCKER_CONTAINER_NAME} | ||
echo "Update completed successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require('dotenv').config(); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { fork } = require('child_process'); | ||
|
||
const rc = require('rc'); | ||
const pjson = require('../package.json'); | ||
const configjson = require('../config/config.json'); | ||
|
||
const defaultConfig = configjson[process.env.NODE_ENV]; | ||
const config = rc(pjson.name, defaultConfig); | ||
|
||
const updateFilepath = '/ot-node/current/UPDATE'; | ||
const destinationBasedir = '/ot-node/'; | ||
|
||
const updater = fork(path.join(__dirname, '..', 'testnet', 'prepare-update.js'), [], { | ||
stdio: [0, 1, 2, 'ipc'], | ||
}); | ||
|
||
updater.on('message', async (result) => { | ||
if (result.status !== 'completed') { | ||
// Something went wrong. | ||
console.log(`Failed to prepare update. Status: ${result.status}.`); | ||
process.exit(1); | ||
} | ||
|
||
console.log(`Update ready for version ${result.version}.`); | ||
fs.writeFileSync(updateFilepath, JSON.stringify({ | ||
version: result.version, | ||
path: result.installDir, | ||
configPath: config.appDataPath, | ||
})); | ||
}).on('error', (error) => { | ||
console.log(`Failed to check prepare update. ${error}`); | ||
process.exit(1); | ||
}); | ||
|
||
|
||
const options = { | ||
archiveUrl: config.autoUpdater.archiveUrl, | ||
destinationBaseDir: destinationBasedir, | ||
}; | ||
|
||
updater.send(options); |