Commit eebdd8fb authored by Jondy Zhao's avatar Jondy Zhao

Start cygserver and syslog-ng service in the slapos-configure script

Start re6stnet in the slapos-configure script
parent 1164037e
......@@ -18,6 +18,8 @@
#
# * cron: create cron configure file
#
# * startup: add this script as startup item
#
# Usage:
#
# ./slapos-configure
......@@ -109,6 +111,28 @@ function show_error_exit()
exit 1
}
function check_service_state()
{
service_name=$1
service_state=$(cygrunsrv --query $service_name | sed -n -e 's/^Current State[ :]*//p')
echo Cygwin $service_name service state: $service_state
if [[ ! x$service_state == "xRunning" ]] ; then
echo Starting $service_name service ...
net start $service_name || show_error_exit "Failed to start $service_name service"
echo Start $service_name service OK.
else
echo Cygwin $service_name service is running.
fi
}
#
# Check ipv6 connection by default ipv6 route
#
function check_ipv6_connection()
{
netsh interface ipv6 show route | grep -q " ::/0 "
}
#
# Query the parameter, usage:
#
......@@ -176,6 +200,7 @@ if (( $? )) ; then
else
echo The cygserver service has been installed.
fi
check_service_state cygserver
echo Checking syslog-ng service ...
cygrunsrv --query syslog-ng > /dev/null 2>&1
......@@ -186,6 +211,7 @@ if (( $? )) ; then
else
echo The syslog-ng service has been installed.
fi
check_service_state syslog-ng
echo Checking cron job ...
ps -ef | grep -q "/usr/sbin/cron"
......@@ -578,6 +604,36 @@ regtool -q get "$slapos_run_key\\$slapos_run_entry" || \
echo Startup item "$slapos_run_key\\$slapos_run_entry": $(regtool get "$slapos_run_key\\$slapos_run_entry")
echo
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo "Checking native IPv6 ..."
check_ipv6_connection
# Run re6stnet if no native ipv6
if (( $? )) ; then
echo "No native IPv6."
echo Check re6stnet network ...
which re6stnet > /dev/null 2>&1 || show_error_exit "Error: no re6stnet installed."
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
# Check if babeld is running, so we guess whether re6stnet is running or not
ps -ef | grep -q babeld.exe
if (( $? )) ; then
echo "Start re6stnet ..."
# It need root rights to install tap-driver
cd /etc/re6stnet
[[ -d /var/log/re6stnet ]] || mkdir -p /var/log/re6stnet
re6stnet @re6stnet.conf --ovpnlog -I $slapos_ifname -i $slapos_ifname >> /var/log/re6stnet/slapos-node.log 2>&1 &
echo $! > /var/run/slapos-node-re6stnet.pid
disown -h
echo "Start re6stent (pid=$!) in the background OK."
echo "You can check log files in the /var/log/re6stnet/."
echo
fi
echo "re6stnet network OK."
else
echo "Native IPv6 Found."
fi
echo SlapOS Node configure successfully.
read -n 1 -t 60 -p "Press any key to exit..."
exit 0
......@@ -59,7 +59,6 @@ check_cygwin_service syslog-ng
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo "Checking native IPv6 ..."
check_ipv6_connection
# Run re6stnet if no native ipv6
......@@ -74,17 +73,17 @@ if (( $? )) ; then
echo "Start re6stnet ..."
# It need root rights to install tap-driver
cd /etc/re6stnet
mkdir -p /var/log/re6stnet
[[ -d /var/log/re6stnet ]] || mkdir -p /var/log/re6stnet
re6stnet @re6stnet.conf --ovpnlog -I $slapos_ifname -i $slapos_ifname >> /var/log/re6stnet/slapos-node.log 2>&1 &
echo $! > /var/run/slapos-node-re6stnet.pid
disown -h
echo "Start re6stent (pid=$!) in the background OK."
echo "You can check log files in the /var/log/re6stnet/."
echo
echo "Waiting re6stent network work ..."
while true ; do
check_ipv6_connection && break
done
# echo "Waiting re6stent network work ..."
# while true ; do
# check_ipv6_connection && break
# done
fi
echo "re6stnet network OK."
else
......
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