diff --git a/config.yaml b/config.yaml index 5b08693..973ffe8 100644 --- a/config.yaml +++ b/config.yaml @@ -11,9 +11,9 @@ node: ## identity configurations identity: - ## the backup of chain controller account + ## the backup of chain account backup: '' - ## the password of chain controller account + ## the password of chain account password: "" ## chain configurations diff --git a/scripts/online_install.sh b/scripts/online_install.sh index 13fda3b..d1b4895 100755 --- a/scripts/online_install.sh +++ b/scripts/online_install.sh @@ -1,6 +1,7 @@ #!/bin/bash version=$1 +shift if [ $(id -u) -ne 0 ]; then echo "Please run with sudo!" @@ -20,7 +21,7 @@ if [ $res -ne 0 ]; then exit 1 fi -./crust-node-$version/install.sh +./crust-node-$version/install.sh $@ if [ $res -ne 0 ]; then echo "Install crust node $version failed" rm v$version.tar.gz diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh deleted file mode 100755 index 41d41e7..0000000 --- a/scripts/upgrade.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -scriptdir=$(cd `dirname $0`;pwd) -basedir=$(cd $scriptdir/..;pwd) -config_file=$basedir/build/sworker/sworker_config.json -builddir=$basedir/build - -source $scriptdir/utils.sh - -function upgrade_sworker() -{ - echo "upgrade...." - - upgrade_docker_image crustio/crust-sworker - if [ $? -ne 0 ]; then - return 1 - fi - - local a_or_b=`cat $basedir/etc/sWorker.ab` - if [ x"$a_or_b" = x"a" ]; then - a_or_b='b' - else - a_or_b='a' - fi - - check_docker_status crust-sworker-a - local resa=$? - check_docker_status crust-sworker-b - local resb=$? - - if [ $resa -eq 0 ] && [ $resb -eq 0 ] ; then - log_info "sworker A/B upgrade is running..." - return 0 - fi - - docker stop crust-sworker-$a_or_b &>/dev/null - docker rm crust-sworker-$a_or_b &>/dev/null - EX_SWORKER_ARGS=--upgrade docker-compose -f $builddir/docker-compose.yaml up -d crust-sworker-$a_or_b - if [ $? -ne 0 ]; then - echo "setup new sworker failed" - return 1 - fi - - if [ x"$a_or_b" = x"a" ]; then - sed -i 's/b/a/g' $basedir/etc/sWorker.ab - else - sed -i 's/a/b/g' $basedir/etc/sWorker.ab - fi - - echo "update start..., setup new sworker 'crust-sworker-$a_or_b'" -} - -if [ x"$config_file" = x"" ]; then - echo "please give right config file" - exit 1 -fi - -api_base_url=`cat $config_file | jq .chain.base_url` -sworker_base_url=`cat $config_file | jq .base_url` - -if [ x"$api_base_url" = x"" ] || [ x"$sworker_base_url" = x"" ]; then - echo "please give right config file" - exit 1 -fi - -api_base_url=`echo "$api_base_url" | sed -e 's/^"//' -e 's/"$//'` -sworker_base_url=`echo "$sworker_base_url" | sed -e 's/^"//' -e 's/"$//'` - -echo "wait 100s for sworker to start" -sleep 100s -while : -do - -system_health=`curl --max-time 30 $api_base_url/system/health 2>/dev/null` -if [ x"$system_health" = x"" ]; then - echo "please run crust chain and api" - sleep 60 - continue -fi - -is_syncing=`echo $system_health | jq .isSyncing` -if [ x"$is_syncing" = x"" ]; then - echo "crust api dose not connet to crust chain" - sleep 60 - continue -fi - -if [ x"$is_syncing" = x"true" ]; then - echo "crust chain is syncing" - sleep 60 - continue -fi - -code=`curl --max-time 30 $api_base_url/swork/code 2>/dev/null` -if [ x"$code" = x"" ]; then - echo "please run chain and api" - sleep 60 - continue -fi - -if [[ ! "$code" =~ ^\"0x.* ]]; then - echo "please run chain and api" - sleep 60 - continue -fi - -code=`echo ${code: 3: 64}` -echo "sWorker code on chain: $code" - -id_info=`curl --max-time 30 $sworker_base_url/enclave/id_info 2>/dev/null` -if [ x"$id_info" = x"" ]; then - echo "please run sworker" - sleep 60 - continue -fi - -mrenclave=`echo $id_info | jq .mrenclave` -if [ x"$mrenclave" = x"" ]; then - echo "waiting sworker ready" - sleep 60 - continue -fi -mrenclave=`echo ${mrenclave: 1: 64}` - -echo "sWorker self code: $mrenclave" - -if [ x"$mrenclave" != x"$code" ] && [ ${#mrenclave} -eq ${#code} ]; then - upgrade_sworker -fi - -sleep 60 -done