mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +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,7 +17,7 @@ shift
|
||||||
# ls -l $GETH
|
# ls -l $GETH
|
||||||
|
|
||||||
# geth CLI params e.g., (dd=04, run=09)
|
# 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
|
datadir=$root/data/$id # /tmp/eth/04
|
||||||
log=$root/log/$id.$datetag.log # /tmp/eth/04.09.log
|
log=$root/log/$id.$datetag.log # /tmp/eth/04.09.log
|
||||||
linklog=$root/log/$id.log # /tmp/eth/04.09.log
|
linklog=$root/log/$id.log # /tmp/eth/04.09.log
|
||||||
|
|
@ -43,8 +43,8 @@ if [ ! -d "$keystoredir" ]; then
|
||||||
# note that the account key will be stored also separately outside
|
# note that the account key will be stored also separately outside
|
||||||
# datadir
|
# datadir
|
||||||
# this way you can safely clear the data directory and still keep your key
|
# this way you can safely clear the data directory and still keep your key
|
||||||
# under `<rootdir>/keystore/dd
|
# under <rootdir>/keystore/dd
|
||||||
# LS=`ls $datadir/keystore`
|
# LS=$(ls $datadir/keystore)
|
||||||
# echo $LS
|
# echo $LS
|
||||||
while [ ! -d "$keystoredir" ]; do
|
while [ ! -d "$keystoredir" ]; do
|
||||||
echo "."
|
echo "."
|
||||||
|
|
@ -57,13 +57,6 @@ if [ ! -d "$keystoredir" ]; then
|
||||||
cp -R "$datadir/keystore/" $root/keystore/$id
|
cp -R "$datadir/keystore/" $root/keystore/$id
|
||||||
fi
|
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
|
# query node's enode url
|
||||||
if [ $ip_addr="" ]; then
|
if [ $ip_addr="" ]; then
|
||||||
pattern='\d+\.\d+\.\d+\.\d+'
|
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 $*
|
||||||
|
|
@ -45,7 +45,7 @@ function attach {
|
||||||
shift
|
shift
|
||||||
echo "attaching console to instance $id"
|
echo "attaching console to instance $id"
|
||||||
cmd="$GETH $* attach ipc:$root/$network_id/data/$id/geth.ipc"
|
cmd="$GETH $* attach ipc:$root/$network_id/data/$id/geth.ipc"
|
||||||
# echo $cmd
|
echo $cmd
|
||||||
eval $cmd
|
eval $cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,6 +58,30 @@ function log {
|
||||||
eval $cmd
|
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 {
|
function less {
|
||||||
id=$1
|
id=$1
|
||||||
shift
|
shift
|
||||||
|
|
@ -319,6 +343,37 @@ function netstatconf {
|
||||||
echo "]" >> $conf
|
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
|
case $cmd in
|
||||||
"info" )
|
"info" )
|
||||||
info $*;;
|
info $*;;
|
||||||
|
|
@ -352,11 +407,25 @@ case $cmd in
|
||||||
cluster $*;;
|
cluster $*;;
|
||||||
"attach" )
|
"attach" )
|
||||||
attach $*;;
|
attach $*;;
|
||||||
|
"cleanbzz" )
|
||||||
|
cleanbzz $*;;
|
||||||
|
"cleanlog" )
|
||||||
|
cleanlog $*;;
|
||||||
"log" )
|
"log" )
|
||||||
log $*;;
|
log $*;;
|
||||||
"less" )
|
"less" )
|
||||||
less $*;;
|
less $*;;
|
||||||
|
"remote-update-scripts" )
|
||||||
|
remote-update-scripts $*;;
|
||||||
|
"remote-update-bin" )
|
||||||
|
remote-update-bin $*;;
|
||||||
|
"update-src" )
|
||||||
|
update-src $*;;
|
||||||
|
"remote-run" )
|
||||||
|
remote-run $*;;
|
||||||
"netstatconf" )
|
"netstatconf" )
|
||||||
netstatconf $*;;
|
netstatconf $*;;
|
||||||
|
"netstatrun" )
|
||||||
|
netstatrun $*;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue