Commit 683ae427 authored by Jondy Zhao's avatar Jondy Zhao

Change slapos node init behaviour

parent dfd6872f
...@@ -4,65 +4,36 @@ ...@@ -4,65 +4,36 @@
# #
# 1. Start re6stnet, # 1. Start re6stnet,
# #
# 2. Check whether IPv6 connection is availabe # 2. Run slapformat to synchornize information with master
# #
# 3. Run slapformat to synchornize information with master # 3. Start slapproxy
# #
# 4. Start slapproxy, it will used by slapos desktop and node manager # 4.
# #
# Get connection name by GUID name, for example ifname=re6stnet-lo
#
# $ guid2name {C8D7F065-AD35-4777-A768-122451282533}
#
function guid2name()
{
if [[ "$1" == "" ]] ; then
echo
else
netsh interface ipv6 show interface level=verbose | \
grep -B 1 "$1" | \
grep "^Connection" | \
sed -e "s/^Connection Name\\s*:\\s*//g"
fi
}
# Default node configure filename # Run re6stnet
cfilename=${1-/etc/opt/slapos/slapos.cfg} echo "Start re6stnet ..."
(cd /etc/re6stnet; re6stnet @re6stnet.conf -I $ifname -i $ifname &)
echo "Start re6stent (pid:$!)in the background OK."
if [[ ! -f $cfilename ]] ; then # echo "Waiting re6stent network work ..."
echo "Error: no found configure file $cfilename, the computer " # while true ; do
echo "need register as a SlapOS Node first." # ping6 slap.vifib.com > /dev/null && break
exit 1 # done
fi # echo "re6stnet network OK."
interface=$(grep "^interface_name\\s*=" $cfilename | \ # Run slapformat
sed -e "s/^interface_name\\s*=\\s*//g") echo "Initializing SlapOS Node ..."
if (( $? == 0 )) ; then /bin/bash --login -i /opt/slapos/bin/slapos node format -c --now
ifname=$(guid2name $interface) if (( $? )) ; then
echo "Initialize SlapOS Node failed."
else else
echo "Error: no interface found in the configure file $cfilename" echo "Initialize SlapOS Node OK."
exit 1
fi
if [[ "$ifname" == "" ]]; then
echo "Error: no ipv6 interface found in the configure file $cfilename"
exit 1
fi fi
# Run re6stnet, waiting until it works
cd /etc/re6stnet
re6stnet @re6stnet.conf -I $ifname -i $ifname
echo "Waiting re6stent network work ..."
while true ; do
ping6 slap.vifib.com > /dev/null && break
done
echo "re6stnet network OK."
# Run slapformat
/opt/slapos/bin/slapos node format -cv --now || \
( echo "Initialize SlapOS Node failed."; exit 1 )
echo "Initialize SlapOS Node OK."
# Run slapproxy # Run slapproxy
/opt/slapos/bin/slapproxy || echo "Start slapproxy failed." # /opt/slapos/bin/slapproxy || echo "Start slapproxy failed."
exit 0
...@@ -259,16 +259,31 @@ grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf ...@@ -259,16 +259,31 @@ grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf
# Add run item when windows startup # Add run item when windows startup
# #
init_script=/etc/slapos/scripts/init-slapos-node init_script=/etc/slapos/scripts/init-slapos-node
password_file=/etc/passwd
password_orig=/etc/slapos-format-passwd.orig
cygroot=$(cygpath -w -a /)
echo "Add ${init_script}.sh as Windows startup item." echo "Add ${init_script}.sh as Windows startup item."
# if [[ ! -f ${init_script}.bat ]] ; then [[ -f ${init_script}.bat ]] && cat <<EOF > ${init_script}.bat
# cat <<EOF > ${init_script}.bat @ECHO OFF
# "$(cygpath -w /usr/bin/bash)" --login -i ${init_script}.sh SETLOCAL
# EXIT 0
# EOF
# fi
${cygroot:0:2}
CD "$(cygpath -w /usr/bin)"
.\cp $password_file $password_orig
.\sed -i -e "s/^Administrator:unused:500:513/Administrator:unused:0:513/" $password_file
START /B bash --login -i "${init_script}.sh"
.\sleep 3
.\cp $password_orig $password_file
ENDLOCAL
EXIT 0
EOF
# regtool -q set "$run_key\\$slapos_run_entry" \
# "\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \
# show_error_exit "Add startup item failed."
regtool -q set "$run_key\\$slapos_run_entry" \ regtool -q set "$run_key\\$slapos_run_entry" \
"\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \ "\"$(cygpath -w ${init_script}.bat)\"" || \
show_error_exit "Add startup item failed." show_error_exit "Add startup item failed."
echo SlapOS Node configure successfully. echo SlapOS Node configure successfully.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment