// IP address format: 192.168.137.*
// 测试数据
const conf_default = "<需要执行的配置名称>"
// 时钟主节点
const master = 40
const hosts = {
device: [43, 44],
switch: [40, 41],
}
安装好需要的依赖:
```bash
sudo npm install -g [email protected]
pip install -r requirements.txt
npm install
配置好环境变量,在.bashrc中加入:
export PYTHONPATH="/home/<用户名>/scripts"
(记得提前配置好树莓派和所有板子之间的ssh public key,方便免密登录)
./batch.mjs clone
默认时master分支,如果需要指定分支,需要修改batch.mjs文件中的pull()函数,具体参考注释的部分
// pull all the latest code
const pull = async () => {
cd(`${os.homedir()}/repos`)
// 如果需要指定分支,类似下面指定qbv-test分支的操作
// await $`cd pkt_gen_app; git stash; git checkout qbv-test; git pull origin qbv-test; cd ..`
// await $`cd time_sync_app; git stash; git checkout qbv-test; git pull origin qbv-test; cd ..`
await Promise.all(hosts.all.map(host => {
const type = hosts.device.includes(host) ? 'device' : 'switch'
if (type === 'device') {
return $`rsync -avPh ${os.homedir}/repos/pkt_gen_app [email protected].${host}:~/`
} else if (type === 'switch') {
return $`rsync -avPh ${os.homedir}/repos/time_sync_app [email protected].${host}:~/;`
}
}))
}
同步到所有板子上:
./batch.mjs pull
./batch.mjs build
./batch.mjs distribute
./batch.mjs launch
./batch.mjs collect