Commit 8fb14cc1 authored by Jondy Zhao's avatar Jondy Zhao

Fix slapos node configure problem in the Windows 7

parent 1510a838
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<itemizedlist> <itemizedlist>
<listitem><para>SlapOS Desktop</para></listitem> <listitem><para>SlapOS Desktop</para></listitem>
<listitem><para>Node Runner</para></listitem> <listitem><para>Node Runner</para></listitem>
<listitem><para>SlapOS Node</para></listitem>
<listitem><para>Command Console</para></listitem> <listitem><para>Command Console</para></listitem>
<listitem><para>Configure SlapOS</para></listitem> <listitem><para>Configure SlapOS</para></listitem>
<listitem><para>User Guide</para></listitem> <listitem><para>User Guide</para></listitem>
...@@ -69,6 +70,9 @@ ...@@ -69,6 +70,9 @@
<para>Node Runner is a web based development tool which uses slapgrid to install and instantiate the software, and it could be used to manage your slapos slave node in your computer.</para> <para>Node Runner is a web based development tool which uses slapgrid to install and instantiate the software, and it could be used to manage your slapos slave node in your computer.</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>SlapOS Node</title>
<para>It's used to format slapos node, release software and create instance, you an run it at any time.</para>
</section>
<section><title>Command Console</title> <section><title>Command Console</title>
<para>It will open a terminal, here you can run most of slapos command, <para>It will open a terminal, here you can run most of slapos command,
<programlisting> <programlisting>
...@@ -191,10 +195,10 @@ Refer to: http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/develope ...@@ -191,10 +195,10 @@ Refer to: http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/develope
D: D:
MD slapos MD slapos
CD slapos CD slapos
SET PACKAGES=-P autobuild -P autoconf -P automake -P autossh -P binutils -P bison -P bzip2 -P ca-certificates -P cron -P curl -P cygport -P cygrunsrv -P file -P flex -P gcc4 -P gdbm -P libgdbm-devel -P gettext -P gettext-devel -P libglib2.0-devel -P libglib2.0_0 -P libexpat1 -P libexpat1-devel -P libmpfr-devel -P libmpfr4 -P libtool -P libxml2 -P libxml2-devel -P libxslt -P libxslt-devel -P make -P m4 -P libncurses-devel -P libncursesw-devel -P patch -P patchutils -P pkg-config -P python -P python-setuptools -P openssh -P openssl-devel -P libopenssl098 -P libopenssl100 -P popt -P readline -P libsqlite3-devel -P libsqlite3_0 -P swig -P syslog-ng -P zlib-devel -P vim -P wget -P docbook-utils SET PACKAGES=-P autobuild -P autoconf -P automake -P autossh -P binutils -P bison -P bzip2 -P ca-certificates -P cron -P curl -P cygport -P cygrunsrv -P file -P flex -P gcc4 -P gdbm -P libgdbm-devel -P gettext -P gettext-devel -P libglib2.0-devel -P libglib2.0_0 -P libexpat1 -P libexpat1-devel -P libmpfr-devel -P libmpfr4 -P libtool -P libxml2 -P libxml2-devel -P libxslt -P libxslt-devel -P make -P m4 -P libncurses-devel -P libncursesw-devel -P patch -P patchutils -P pkg-config -P python -P python-setuptools -P openssh -P openssl-devel -P libopenssl098 -P libopenssl100 -P popt -P readline -P libsqlite3-devel -P libsqlite3_0 -P swig -P syslog-ng -P zlib-devel -P vim -P wget
MOVE d:\temp\setup.exe .\ MOVE d:\temp\setup.exe .\
setup.exe %PACKAGES% --no-verify -D -L -l D:\slapos\cygwin-packages -R D:\slapos\cygwin -s http://www.netgull.com/cygwin setup.exe %PACKAGES% --no-verify -D -L -l D:\slapos\cygwin-packages -R D:\slapos\cygwin -s http://www.netgull.com/cygwin
</programlisting>Waiting for the installer finished.</para></listitem> </programlisting>Waiting for the installer finished. -P docbook-utils</para></listitem>
</itemizedlist> </itemizedlist>
A cygwin icon will be added in the windows desktop, click it to enter cygwin box, then run the following commands: A cygwin icon will be added in the windows desktop, click it to enter cygwin box, then run the following commands:
<!-- <!--
...@@ -212,7 +216,9 @@ start mintty.exe -i /Cygwin-Terminal.ico - ...@@ -212,7 +216,9 @@ start mintty.exe -i /Cygwin-Terminal.ico -
<programlisting> <programlisting>
echo "export CYGWIN=server" >> ~/.bash_profile echo "export CYGWIN=server" >> ~/.bash_profile
sed -i -e "s/4\.3\.4/4.5.3/g" /usr/bin/libtool sed -i -e "s/4\.3\.4/4.5.3/g" /usr/bin/libtool
cp /etc/password /etc/password.orig [[ -f /etc/passwd ]] || mkpasswd > /etc/passwd
[[ -f /etc/group ]] || mkgroup > /etc/group
cp /etc/passwd /etc/passwd.orig
myaccount=$(grep "^Administrator:" /etc/passwd | \ myaccount=$(grep "^Administrator:" /etc/passwd | \
sed -e "s/Administrator:unused:500:/root:unused:0:/g") sed -e "s/Administrator:unused:500:/root:unused:0:/g")
echo $myaccount >> /etc/passwd echo $myaccount >> /etc/passwd
...@@ -243,7 +249,7 @@ mkdir -p /opt/slapos ...@@ -243,7 +249,7 @@ mkdir -p /opt/slapos
mkdir -p /opt/download-cache mkdir -p /opt/download-cache
cd /opt/slapos cd /opt/slapos
echo "[buildout] echo "[buildout]
extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin-0:/component/slapos/buildout.cfg extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/component/slapos/buildout.cfg
download-cache = /opt/download-cache download-cache = /opt/download-cache
prefix = ${buildout:directory} prefix = ${buildout:directory}
" > buildout.cfg " > buildout.cfg
...@@ -255,9 +261,9 @@ Now we need patch slapos.core for supporting cygwin, after these code are merged ...@@ -255,9 +261,9 @@ Now we need patch slapos.core for supporting cygwin, after these code are merged
<programlisting> <programlisting>
cd /opt cd /opt
wget http://www.dashingsoft.com/products/slapos/slapos-patches.tar.gz wget http://www.dashingsoft.com/products/slapos/slapos-patches.tar.gz
tar xzf slapos-patches.tar.gz tar xzf slapos-patches.tar.gz --no-same-owner
cd eggs/slapos.core-0.35-py2.7.egg/slapos cd /opt/slapos/eggs/slapos.core-0.35-py2.7.egg
patch -p1 &lt; /opt/patches/slapos-core.patch patch -p1 &lt; /opt/patches/slapos-core-format.patch
</programlisting> </programlisting>
It seems netifaces.dll need to rebase, It seems netifaces.dll need to rebase,
<programlisting> <programlisting>
...@@ -282,7 +288,6 @@ git clone -b cygwin http://git.erp5.org/repos/slapos.package.git ...@@ -282,7 +288,6 @@ git clone -b cygwin http://git.erp5.org/repos/slapos.package.git
Then build babeld and openvpn for cygwin, we need use the sources in the slapos.package.git, they are patched for cygwin: Then build babeld and openvpn for cygwin, we need use the sources in the slapos.package.git, they are patched for cygwin:
<programlisting> <programlisting>
cd /opt/git/slapos.package/windows/babeld cd /opt/git/slapos.package/windows/babeld
# If your os is windows xp, type the following command, otherwise type make only.
make WINVER=XP make WINVER=XP
cp babeld.exe /usr/local/bin cp babeld.exe /usr/local/bin
...@@ -308,7 +313,7 @@ Download pyOpenSSL-0.13.tar.gz, miniupnpc-1.8.tar.gz, ...@@ -308,7 +313,7 @@ Download pyOpenSSL-0.13.tar.gz, miniupnpc-1.8.tar.gz,
<programlisting> <programlisting>
mkdir -p /opt/downloads mkdir -p /opt/downloads
cd /opt/downloads cd /opt/downloads
wget --no-verify-certificate https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz#md5=767bca18a71178ca353dff9e10941929 wget --no-check-certificate https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz#md5=767bca18a71178ca353dff9e10941929
wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz -O miniupnpc-1.8.tar.gz wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz -O miniupnpc-1.8.tar.gz
</programlisting> </programlisting>
Get re6stnet for cygwin Get re6stnet for cygwin
...@@ -323,8 +328,8 @@ Get the icons and openvpn drivers ...@@ -323,8 +328,8 @@ Get the icons and openvpn drivers
cd /opt cd /opt
wget http://www.dashingsoft.com/products/slapos/images.tar.gz wget http://www.dashingsoft.com/products/slapos/images.tar.gz
wget http://www.dashingsoft.com/products/slapos/openvpn-driver.tar.gz wget http://www.dashingsoft.com/products/slapos/openvpn-driver.tar.gz
tar xzf images.tar.gz tar xzf images.tar.gz --no-same-owner
tar xzf openvpn-driver.tar.gz tar xzf openvpn-driver.tar.gz --no-same-owner
</programlisting> </programlisting>
</para> </para>
</section> </section>
......
...@@ -59,6 +59,7 @@ Source: "opt\openvpn\bin\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin"; ...@@ -59,6 +59,7 @@ Source: "opt\openvpn\bin\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver"; Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
...@@ -71,15 +72,13 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D ...@@ -71,15 +72,13 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons] [Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico"; Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico"; Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico"; Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -h never -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
; Name: "{group}\SlapOS Console"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h always -t ""SlapOS Console"" /opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\SlapOS Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico"; Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
; Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html"; Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}"; Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
[Run] [Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden; Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist runhidden; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist runhidden;
......
#! /bin/bash
#
# Configure slapos node, it could be run at anytime to check the
# configure of slapos node. The main functions:
#
# * Install msloop network adapter, named to re6stnet-lo
#
# It'll used as main interface for slapos and re6stnet
#
# * ipv6: Ipv6 configure
#
# * re6stnet: Install re6stnet and register to nexedi re6stnet if it hasn't
#
# * node: Create node configure file by parameters ca/key
#
# * client: Create client configure file by parameters ca/key
#
# * cron: start/stop cron configure.
#
# Usage:
#
# ./slapos-node-config [ * | ipv6 | re6stnet | node | client | cron ]
#
export PATH=/usr/local/bin:/usr/bin:$PATH
#
# Return connection name by line, and replace space with '%'
#
function get_all_connections()
{
netsh interface ipv6 show interface | \
grep "^[ 0-9]\+ " | \
sed -e "s/^[ 0-9]\+[a-zA-Z]\+//" -e "s/^\s*//" -e "s/ /%/g"
}
#
# Check all the connection names, and compare the original connection
# list, return the new connection name
#
# If nothing found, return empty
# If more than one, return the first one
#
function get_new_connection()
{
original_connections=" $* "
current_connections=$(get_all_connections)
for name in $current_connections ; do
[[ ! "$original_connections" == *[\ ]$name[\ ]* ]] && \
echo ${name//%/ } && return 0
done
}
#
# Remove all ipv4/ipv6 addresses in the connection re6stnet-lo
#
function reset_connection()
{
ifname=${1-re6stnet-lo}
for addr in $(netsh interface ipv6 show address $ifname level=normal | \
grep "^Manual" | \
sed -e "s/^\(\w\+\s\+\)\{4\}//") ; do
netsh interface ipv6 del address $ifname $addr
done
netsh interface ip set address $ifname source=dhcp
# for addr in $(netsh interface ip show address $ifname | \
# grep "IP Address:" | \
# sed -e "s/IP Address://") ; do
# netsh interface del address $ifname $addr
# done
}
#
# Transfer connection name to GUID
#
function connection2guid()
{
ifname=${1-re6stnet-lo}
# This command doesn't work in the Windows 7/8, maybe Vista
# netsh interface ipv6 show interface $ifname | \
# grep "^GUID\s*:" | \
# sed -e "s/^GUID\s*:\s*//"
getmac /fo list /v | grep -A3 "^Connection Name: *$ifname\$" \
| grep "^Transport Name:" | sed -e "s/^.*Tcpip_//g"
}
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Failed to configure Slapos Node in this computer.}
echo $msg
read -n 1 -p "Press any key to exit..."
exit 1
}
#
# Query the parameter, usage:
#
# query_parameter Actual Excpeted Message
#
function query_parameter()
{
if [[ X$1 == X || $1 == "*" || $1 == "all" ]] ; then
return 1
fi
if [[ $1 == "?" || $1 == "query"]] ; then
read -n 1 -p $3 user_ack
if [[ X$user_ack == X[Yy] ]] ; then
return 1
else
return 0
fi
fi
if [[ $1 == $2 ]] ; then
return 1
fi
return 0
}
slapos_client_home=~/.slapos
client_configure_file=$slapos_client_home/slapos.cfg
client_certificate_file=$slapos_client_home/certificate
client_key_file=$slapos_client_home/key
client_template_file=/etc/slapos/slapos-client.cfg.example
node_certificate_file=/etc/opt/slapos/ssl/computer.crt
node_key_file=/etc/opt/slapos/ssl/computer.key
node_config_file=/etc/opt/slapos/slapos.cfg
node_template_file=/etc/slapos/slapos.cfg.example
run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=SlapOS-Node
slapos_ifname=re6stnet-lo
#
# Add msloop network adapter, ane name it as "re6stnet-lo"
#
echo Checking slapos network adapter: $slapos_ifname ...
original_connections=$(echo $(get_all_connections))
if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then
echo Installing slapos network adapter ...
devcon install $WINDIR\\inf\\netloop.inf *MSLOOP
connection_name=$(get_new_connection $original_connections)
[[ "X$connection_name" == "X" ]] && \
show_error_exit "Add msloop network adapter failed."
echo
netsh interface set interface name="$connection_name" newname="$slapos_ifname"
fi
reset_connection $slapos_ifname
echo SlapOS network adapter OK.
#
# Generate Node Configure file
#
echo
echo Before continue to configure, make sure you have register your server to
echo slapos.org community Cloud, and have obtained X509 certificate and key
echo which are needed for the following configuration process.
echo
echo Refer to http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Installing.SlapOS.Slave.Node.Source
echo
mkdir -p /etc/opt/slapos/ssl/partition_pki
if [[ ! -f $node_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \
show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $node_certificate_file"
certificate_file=$(cygpath -u $certificate_file)
cp $certificate_file $node_certificate_file
fi
if [[ ! -f $node_key_file ]] ; then
read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \
show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $node_key_file"
key_file=$(cygpath -u $key_file)
cp $key_file $node_key_file
fi
if [[ "$1" == COMP-+([0-9]) ]] ; then
computer_id=$1
else
[[ "X$1" == "X" ]] || echo "Invalid computer id: $1"
echo
echo Please input computer id you have registered, it looks like COMP-XXXX
read -p "computer id: " computer_id
fi
[[ "$computer_id" == COMP-+([0-9]) ]] || \
show_error_exit "Invalid computer id specified."
# Hope it will not confilct with original network in the local machine
ipv4_local_network=10.201.67.0/24
# Add ipv4 address
ip -4 addr add $ipv4_local_network dev $slapos_ifname
# Create node configure file, replace interface_name with guid of
# re6stnet-lo
if [[ ! -f $node_config_file ]] ; then
[[ -f $node_template_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example) || \
show_error_exit "Download slapos.cfg.example failed."
cp $node_template_file $node_config_file
fi
interface_guid=$(connection2guid $slapos_ifname)
# generate /etc/slapos/slapos.cfg
sed -i -e "s%^\\s*interface_name.*$%interface_name = $interface_guid%" \
-e "s%^#\?\\s*ipv6_interface.*$%# ipv6_interface =%g" \
-e "s%^ipv4_local_network.*$%ipv4_local_network = $ipv4_local_network%" \
-e "s%^computer_id.*$%computer_id = $computer_id%" \
$node_config_file
if [[ ! -f $client_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \
show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $client_certificate_file"
certificate_file=$(cygpath -u $certificate_file)
cp $certificate_file $client_certificate_file
fi
if [[ ! -f $client_key_file ]] ; then
read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \
show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $client_key_file"
key_file=$(cygpath -u $key_file)
cp $key_file $client_key_file
fi
if [[ ! -f $client_configure_file ]] ; then
[[ -f $template_configure_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example) || \
show_error_exit "Download slapos-client.cfg.example failed."
cp $template_configure_file $client_configure_file
fi
sed -i -e "s%^cert_file.*$%cert_file = $client_certificate_file%" \
-e "s%^key_file.*$%key_file = $client_key_file%" \
$client_configure_file
# Config slapproxy
if ! $(grep -q "^\[slapproxy\]" $node_config_file) ; then
echo "
[slapproxy]
host = 127.0.0.1
port = 28080
database_uri = /var/lib/slapproxy.db
" >> $node_config_file
fi
#
# Re6stnet
#
# Check ipv6, install it if it isn't installed.
netsh interface ipv6 show interface > /dev/null || netsh interface ipv6 install
# miniupnpc is required by re6stnet
if [[ ! -d /opt/miniupnpc ]] ; then
if [[ -f /miniupnpc.tar.gz ]] ; then
echo "Installing miniupnpc ..."
cd /opt
tar xzf /miniupnpc.tar.gz --no-same-owner
mv $(ls -d miniupnpc-*) miniupnpc
cd miniupnpc
make
python setup.py install || echo "Install miniupnpc failed."
else
echo "No miniupnpc source package found."
fi
fi
# pyOpenSSL is required by re6stnet
if [[ ! -d /opt/pyOpenSSL ]] ; then
if [[ -f /pyOpenSSL.tar.gz ]] ; then
echo "Installing pyOpenSSL ..."
cd /opt
tar xzf /pyOpenSSL.tar.gz --no-same-owner
mv $(ls -d pyOpenSSL-*) pyOpenSSL
cd pyOpenSSL
python setup.py install || echo "Install pyOpenSSL failed."
fi
fi
# Install re6stnet
if [[ ! -d /opt/re6stnet ]] ; then
echo "Installing re6stnet ..."
cd /opt
if [[ -f /re6stnet.tar.gz ]] ; then
tar xzf /re6stnet.tar.gz --no-same-owner
mv $(ls -d re6stnet-*) re6stnet
else
echo "Clone re6stnet from http://git.erp5.org/repos/re6stnet.git"
git clone -b cygwin http://git.erp5.org/repos/re6stnet.git
fi
cd re6stnet
python setup.py install || echo "Install re6stnet failed."
fi
mkdir -p /etc/re6stnet
cd /etc/re6stnet
if [[ ! -f re6stnet.conf ]] ; then
re6st-conf --registry http://re6stnet.nexedi.com/
fi
[[ ! -f re6stnet.conf ]] && show_error_exit "Register to nexedi re6stnet failed"
grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf
#
# Create instance of web runner
#
slaprunner_cfg=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner/software.cfg
while true ; do
/opt/slapos/bin/slapos supply $slaprunner_cfg $computer_id
/opt/slapos/bin/slapos request "Node Runner" $slaprunner_cfg --node computer_guid=$computer_id && break
done
#
# Get url from connection infromation
#
# 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 "Node Runner" $slaprunner_cfg --node computer_guid=$computer_id | grep backend_url | sed -e "s/^.*': '//g" -e "s/',.*$//g")
echo SlapOS Node configure successfully.
read -n 1 -p "Press any key to exit..."
exit 0
#! /bin/bash
#
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH
current_path=$(cygpath -a $(dirname $0))
if [[ ! -f $current_path/node-runner.vbs ]] ; then
echo Installing slap-runner ...
$current_path/slapos-configure runner || (echo Failed to create instance of slap-runner ; exit 1)
echo Install slap-runner OK.
fi
# cat <<EOF > $current_path/node-runner.vbs
# Set oShell = CreateObject("WScript.Shell")
# oShell.OpenBrowser("http://[2001:67c:1254:45::c5d5]:50000")
# EOF
if [[ -f $current_path/node-runner.vbs ]] ; then
echo Starting slap-runner ...
cyg_cscript $current_path/node-runner.vbs || (echo Failed to start slap-runner ; exit 1)
echo Start slap-runner OK.
fi
#! /bin/bash
export PATH=/usr/local/bin:/usr/bin:$PATH
ifname=re6stnet-lo
ping6 slap.vifib.com > /dev/null
# Run re6stnet if no native ipv6
if (( $? )) ; then
echo "Start re6stnet ..."
(cd /etc/re6stnet; re6stnet @re6stnet.conf --ovpnlog -I $ifname -i $ifname &)
echo "Start re6stent in the background OK."
echo "Waiting re6stent network work ..."
while true ; do
ping6 slap.vifib.com && break
done
echo "re6stnet network OK."
fi
# Format slapos node
echo "Run Slapos format ..."
/opt/slapos/bin/slapos node format -cv --now
if (( $? )) ; then
echo "Failed to run slapos format."
exit 1
else
echo "Format slapos node OK."
fi
# Release software
echo "Releasing software ..."
/opt/slapos/bin/slapos node software
if (( $? )) ; then
echo "Failed to relase software in the slapos node."
exit 1
else
echo "Release software OK."
fi
# Instance software
echo "Creating instance ..."
/opt/slapos/bin/slapos node instance
if (( $? )) ; then
echo "Failed to create instance in the slapos node."
exit 1
else
echo "Create instance OK."
fi
# Send report
/opt/slapos/bin/slapos node report
exit 0
...@@ -53,6 +53,7 @@ Source: "opt\openvpn\bin\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin"; ...@@ -53,6 +53,7 @@ Source: "opt\openvpn\bin\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver"; Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
...@@ -65,11 +66,10 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D ...@@ -65,11 +66,10 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons] [Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico"; Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico"; Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico"; Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -h never -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
; Name: "{group}\SlapOS Console"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h always -t ""SlapOS Console"" /opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\SlapOS Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico"; Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
; Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html"; Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}"; Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
......
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