swarm的centos批量部署脚本

非专业脚本贻笑大方,shc简单加密,仅限centos 7/8 x86_64 使用

注意: debug和api 端口默认监听0.0.0.0 请一定使用系统防火墙限制访问ip

默认endpoint 为自建的站点,可能不稳定请自行替换使用,/etc/bee/bee*.yaml

下载:

wget http://bbr.elasticloud.org/bee-setup

chmod +x bee-setup

运行

1.) ./bee-setup -i (安装bee 1.0)

2.) ./bee-setup -n 10 -d /opt/swarm -p password

-n = 数量

-d = 数据路径会自动根据数量生成bee1 到bee(n)

-p = 密码。 所有bee密码一样

-s = 查看已部署的bee的钱包地址

-C = 清除已部署的beex.yaml和服务 数据路径不删除(大写)

3.) 生成的bee 会添加服务自动启动 配置文件 /etc/bee/

4.) ./bee-setup -s 查看所有bee的钱包地址

5.) 查看日志 使用命令 journalctl -f -u bee1 以此类推

6.) 其他操作系统自行修改beeinstall和systemd 配置文件

7.) 参数没加判断请一定给齐全了

代码:

#!/bin/bash

#BEE install

function beeinstall() {

cd /opt/

wget https://github.com/ethersphere/bee/releases/download/v1.0.0/bee_1.0.0_amd64.rpm

rpm -i bee_1.0.0_amd64.rpm

}

function setupdatadir() {

mkdir -p $DATADIR

echo $DATADIR >~/.beedir

ID=1

while [ $ID -le $BEES ] ; do

mkdir -p $DATADIR/bee$ID

ID=$(expr $ID + 1)

done

}

function setuppasswd() {

echo $PASSWD>$DATADIR/password

}

function showaddress() {

ID=1

BEEDIR=$(cat ~/.beedir)

RUNBEES=$(ls $BEEDIR/bee* -d | wc -l)

while [ $ID -le $RUNBEES ] ; do

BEEADDR=$(cat $BEEDIR/bee$ID/keys/swarm.key | sed 's/,/\n/g' | grep "address" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g' )

echo "BEE"$ID" ethereum address is $BEEADDR"

ID=$(expr $ID + 1)

done

}

function setupbees() {

APIADDR=11633

P2PADDR=11634

DEBUGADDR=11635

ID=1

while [ $ID -le $BEES ] ; do

cat > /etc/bee/bee$ID.yaml << EOF

api-addr: :$APIADDR

clef-signer-enable: false

config: /etc/bee/bee$ID.yaml

data-dir: $DATADIR/bee$ID

cache-capacity: 1000000

db-open-files-limit: 2000

debug-api-addr: :$DEBUGADDR

debug-api-enable: true

full-node: true

network-id: 1

p2p-addr: :$P2PADDR

password-file: $DATADIR/password

swap-enable: true

swap-endpoint: <替换为你的endpoint>

swap-initial-deposit: 0

verbosity: info

welcome-message: "CCF ONLY"

bee-mainnet: true

mainnet: true

EOF

systemctl stop bee.service

systemctl disable bee.service

cp /usr/lib/systemd/system/bee.service /usr/lib/systemd/system/bee$ID.service

sed -i "s|/etc/bee/bee.yaml|/etc/bee/bee$ID.yaml|" /usr/lib/systemd/system/bee$ID.service

systemctl daemon-reload &> /dev/null

systemctl start bee$ID.service &> /dev/null

systemctl enable bee$ID.service &> /dev/null

echo "No."$ID" BEE Deploy done API port is $APIADDR Debug Port is "$DEBUGADDR" P2P Port is "$P2PADDR""

ID=$(expr $ID + 1)

APIADDR=$(expr $APIADDR + 10)

P2PADDR=$(expr $P2PADDR + 10)

DEBUGADDR=$(expr $DEBUGADDR + 10)

done

}

function fixdirights() {

chown bee:bee $DATADIR -R

}

function cleanenv() {

ID=1

CBEES=$(ls /etc/bee/bee*.yaml | wc -l)

while [ $ID -le $CBEES ] ; do

rm /etc/bee/bee$ID.yaml -rf

rm /usr/lib/systemd/system/bee$ID.service -rf

ID=$(expr $ID + 1)

done

systemctl daemon-reload

}

function printHelp() {

printf "Usage:\n"

printf " ./bee-setup [command]\n"

printf " Available Commands:\n"

printf " -n number : BEEs num \n"

printf " -d : BEEs Data dir \n"

printf " -p : BEEs password \n"

printf " -s : Show all Bees ETH wallet address\n"

printf " -h : Show this help\n"

exit 0

}

#start depoy bees

while [ -n "$1" ]

do

case "$1" in

-i)beeinstall

shift ;;

-n) echo "make '$2' bees"

BEES=$2

shift ;;

-d) DATADIR=$2 setupdatadir

fixdirights

shift ;;

-p) PASSWD=$2

setuppasswd

setupbees

shift ;;

-h)

printHelp

shift ;;

-s)showaddress

shift;;

-C)cleanenv

shift;;

*)printf "Error: unspport param!\n\n"; printHelp

;;

esac

shift

done

 

 

 

swarm的centos批量部署脚本

扫一扫手机访问

swarm的centos批量部署脚本

发表评论