mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
swarm/cmd: add cleanlog, cleanbzz, update-src, remote-update-scripts, remote-update-bin, remote-run
This commit is contained in:
parent
0e23886184
commit
c6205b2244
4 changed files with 87 additions and 14 deletions
9
swarm/cmd/swarm/env.sh
Normal file
9
swarm/cmd/swarm/env.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export GOPATH=~/go
|
||||
export PATH=~/bin:$GOPATH/bin:$PATH
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
export NVM_DIR="/home/ubuntu/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
|
|
@ -17,13 +17,13 @@ shift
|
|||
# ls -l $GETH
|
||||
|
||||
# geth CLI params e.g., (dd=04, run=09)
|
||||
datetag=`date "+%c%y%m%d-%H%M%S"|cut -d ' ' -f 5`
|
||||
datetag=`date "+%Y-%m-%d-%H:%M:%S"`
|
||||
datadir=$root/data/$id # /tmp/eth/04
|
||||
log=$root/log/$id.$datetag.log # /tmp/eth/04.09.log
|
||||
linklog=$root/log/$id.log # /tmp/eth/04.09.log
|
||||
password=$id # 04
|
||||
port=303$id # 34504
|
||||
bzzport=322$id # 32204
|
||||
bzzport=322$id # 3 2204
|
||||
rpcport=302$id # 3204
|
||||
|
||||
mkdir -p $root/data
|
||||
|
|
@ -43,8 +43,8 @@ if [ ! -d "$keystoredir" ]; then
|
|||
# note that the account key will be stored also separately outside
|
||||
# datadir
|
||||
# this way you can safely clear the data directory and still keep your key
|
||||
# under `<rootdir>/keystore/dd
|
||||
# LS=`ls $datadir/keystore`
|
||||
# under <rootdir>/keystore/dd
|
||||
# LS=$(ls $datadir/keystore)
|
||||
# echo $LS
|
||||
while [ ! -d "$keystoredir" ]; do
|
||||
echo "."
|
||||
|
|
@ -57,13 +57,6 @@ if [ ! -d "$keystoredir" ]; then
|
|||
cp -R "$datadir/keystore/" $root/keystore/$id
|
||||
fi
|
||||
|
||||
# # mkdir -p $datadir/keystore
|
||||
# if [ ! -d "$datadir/keystore" ]; then
|
||||
# echo "copying keys $root/keystore/$id $datadir/keystore"
|
||||
# cp -R $root/keystore/$id/keystore/ $datadir/keystore/
|
||||
# fi
|
||||
|
||||
|
||||
# query node's enode url
|
||||
if [ $ip_addr="" ]; then
|
||||
pattern='\d+\.\d+\.\d+\.\d+'
|
||||
|
|
|
|||
2
swarm/cmd/swarm/swarm
Executable file
2
swarm/cmd/swarm/swarm
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
bash ~/bin/swarm.sh $SWARM_DIR $SWARM_NETWORK_ID $*
|
||||
|
|
@ -44,8 +44,8 @@ function attach {
|
|||
id=$1
|
||||
shift
|
||||
echo "attaching console to instance $id"
|
||||
cmd="$GETH $* attach ipc:$root/$network_id/data/$id/geth.ipc"
|
||||
# echo $cmd
|
||||
cmd="$GETH $* attach ipc:$root/$network_id/data/$id/geth.ipc"
|
||||
echo $cmd
|
||||
eval $cmd
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +58,30 @@ function log {
|
|||
eval $cmd
|
||||
}
|
||||
|
||||
function cleanlog {
|
||||
id=$1
|
||||
shift
|
||||
if [ $id = "all" ]; then
|
||||
echo "remove logs for all instances"
|
||||
rm -rf "$root/$network_id/log/"
|
||||
else
|
||||
echo "remove logs for instance $id"
|
||||
rm -rf $root/$network_id/log/$id*
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanbzz {
|
||||
id=$1
|
||||
shift
|
||||
if [ $id = "all" ]; then
|
||||
echo "remove bzz data for all instances"
|
||||
rm -rf $root/$network_id/data/*/bzz
|
||||
else
|
||||
echo "remove bzz data for instance $id"
|
||||
rm -rf "$root/$network_id/data/$id"
|
||||
fi
|
||||
}
|
||||
|
||||
function less {
|
||||
id=$1
|
||||
shift
|
||||
|
|
@ -319,6 +343,37 @@ function netstatconf {
|
|||
echo "]" >> $conf
|
||||
}
|
||||
|
||||
function remote-update-scripts {
|
||||
scriptdir=$1
|
||||
remotes=$2
|
||||
cd $GETH_DIR
|
||||
for remote in `cat $remotes|grep -v '^#'`; do echo "updating scripts on $remote..."; ssh $remote mkdir -p bin && scp -r $scriptdir/* $remote:bin/; done
|
||||
}
|
||||
|
||||
function remote-update-bin {
|
||||
remote-update-scripts ~/bin $remotes
|
||||
for remote in `cat $remotes|grep -v '^#'`; do echo "updating binary on $remote..."; scp -r $GETH_DIR/geth $remote:bin/; done
|
||||
}
|
||||
|
||||
function remote-run {
|
||||
remotes=$1
|
||||
shift
|
||||
for remote in `cat $remotes|grep -v '^#'`; do echo "running on $remote..."; ssh $remote ". ~/bin/env.sh; $*"; done
|
||||
}
|
||||
|
||||
function update-src {
|
||||
branch=$1
|
||||
echo "cd $GETH_DIR && git remote update && git reset --hard $branch"
|
||||
(cd $GETH_DIR && git remote update && git reset --hard $branch)
|
||||
}
|
||||
|
||||
function netstatrun {
|
||||
cd ~/eth-net-intelligence-api
|
||||
pm2 kill
|
||||
pm2 start $root/$network_id/*.netstat.json
|
||||
}
|
||||
|
||||
|
||||
case $cmd in
|
||||
"info" )
|
||||
info $*;;
|
||||
|
|
@ -352,11 +407,25 @@ case $cmd in
|
|||
cluster $*;;
|
||||
"attach" )
|
||||
attach $*;;
|
||||
"cleanbzz" )
|
||||
cleanbzz $*;;
|
||||
"cleanlog" )
|
||||
cleanlog $*;;
|
||||
"log" )
|
||||
log $*;;
|
||||
"less" )
|
||||
less $*;;
|
||||
"netstatconf" )
|
||||
"remote-update-scripts" )
|
||||
remote-update-scripts $*;;
|
||||
"remote-update-bin" )
|
||||
remote-update-bin $*;;
|
||||
"update-src" )
|
||||
update-src $*;;
|
||||
"remote-run" )
|
||||
remote-run $*;;
|
||||
"netstatconf" )
|
||||
netstatconf $*;;
|
||||
"netstatrun" )
|
||||
netstatrun $*;;
|
||||
|
||||
esac
|
||||
|
|
|
|||
Loading…
Reference in a new issue