Commit 3a7bd752 authored by Jondy Zhao's avatar Jondy Zhao

Move slapos-webrunner configuration to slapos-node script

parent 390e04a2
...@@ -113,7 +113,7 @@ Then waiting for configure script finished. Be sure the configure scrip report s ...@@ -113,7 +113,7 @@ Then waiting for configure script finished. Be sure the configure scrip report s
<section><title>SlapOS Runner</title> <section><title>SlapOS Runner</title>
<para>SlapOS Runner is a web based development tool which uses slapgrid to install the software, and it could be used to manage your slapos slave node in your computer.</para> <para>SlapOS Runner is a web based development tool which uses slapgrid to install the software, and it could be used to manage your slapos slave node in your computer.</para>
<para>After installing slapos, Node Runner isn't available. You need run Configure SlapOS first. After that, Node Runner would be available.</para> <para>After installing slapos, Node Runner isn't available. You need run SlapOS Node first. After that, Node Runner would be available.</para>
<para>Refer to <ulink url="http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Howto.Use.SlapOS.Web.Runner.html5"/></para> <para>Refer to <ulink url="http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Howto.Use.SlapOS.Web.Runner.html5"/></para>
</section> </section>
<section><title>Command Console</title> <section><title>Command Console</title>
......
<html> <html>
<head><title>SlapOS Web Runner</title></head> <head><title>SlapOS Webrunner</title></head>
<body>Sorry, SlapOS Web Runner isn't installed now. Please run Configure Slapos at first by clicking Start -> SlapOS -> Configure SlapOS. Be sure to run it as Administrator in the Windows 7.</body> <body>Sorry, SlapOS Web Runner isn't installed now. Please run SlapOS Node at first by clicking Start -> SlapOS -> SlapOS Node. Be sure to run it as Administrator in the Windows 7.</body>
</html> </html>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# Usage: # Usage:
# #
# ./slapos-configure [--install | --query | --overwrite | --uninstall] # ./slapos-configure [--install | --query | --overwrite | --uninstall]
# [ * | re6stnet | taps | config | cron | startup | runner] # [ * | re6stnet | taps | config | cron ]
# #
# The action option: # The action option:
# #
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
# taps Install OpenVPN Tap-Windows Driver for re6stnet # taps Install OpenVPN Tap-Windows Driver for re6stnet
# config Generate slapos node and client configure files # config Generate slapos node and client configure files
# cron Generate cron file and start cron job # cron Generate cron file and start cron job
# runner Install web runner for this node
# #
source $(/usr/bin/dirname $0)/slapos-include.sh source $(/usr/bin/dirname $0)/slapos-include.sh
...@@ -450,91 +449,6 @@ echo ...@@ -450,91 +449,6 @@ echo
echo Configure section taps OK. echo Configure section taps OK.
echo echo
# -----------------------------------------------------------
# runner: Create instance of slap web runner
# -----------------------------------------------------------
echo
echo Starting configure section runner ...
echo
slaprunner_title="SlapOS-Node-Runner-In-$computer_guid"
feature_code="#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
if ! grep -q -F "$feature_code" $slaprunner_startup_file ; then
echo Installing SlapOS Web Runner ...
if [[ -r $re6stnet_configure_file ]] ; then
re6stnet_ipv6=$(grep "Your subnet" $re6stnet_configure_file| \
sed -e "s/^.*subnet: //g" -e "s/\/80 (CN.*\$/1/g")
if [[ ! -z "$re6stnet_ipv6" ]] ; then
echo "Re6stnet address in this computer: $re6stnet_ipv6"
netsh interface ipv6 show addr $slapos_ifname level=normal | \
grep -q $re6stnet_ipv6 || \
netsh interface ipv6 add addr $slapos_ifname $re6stnet_ipv6
fi
fi
/opt/slapos/bin/slapos node format -cv --now || \
csih_error "Failed to run slapos format."
echo "Supply slapwebrunner in the computer $computer_guid"
/opt/slapos/bin/slapos supply slaposwebrunner $computer_guid
echo "Request an instance $slaprunner_title ..."
patch_file=/etc/slapos/patches/slapos-cookbook-inotifyx.patch
while true ; do
/opt/slapos/bin/slapos node software --verbose
# Apply patches to slapos.cookbook for inotifix
if [[ -r $patch_file ]] ; then
for x in $(find /opt/slapgrid/ -name slapos.cookbook-*.egg) ; do
echo Apply patch $patch_file at $x
cd $x
patch -f --dry-run -p1 < $patch_file > /dev/null && \
patch -p1 < $patch_file
done
fi
/opt/slapos/bin/slapos node instance --verbose
/opt/slapos/bin/slapos node report --verbose
/opt/slapos/bin/slapos request $client_config_file $slaprunner_title \
slaposwebrunner --node computer_guid=$computer_guid && break
sleep 3
done
# Connection parameters of instance are:
# {'backend_url': 'http://[2001:67c:1254:45::c5d5]:50000',
# 'cloud9-url': 'http://localhost:9999',
# 'password_recovery_code': 'e2d01c14',
# 'ssh_command': 'ssh 2001:67c:1254:45::c5d5 -p 2222',
# 'url': 'http://softinst39090.host.vifib.net/'}
slaprunner_url=$(/opt/slapos/bin/slapos request $client_config_file \
$slaprunner_title slaposwebrunner --node computer_guid=$computer_guid | \
grep backend_url | sed -e "s/^.*': '//g" -e "s/',.*$//g")
echo "SlapOS Web Runner URL: $slaprunner_url"
[[ -z "$slaprunner_url" ]] && \
csih_error "Failed to create instance of SlapOS Web Runner."
cat <<EOF > $slaprunner_startup_file
<html>
<head><title>SlapOS Web Runner</title>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.location.href = "$slaprunner_url"
}
//-->
</script>
</head>
<body onload="openwin()"/>
<!-- $feature_code -->
</html>
EOF
echo SlapOS Web Runner boot file $slaprunner_startup_file generated.
echo
echo Install Web Runner OK.
echo
fi
echo
echo Configure section runner OK.
echo
# ----------------------------------------------------------- # -----------------------------------------------------------
# tab: Install cron service and create crontab # tab: Install cron service and create crontab
# ----------------------------------------------------------- # -----------------------------------------------------------
......
...@@ -385,3 +385,101 @@ function create_template_configure_file() ...@@ -385,3 +385,101 @@ function create_template_configure_file()
wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example -O $node_template_file || return 1 wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example -O $node_template_file || return 1
echo Got $node_template_file. echo Got $node_template_file.
} # === create_template_configure_file() === # } # === create_template_configure_file() === #
# ======================================================================
# Routine: create_slapos_webrunner_instance
# Create one instance of slapos webrunner in local computer
# ======================================================================
function create_slapos_webrunner_instance()
{
local _title
local _guid
local _feature_code="#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
local _re6stnet_ipv6
local _patch_file=/etc/slapos/patches/slapos-cookbook-inotifyx.patch
local _url
echo Checking SlapOS Webruner ...
if grep -q -F "${_feature_code}" ${slaprunner_startup_file} ; then
echo "Find feature code ${_feature_code} in the ${slaprunner_startup_file}"
echo "Check SlapOS Webrunner OK."
else
echo Installing SlapOS Webrunner ...
_guid=$(grep "CN=COMP" $node_certificate_file | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
[[ "${_guid}" == COMP-+([0-9]) ]] ||
csih_error "Invalid computer id '${_guid}' specified."
_title="SlapOS-Node-Runner-In-${_guid}"
if [[ -r $re6stnet_configure_file ]] ; then
_re6stnet_ipv6=$(grep "Your subnet" $re6stnet_configure_file| \
sed -e "s/^.*subnet: //g" -e "s/\/80 (CN.*\$/1/g")
if [[ ! -z "${_re6stnet_ipv6}" ]] ; then
echo "Re6stnet address in this computer: ${_re6stnet_ipv6}"
netsh interface ipv6 show addr $slapos_ifname level=normal | \
grep -q ${_re6stnet_ipv6} || \
netsh interface ipv6 add addr $slapos_ifname ${_re6stnet_ipv6}
fi
fi
/opt/slapos/bin/slapos node format -cv --now || \
csih_error "Failed to run slapos format."
echo "Supply slapwebrunner in the computer ${_guid}"
/opt/slapos/bin/slapos supply slaposwebrunner ${_guid}
echo "Request an instance ${_title} ..."
while true ; do
/opt/slapos/bin/slapos node software --verbose
# Apply patches to slapos.cookbook for inotifix
if [[ -r ${_patch_file} ]] ; then
for x in $(find /opt/slapgrid/ -name slapos.cookbook-*.egg) ; do
echo Apply patch ${_patch_file} at $x
cd $x
patch -f --dry-run -p1 < ${_patch_file} > /dev/null && \
patch -p1 < ${_patch_file}
done
fi
/opt/slapos/bin/slapos node instance --verbose
/opt/slapos/bin/slapos node report --verbose
/opt/slapos/bin/slapos request $client_config_file ${_title} \
slaposwebrunner --node computer_guid=${_guid} && break
sleep 3
done
# Connection parameters of instance are:
# {'backend_url': 'http://[2001:67c:1254:45::c5d5]:50000',
# 'cloud9-url': 'http://localhost:9999',
# 'password_recovery_code': 'e2d01c14',
# 'ssh_command': 'ssh 2001:67c:1254:45::c5d5 -p 2222',
# 'url': 'http://softinst39090.host.vifib.net/'}
_url=$(/opt/slapos/bin/slapos request $client_config_file \
${_title} slaposwebrunner --node computer_guid=${_guid} | \
grep backend_url | sed -e "s/^.*': '//g" -e "s/',.*$//g")
echo "SlapOS Web Runner URL: ${_url}"
[[ -z "${_url}" ]] && \
csih_error "Failed to create instance of SlapOS Web Runner."
cat <<EOF > $slaprunner_startup_file
<html>
<head><title>SlapOS Web Runner</title>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.location.href = "${_url}"
}
//-->
</script>
</head>
<body onload="openwin()"/>
<!-- $feature_code -->
</html>
EOF
echo SlapOS Webrunner boot file $slaprunner_startup_file generated.
echo Install Web Runner OK.
echo
fi
} # === create_slapos_webrunner_instance() === #
...@@ -22,6 +22,11 @@ check_cygwin_service sshd ...@@ -22,6 +22,11 @@ check_cygwin_service sshd
check_cygwin_service cron check_cygwin_service cron
check_re6stnet_needed && check_cygwin_service re6stnet check_re6stnet_needed && check_cygwin_service re6stnet
# -----------------------------------------------------------
# Create instance of slap web runner
# -----------------------------------------------------------
create_slapos_webrunner_instance || exit 1
# ----------------------------------------------------------- # -----------------------------------------------------------
# Format slapos node # Format slapos node
# ----------------------------------------------------------- # -----------------------------------------------------------
......
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