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

Change slapos node init behaviour

parent dfd6872f
......@@ -4,65 +4,36 @@
#
# 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
#
# $ 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
}
ifname=re6stnet-lo
# Default node configure filename
cfilename=${1-/etc/opt/slapos/slapos.cfg}
# Run re6stnet
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 "Error: no found configure file $cfilename, the computer "
echo "need register as a SlapOS Node first."
exit 1
fi
# echo "Waiting re6stent network work ..."
# while true ; do
# ping6 slap.vifib.com > /dev/null && break
# done
# echo "re6stnet network OK."
interface=$(grep "^interface_name\\s*=" $cfilename | \
sed -e "s/^interface_name\\s*=\\s*//g")
if (( $? == 0 )) ; then
ifname=$(guid2name $interface)
# Run slapformat
echo "Initializing SlapOS Node ..."
/bin/bash --login -i /opt/slapos/bin/slapos node format -c --now
if (( $? )) ; then
echo "Initialize SlapOS Node failed."
else
echo "Error: no interface found in the configure file $cfilename"
exit 1
fi
if [[ "$ifname" == "" ]]; then
echo "Error: no ipv6 interface found in the configure file $cfilename"
exit 1
echo "Initialize SlapOS Node OK."
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
/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
# Add run item when windows startup
#
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."
# if [[ ! -f ${init_script}.bat ]] ; then
# cat <<EOF > ${init_script}.bat
# "$(cygpath -w /usr/bin/bash)" --login -i ${init_script}.sh
# EXIT 0
# EOF
# fi
[[ -f ${init_script}.bat ]] && cat <<EOF > ${init_script}.bat
@ECHO OFF
SETLOCAL
${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" \
"\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \
"\"$(cygpath -w ${init_script}.bat)\"" || \
show_error_exit "Add startup item failed."
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