|
|
@ -49,6 +49,15 @@ function myip() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function check_root |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then |
|
|
|
|
|
|
|
msg "this script must be run as root to setup environment" |
|
|
|
|
|
|
|
msg please use \"sudo ${progname}\" |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function add_env |
|
|
|
function add_env |
|
|
|
{ |
|
|
|
{ |
|
|
|
filename=$1 |
|
|
|
filename=$1 |
|
|
@ -58,6 +67,8 @@ function add_env |
|
|
|
|
|
|
|
|
|
|
|
function setup_env |
|
|
|
function setup_env |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
check_root |
|
|
|
|
|
|
|
|
|
|
|
# setup environment variables, may not be nessary |
|
|
|
# setup environment variables, may not be nessary |
|
|
|
sysctl -w net.core.somaxconn=1024 |
|
|
|
sysctl -w net.core.somaxconn=1024 |
|
|
|
sysctl -w net.core.netdev_max_backlog=65536 |
|
|
|
sysctl -w net.core.netdev_max_backlog=65536 |
|
|
@ -78,20 +89,18 @@ function setup_env |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
######## main ######### |
|
|
|
######## main ######### |
|
|
|
if [[ $EUID -ne 0 ]]; then |
|
|
|
|
|
|
|
msg "this script must be run as root" |
|
|
|
|
|
|
|
msg please use \"sudo $0\" |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print_usage() { |
|
|
|
print_usage() { |
|
|
|
cat <<- ENDEND |
|
|
|
cat <<- ENDEND |
|
|
|
|
|
|
|
|
|
|
|
usage: ${progname} [-1ch] [-k KEYFILE] |
|
|
|
usage: ${progname} [-1ch] [-k KEYFILE] |
|
|
|
-c back up database/logs and start clean |
|
|
|
-c back up database/logs and start clean |
|
|
|
(use only when directed by Harmony) |
|
|
|
(use only when directed by Harmony) |
|
|
|
-1 do not loop; run once and exit |
|
|
|
-1 do not loop; run once and exit |
|
|
|
-h print this help and exit |
|
|
|
-h print this help and exit |
|
|
|
-k KEYFILE use the given BLS key file (default: autodetect) |
|
|
|
-k KEYFILE use the given BLS key file (default: autodetect) |
|
|
|
|
|
|
|
-s run setup env only (must run as root) |
|
|
|
|
|
|
|
-S run the ${progname} as non-root user (default: run as root) |
|
|
|
|
|
|
|
|
|
|
|
ENDEND |
|
|
|
ENDEND |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -101,14 +110,15 @@ usage() { |
|
|
|
exit 64 # EX_USAGE |
|
|
|
exit 64 # EX_USAGE |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unset start_clean loop |
|
|
|
unset start_clean loop run_as_root |
|
|
|
start_clean=false |
|
|
|
start_clean=false |
|
|
|
loop=true |
|
|
|
loop=true |
|
|
|
|
|
|
|
run_as_root=true |
|
|
|
${BLSKEYFILE=} |
|
|
|
${BLSKEYFILE=} |
|
|
|
|
|
|
|
|
|
|
|
unset OPTIND OPTARG opt |
|
|
|
unset OPTIND OPTARG opt |
|
|
|
OPTIND=1 |
|
|
|
OPTIND=1 |
|
|
|
while getopts :1chk: opt |
|
|
|
while getopts :1chk:sS opt |
|
|
|
do |
|
|
|
do |
|
|
|
case "${opt}" in |
|
|
|
case "${opt}" in |
|
|
|
'?') usage "unrecognized option -${OPTARG}";; |
|
|
|
'?') usage "unrecognized option -${OPTARG}";; |
|
|
@ -117,6 +127,8 @@ do |
|
|
|
1) loop=false;; |
|
|
|
1) loop=false;; |
|
|
|
h) print_usage; exit 0;; |
|
|
|
h) print_usage; exit 0;; |
|
|
|
k) BLSKEYFILE="${OPTARG}";; |
|
|
|
k) BLSKEYFILE="${OPTARG}";; |
|
|
|
|
|
|
|
s) setup_env; exit 0;; |
|
|
|
|
|
|
|
S) run_as_root=false ;; |
|
|
|
*) err 70 "unhandled option -${OPTARG}";; # EX_SOFTWARE |
|
|
|
*) err 70 "unhandled option -${OPTARG}";; # EX_SOFTWARE |
|
|
|
esac |
|
|
|
esac |
|
|
|
done |
|
|
|
done |
|
|
@ -128,6 +140,10 @@ case $# in |
|
|
|
;; |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ${run_as_root}; then |
|
|
|
|
|
|
|
check_root |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
case "${BLSKEYFILE}" in |
|
|
|
case "${BLSKEYFILE}" in |
|
|
|
"") |
|
|
|
"") |
|
|
|
unset -v f |
|
|
|
unset -v f |
|
|
@ -193,7 +209,9 @@ NODE_PORT=9000 |
|
|
|
PUB_IP= |
|
|
|
PUB_IP= |
|
|
|
|
|
|
|
|
|
|
|
if [ "$OS" == "Linux" ]; then |
|
|
|
if [ "$OS" == "Linux" ]; then |
|
|
|
|
|
|
|
if ${run_as_root}; then |
|
|
|
setup_env |
|
|
|
setup_env |
|
|
|
|
|
|
|
fi |
|
|
|
# Kill existing soldier/node |
|
|
|
# Kill existing soldier/node |
|
|
|
fuser -k -n tcp $NODE_PORT |
|
|
|
fuser -k -n tcp $NODE_PORT |
|
|
|
fi |
|
|
|
fi |
|
|
|