Commit 5dd596a2 authored by Jondy Zhao's avatar Jondy Zhao

Change windows installer scripts

parent 51a4a9f5
......@@ -20,75 +20,92 @@
<chapter id="ch_introduction"><title>Introduction</title>
<para>SlapOS can be described as a cloud operating system in which "everything is a process" unlike Unix in which "everything is a file". If one has to manage thousands of servers with thousands of processes, hundred different applications in multiple different releases or versions, SlapOS can help you a lot by making the whole management process well specified, automated and under control.</para>
<para>The goal of this tutorial is to teach how to use SlapOS in the windows.</para>
<!--
<itemizedlist>
<listitem><para>First you need register an account in the slapos.org (refer to <xref linkend="ch_register_slapos_org"/>)</para></listitem>
<listitem><para>Then install SlapOS slave node in the windows (refer to <xref linkend="ch_install_slapos"/>)</para></listitem>
<listitem><para>Finally enjoy slapos cloud in the Windows</para></listitem>
</itemizedlist>
-->
</chapter>
<!--
<chapter id="ch_register_slapos_org"><title>Registering in the slapos.org</title>
<para>Then, we need to register your computer to slapos.org community Cloud. By doing so, we will obtain X509 certificate and key which are later needed for the configuration process.
<itemizedlist>
<listitem><para>Login to www.slapos.org. Go to the "My Space" area and then to the "My Servers" section. Click on the button "New Server". This button will lead you to a page where you can specify the name of your server.</para></listitem>
<listitem><para>Enter a self contained name to identify your server. Consider a name "VIFIB 19 Asus i7 for JB" rather than "My Server". This will help you find your server later on. Click on the "Add" button.</para></listitem>
<listitem><para>X509 key and certificate are generated. Certificates are not stored by slapos.org server. They will be lost if you do not save them : Do not close this web page yet as we are going to store the key and certificate in files in next step. </para>
<para>You can create 2 new files named as computer.key and computer.crt by Notepad or any editor your prefer, and save the content of certificate and key into both of files respectively.</para></listitem>
</itemizedlist>
</para>
<para>Refer to <ulink url="http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Running.SlapOS.on.your.computer"></ulink> in the section VIFIB Registration.</para>
</chapter>
-->
<chapter id="ch_install_slapos"><title>Installing SlapOS node in the Windows</title>
<para>At first, we need to sign up in VIFIB community Cloud by clicking here <ulink url="https://www.slapos.org/login_form"/></para>
<para>Then download the latest slapos windows installer from <ulink url="http://www.erp5.org/dists/installer"></ulink>, the filename of windows installer look like slapos-XXX-windows-x86-all-in-one.exe or slapos-XXX-windows.exe, XXX stands for version-release information. The all-in-one installer include all the files required by slapos node, so it can run in the computer which doesn't access internat; the later will download most of packages from internet and build, so it need more time than all-in-one installer. It's recommanded to use the former installer in case of slow or unstable internet even if the size of all-in-one installer is more than 100MB, compare of the latter which size is about 2MB.</para>
<para>Double click the installer, click Next, Next ...</para>
<para>Double click the installer, click Next, Next ...
<note><para>If the current user isn't Administrator, you need run it as Administrator. Right click the installer, then click Run As Administrator.</para></note>
</para>
<para>At the final wizard page, click Install.</para>
<para>Waiting for everything done.</para>
<para>If you'd like to install slapos node from sources, refer to the chapter <xref linkend="ch_generate_window_installer"/>.</para>
<para>If you prefer to install slapos node from sources, refer to the chapter <xref linkend="ch_generate_window_installer"/>.</para>
</chapter>
<chapter><title>Using Slapos in the Windows</title>
<para>After SlapOS has been installed successfully, you will find program group "SlapOS" which include the following entries:
<itemizedlist>
<listitem><para>Configure SlapOS</para></listitem>
<listitem><para>SlapOS Node</para></listitem>
<listitem><para>SlapOS Desktop</para></listitem>
<listitem><para>Node Runner</para></listitem>
<listitem><para>SlapOS Node</para></listitem>
<listitem><para>Command Console</para></listitem>
<listitem><para>Configure SlapOS</para></listitem>
<listitem><para>User Guide</para></listitem>
</itemizedlist>
</para>
<section><title>Configure SlapOS</title>
<para>It used to generate all the configure files required by slapos slave node, you can run it anytime when you need change the configure of your slapos slave node.</para>
<para>Go to slapos.org (or any other SlapOS Master), register if not already done, go to My Account and request an SSL certificate:
<itemizedlist>
<listitem><para>Copy the certificate in a file, save it in C:/slapos/cygwin/certificate</para></listitem>
<listitem><para>Copy the key in a file, save it in C:/slapos/cygwin/key</para></listitem>
</itemizedlist>
You can save them anywhere, but it's better to save them in the path C:/slapos/cygwin which is your slapos installed, because it's the default path in the slapos configure script. More information refer to <ulink url="http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Installing.SlapOS.Client"></ulink></para>
<para>Then register your computer to slapos.org community Cloud. By doing so, we will obtain X509 certificate and key which are later needed for the configuration process.
<itemizedlist>
<listitem><para>Login to www.slapos.org. Go to the "My Space" area and then to the "My Servers" section. Click on the button "New Server". This button will lead you to a page where you can specify the name of your server.</para></listitem>
<listitem><para>Enter a self contained name to identify your server. Consider a name "VIFIB 19 Asus i7 for JB" rather than "My Server". This will help you find your server later on. Click on the "Add" button.</para></listitem>
<listitem><para>X509 key and certificate are generated. Certificates are not stored by slapos.org server. They will be lost if you do not save them : Do not close this web page yet as we are going to store the key and certificate in files in next step. </para></listitem>
<listitem><para>Copy the certificate in a file, save it in C:/slapos/cygwin/computer.crt</para></listitem>
<listitem><para>Copy the key in a file, save it in C:/slapos/cygwin/computer.key</para></listitem>
</itemizedlist>
More information refer to <ulink url="http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Running.SlapOS.on.your.computer"></ulink> in the section VIFIB Registration.</para>
<para>Now it's time to run Configure SlapOS, click Start -> SlapOS -> Configure SlapOS, if the current user isn't Administrator, Right click Configure SlapOS, then Run As Administrator.</para>
<para>Or you can run configure script in the command line, first click Start -> SlapOS -> Command Console, if the current user isn't Administrator, Right click Command Console, then Run As Administrator, then in the command line:
<programlisting>
/etc/opt/slapos/scripts/slapos-configure.sh
</programlisting>
The configure script will guide you to configure slapos slave node, as the prompt:
<itemizedlist>
<listitem><para>Type computer certificate filename, if it's stored in the default path as above, type Enter directly</para></listitem>
<listitem><para>Type computer key filename, if it's stored in the default path as above, type Enter directly</para></listitem>
<listitem><para>Type client certificate filename, if it's stored in the default path as above, type Enter directly</para></listitem>
<listitem><para>Type client key filename, if it's stored in the default path as above, type Enter directly</para></listitem>
</itemizedlist>
Be sure the configure scrip report successfully, otherwise fix the problem and run it again. You can run Slapos Configure at anytime, and netx time you needn't input anything, configure scripts just checks all then configuration and update the configure files.
</para>
</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>
<para>Click Start -> SlapOS -> SlapOS Node, if the current user isn't Administrator, Right click SlapOS Node, then Run As Administrator.</para>
<para>Be sure the scrip reports successfully, otherwise fix the problem and run it again.</para>
</section>
<section><title>SlapOS Desktop</title>
<para>This is used by slapos client, now it's connected to <ulink url="https://www.slapos.org"/>. Logon and enjoy the journey in the SlapOS Cloud world.</para>
</section>
<section><title>Node Runner</title>
<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>After installing slapos, Node Runner isn't available. You need run Configure SlapOS 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>
</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>
<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, for examples,
<programlisting>
cd /opt/slapos
ls bin
bang slapconsole slapgrid-sr slapos
buildout slapformat slapgrid-supervisorctl slapos-watchdog
generate-signature-key slapgrid slapgrid-supervisord slapproxy
py slapgrid-cp slapgrid-ur slapproxy-query
/opt/slapos/bin/slapos node foramt -cv --now
/opt/slapos/bin/slapos supply slaprunner COMP-1658
/opt/slapos/bin/slapos request "Jondy Web Runner In Windows 7" slaprunner --node computer_guid=COMP-1658
/opt/slapos/bin/slapos node software
/opt/slapos/bin/slapos node instance
/opt/slapos/bin/slapos node status
</programlisting>
</para>
<para>Refer to <ulink url="http://git.erp5.org/gitweb/slapos.core.git/blob/HEAD:/documentation/source/slapos.usage.rst?js=1"/></para>
</section>
<section><title>Configure SlapOS</title>
<para>It used to generate all the configure files required by slapos slave node, it will be called when first run slapos. And you can run it anytime when you need change the configure of your slapos slave node.</para>
<para>For more information, refer to <ulink url="http://git.erp5.org/gitweb/slapos.core.git/blob/HEAD:/documentation/source/slapos.usage.rst?js=1"/></para>
</section>
<section><title>User Guide</title>
<para>It just showes this documnet in the web browser.</para>
</section>
......@@ -190,15 +207,17 @@ Refer to: http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/develope
<para>Or you can install cygwin by command console, first you need download setup.exe from cygwin.com, save to D:\temp\setup.exe or somewhere else.
<itemizedlist>
<listitem><para>In the Windows destktop, Click Start</para></listitem>
<listitem><para>Click Run, type command: 'cmd', click OK to enter windows console</para></listitem>
<listitem><para>Click Run, type command: 'cmd', click OK to enter windows console. Be sure you start 'cmd' as Administrator:</para></listitem>
<listitem><para>Type the following commands:<programlisting>
D:
MD 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
REM If you require docbook-utils indeed, uncomment the next line (remove REM). Refer to <xref linkend="package-docbook-utils"/> to know what about docbook-utils.
REM SET PACKAGES=%PACKAGES% -P docbook-utils
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
</programlisting>Waiting for the installer finished. -P docbook-utils</para></listitem>
</programlisting>Waiting for the installer finished.</para></listitem>
</itemizedlist>
A cygwin icon will be added in the windows desktop, click it to enter cygwin box, then run the following commands:
<!--
......@@ -245,7 +264,7 @@ Then restart cygwin command box.
mkdir -p /cygdrive/d/slapos/opt
cd /
ln -s /cygdrive/d/slapos/opt
mkdir -p /opt/slapos
mkdir -p /opt/slapos/log
mkdir -p /opt/download-cache
cd /opt/slapos
echo "[buildout]
......@@ -323,11 +342,12 @@ git clone -b cygwin http://git.erp5.org/repos/re6stnet.git
cd re6stnet
python setup.py sdist
</programlisting>
Get the icons and openvpn drivers
Get the icons and openvpn drivers, if you use 32-bit windows, uncomment the comment line to download openvpn-driver-i386.tar.gz other than openvpn-driver-x86_64.tar.gz:
<programlisting>
cd /opt
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-x86_64.tar.gz -O openvpn-driver.tar.gz
# wget http://www.dashingsoft.com/products/slapos/openvpn-driver-i386.tar.gz -O openvpn-driver.tar.gz
tar xzf images.tar.gz --no-same-owner
tar xzf openvpn-driver.tar.gz --no-same-owner
</programlisting>
......@@ -406,46 +426,6 @@ $ bin/slapformat -c - -now /etc/slapos/slapos.cfg
</section>
</chapter>
<!--
A.
To install the IPv6 protocol for Windows XP with SP2 or later, do the following:
Log on to the computer with a user account that has privileges to change network configuration.
Click Start, click Control Panel, and then double-click Network Connections.
Right-click any local area connection, and then click Properties.
Click Install.
In the Select Network Component Type dialog box, click Protocol, and then click Add.
In the Select Network Protocol dialog box, click Microsoft TCP/IP version 6, and then click OK.
Click Close to save changes to your network connection.
Alternately, from the Windows XP desktop, click Start, point to Programs, point to Accessories, and then click Command Prompt. At the command prompt, type netsh interface ipv6 install.
For the IPv6 protocol for Windows XP with SP1, do the following:
Log on to the computer with a user account that has privileges to change network configuration.
Click Start, click Control Panel, and then double-click Network Connections.
Right-click any local area connection, and then click Properties.
Click Install.
In the Select Network Component Type dialog box, click Protocol, and then click Add.
In the Select Network Protocol dialog box, click Microsoft IPv6 Developer Edition, and then click OK.
Click Close to save changes to your network connection.
Alternately, from the Windows XP desktop, click Start, point to Programs, point to Accessories, and then click Command Prompt. At the command prompt, type netsh interface ipv6 install.
To install the IPv6 protocol for Windows XP with no service packs installed:
Log on to the computer running Windows XP with a user account that has privileges to change network configuration.
Open a command prompt. From the Windows XP desktop, click Start, point to Programs, point to Accessories, and then click Command Prompt.
At the command prompt, type ipv6 install.
Regardless of the version of Windows XP, to use RPC applications over IPv6, you must first restart the computer.
Q. How can I tell if the IPv6 protocol is installed for Windows XP with no service packs installed? It does not appear in the list of protocols in Network Connections. A. The installation of the IPv6 Protocol for Windows XP with no service packs installed does not use the standard procedure for protocol installation in the Network Connections folder. Therefore, it is not visible as an installed protocol. To determine whether IPv6 is installed, type ipv6 if at a command prompt. If IPv6 is installed, you will see a display of your IPv6 interfaces and their configuration. Otherwise, the Ipv6.exe tool will indicate that IPv6 is not installed.
-->
<appendix id="appendix_cygwin_packages"><title>Cygwin Required Packages List</title>
<para>The following packages are requied by SlapOS Node
<itemizedlist>
......@@ -458,6 +438,7 @@ Q. How can I tell if the IPv6 protocol is installed for Windows XP with no servi
<listitem><para>Utils/bzip2<superscript></superscript></para></listitem>
<listitem><para>Net/ca-certificates</para></listitem>
<listitem><para>Admin/cron</para></listitem>
<listitem><para>Net/curl</para></listitem>
<listitem><para>Devel/cygport</para></listitem>
<listitem><para>Admin/cygrunsrv</para></listitem>
<listitem><para>Utils/file<superscript>*</superscript></para></listitem>
......@@ -504,7 +485,10 @@ Q. How can I tell if the IPv6 protocol is installed for Windows XP with no servi
<listitem><para>Editor/vim</para></listitem>
<listitem><para>Web/wget</para></listitem>
</itemizedlist>
<note id="package-docbook-utils"><para>
There is another package: Text/docbook-utils, it only used to generate user-guide.html from source file. But this package will increase required disk size remarkable, because many dependent packages are installed by Cygwin, so it recommand not to check this package when building slapos source or the installer.</para></note>
</para>
<!--
<para>
The following packages are requied by re6stnet
<itemizedlist>
......@@ -518,9 +502,6 @@ The following packages are requied by re6stnet
<listitem><para>Web/apache2-devel</para></listitem>
<listitem><para>apache2-php<superscript>#</superscript></para></listitem>
<listitem><para>Devel/cmake</para></listitem>
<listitem><para>Admin/cron</para></listitem>
<listitem><para>Admin/cygrunsrv</para></listitem>
<listitem><para>Net/curl</para></listitem>
<listitem><para>Libs/libbz2-devel</para></listitem>
<listitem><para>Net/libcurl-devel</para></listitem>
<listitem><para>Text/libenchant-devel</para></listitem>
......@@ -541,6 +522,7 @@ The following packages are requied by re6stnet
</itemizedlist>
'*' means it's default package of cygwin, '#' means it need to build by myself, '?' means maybe it's not required.
</para>
-->
</appendix>
</book>
......@@ -6,47 +6,57 @@
#
# It will do:
#
# 1. Set uid of Adminstrator to 0, and create root account
# * Set uid of Adminstrator to 0, and create root account
#
# 2. Create .minttyrc and cygtty.bat, which used to start comand console
# * Create .minttyrc and cygtty.bat, which used to start comand console
#
# 3. Configure cygserver
# * Create autorebase.bat, it used to fix cygwin dll problem
#
# 4. Configure syslog-ng
#
if [[ ! "$(whoami)" == "Administrator" ]] ; then
exit 1
# * Change readme.txt to dos format
#
password_filename=/etc/passwd
echo Checking passwd file ...
if [[ ! -f $password_filename ]] ; then
echo No passwd file found.
mkpasswd > $password_filename
echo Generate passwd file OK.
else
echo Check passwd file OK.
fi
if [[ ! -f /etc/passwd ]] ; then
mkpasswd > /etc/passwd
echo Checking group file ...
if [[ ! -f /etc/group ]] ; then
echo No group file found.
mkgroup > /etc/group
echo Generate group file OK.
else
cp /etc/passwd /etc/passwd.orig
echo Check group file OK.
fi
# sed -i -e "s/Administrator:unused:500:/Administrator:unused:0:/g" /etc/passwd
grep -q "^root:" /etc/passwd
if (( $? != 0 )) ; then
myaccount=$(grep "^Administrator:" /etc/passwd | \
sed -e "s/Administrator:unused:500:/root:unused:0:/g")
if [[ "${myaccount:0:4}" == root ]] ; then
echo $myaccount >> /etc/passwd
else
exit 1
fi
fi
# grep -q "^root:" $password_filename
# if (( $? != 0 )) ; then
# myaccount=$(grep "^Administrator:" $password_filename | \
# sed -e "s/Administrator:unused:500:/root:unused:0:/g")
# if [[ "${myaccount:0:4}" == root ]] ; then
# echo $myaccount >> $password_filename
# else
# exit 1
# fi
# fi
if [[ ! -f ~/.minttyrc ]] ; then
echo Creating ~/.minttyrc
cat <<EOF > ~/.minttyrc
BoldAsFont=no
Font=Courier New
FontHeight=16
Scrollbar=none
EOF
echo File ~/.minttyrc created
fi
if [[ ! -f /cygtty.bat ]] ; then
echo Creating /cygtty.bat
cyghome=$(cygpath -w /)
cat <<EOF > /cygtty.bat
@echo off
......@@ -57,24 +67,37 @@ chdir ${cyghome}\\bin
start mintty.exe -i /Cygwin-Terminal.ico -
EOF
chmod +x /cygtty.bat
echo File /cygtty.bat created.
fi
# Configure cygserver
/usr/bin/cygserver-config --yes
# Configure syslog-ng
/usr/bin/syslog-ng-config --yes
# Copy rebaseall.bat to /
if [[ -f /etc/postinstall/autorebase.bat.done ]] ; then
cp /etc/postinstall/autorebase.bat.done /autorebase.bat
if [[ ! -f /autorebase.bat ]] ; then
echo Create /autorebase.bat
copy <<EOF > /autorebase.bat
@echo off
rem Postinstall scripts are always started from the Cygwin root dir
rem so we can just call dash from here
path .\bin;%path%
dash /bin/rebaseall -p
EOF
chmod +x /autorebase.bat
echo /autorebase.bat created.
fi
# Change format of readme.txt
readme_filepath=$(cygpath -m /)/..
if [[ -f $readme_filepath/Readme.txt ]] ; then
unix2dos $readme_filepath/Readme.txt
echo Change readme.txt to dos format OK.
fi
# Remove cygwin services to be sure these services will be configured
# in this cygwin enviroments when there are many cygwin instances
# installed in this computer.
for x in $(cygrunsrv --list) ; do
echo Removing cygservice $x
cygrunsrv -R $x
done
exit 0
#! /bin/bash
#
# When uninstall slapos, it will be called by uninstaller.
# When uninstall slapos, it will be called by uninstaller. Root right
# required to run this script.
#
# /bin/bash/ --login -i pre-uninstall.sh
#
......@@ -8,24 +9,15 @@
#
# 1. Remove virtual netcards installed by re6stnet
#
# 2. Remove service cygserver and syslog-ng
# 2. Remove service cron, cygserver and syslog-ng
#
if [[ ! "$(whoami)" == "Administrator" ]] ; then
exit 1
fi
#
# Remove slapos-init script when windows startup
#
run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=SlapOS-Node
regtool -q unset "$run_key\\$slapos_run_entry"
#
# Remove virtual netcard installed by re6stnet
#
for ifname in $(netsh interface show interface | gawk '{ print $3 }') ; do
if [[ ("$ifname" == re6stnet*) && ("$ifname" != "re6stnet-lo") ]] ; then
echo Removing network connection: $ifname
ip vpntap del dev $ifname mode true
fi
done
......@@ -33,8 +25,10 @@ done
#
# Remove services installed by cygwin
#
cygrunsrv.exe --remove syslog-ng
cygrunsrv.exe --remove cygserver
for x in $(cygrunsrv --list) ; do
echo Removing cygservice $x
cygrunsrv -R $x
done
exit 0
......@@ -64,6 +64,7 @@ Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app
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-node-runner.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\pre-uninstall.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
......@@ -71,18 +72,18 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.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 -h never -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Node Runner"; Filename: "http://{app}\cygwin\etc\slapos\scripts\slap-runner.html"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.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 -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 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}\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}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run]
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\autorebase.bat"; WorkingDir: "{app}\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;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist;
[UninstallRun]
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist runhidden;
......
#! /bin/bash
#
# Configure slapos node, it could be run at anytime to check the
# configure of slapos node. The main functions:
# This script need root rights. Before run it, make sure you have root
# right.
#
# * Install msloop network adapter, named to re6stnet-lo
# It used to configure slapos node, it could be run at anytime to
# check the configure of slapos node. The main functions:
#
# It'll used as main interface for slapos and re6stnet
# * Install msloop network adapter, named to re6stnet-lo
#
# * ipv6: Ipv6 configure
#
......@@ -15,14 +16,21 @@
#
# * client: Create client configure file by parameters ca/key
#
# * cron: start/stop cron configure.
# * cron: create cron configure file
#
# Usage:
#
# ./slapos-node-config [ * | ipv6 | re6stnet | node | client | cron ]
# ./slapos-configure
#
export PATH=/usr/local/bin:/usr/bin:$PATH
grep -q "export CYGWIN=server" ~/.bash_profie || echo "export CYGWIN=server" >> ~/.bash_profile
grep -q "export CYGWIN=server" ~/.profie || echo "export CYGWIN=server" >> ~/.profile
#-------------------------------------------------
# Common functions
#-------------------------------------------------
#
# Return connection name by line, and replace space with '%'
#
......@@ -76,10 +84,15 @@ function reset_connection()
function connection2guid()
{
ifname=${1-re6stnet-lo}
# This command doesn't work in the Windows 7/8, maybe Vista
#
# This command doesn't work in the Windows 7, Window 8, maybe
# Vista. Because no guid information in these platforms.
#
# netsh interface ipv6 show interface $ifname | \
# grep "^GUID\s*:" | \
# sed -e "s/^GUID\s*:\s*//"
#
# So we use getmac to repleace it:
getmac /fo list /v | grep -A3 "^Connection Name: *$ifname\$" \
| grep "^Transport Name:" | sed -e "s/^.*Tcpip_//g"
}
......@@ -98,7 +111,7 @@ function show_error_exit()
#
# Query the parameter, usage:
#
# query_parameter Actual Excpeted Message
# query_parameter ACTUAL EXCPETED MESSAGE
#
function query_parameter()
{
......@@ -119,23 +132,78 @@ function query_parameter()
return 0
}
#-------------------------------------------------
# Constants
#-------------------------------------------------
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
url_client_template_file=http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/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
url_node_template_file=http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example
slapos_ifname=re6stnet-lo
# Hope it will not confilct with original network in the local machine
ipv4_local_network=10.201.67.0/24
slapos_runner_file=/etc/slapos/scripts/slap-runner.html
slaprunner_cfg=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner/software.cfg
slaprunner_title="Node Runner"
#-------------------------------------------------
# Create paths
#-------------------------------------------------
mkdir -p /etc/opt/slapos/ssl/partition_pki
mkdir -p $slapos_client_home
#-------------------------------------------------
# Configure cygwin server services
#-------------------------------------------------
echo Checking cygserver service ...
cygrunsrv --query cygserver > /dev/null
if (( $? )) ; then
echo Run cygserver-config ...
/usr/bin/cygserver-config --yes || \
show_error_exit "Failed to run cygserver-config"
echo OK.
else
echo The cygserver service has been installed.
fi
echo Checking syslog-ng service ...
cygrunsrv --query syslog-ng > /dev/null
if (( $? )) ; then
echo Run syslog-ng-config ...
/usr/bin/syslog-ng-config --yes || \
show_error_exit "Failed to run syslog-ng-config"
echo OK.
else
echo The syslog-ng service has been installed.
fi
echo Checking cron service ...
cygrunsrv --query cron > /dev/null
if (( $? )) ; then
echo Run cron-config ...
/usr/bin/cron-config --yes || \
show_error_exit "Failed to run cron-config"
echo OK.
else
echo The cron service has been installed.
fi
#-------------------------------------------------
# Configure slapos network
#-------------------------------------------------
#
# Add msloop network adapter, ane name it as "re6stnet-lo"
#
......@@ -150,131 +218,173 @@ if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then
echo
netsh interface set interface name="$connection_name" newname="$slapos_ifname"
fi
reset_connection $slapos_ifname
#ip -4 addr add $ipv4_local_network dev $slapos_ifname
# reset_connection $slapos_ifname
echo SlapOS network adapter OK.
echo Slapos ipv4_local_network is $ipv4_local_network
#
# 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
#-------------------------------------------------
# Generate slapos node configure file
#-------------------------------------------------
echo Checking computer certificate file ...
if [[ ! -f $node_certificate_file ]] ; then
read -p "Where is computer certificate file: " certificate_file
read -p "Where is computer certificate file (/computer.crt): " certificate_file
[[ X$certificate_file == X ]] && certificate_file=/computer.crt
[[ ! -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
else
echo Found computer certificate file: $node_certificate_file
fi
openssl x509 -noout -in $node_certificate_file || \
show_error_exit "Invalid computer certificate: $node_certificate_file."
echo Check computer certificate OK.
echo Checking computer guid ...
computer_id=$(grep CN=COMP $node_certificate_file | sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
[[ "$computer_id" == COMP-+([0-9]) ]] || \
show_error_exit "Invalid computer id specified."
echo Computer GUID is: $computer_id
echo Checking computer key file ...
if [[ ! -f $node_key_file ]] ; then
read -p "Where is computer key file: " key_file
read -p "Where is computer key file (/computer.key): " key_file
[[ X$key_file == X ]] && key_file=/computer.key
[[ ! -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
else
echo Found computer key file: $node_key_file
fi
# 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
openssl rsa -noout -in $node_key_file -check || \
show_error_exit "Invalid computer key: $node_key_file."
echo Check computer key OK.
# Create node configure file, replace interface_name with guid of
# re6stnet-lo
echo Checking computer configure file ...
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) || \
(cd /etc/slapos; wget $url_node_template_file -O $node_template_file) || \
show_error_exit "Download slapos.cfg.example failed."
echo "Copy computer configure file from $node_template_file to $node_config_file"
cp $node_template_file $node_config_file
fi
interface_guid=$(connection2guid $slapos_ifname)
interface_guid=$(connection2guid $slapos_ifname) || \
show_error_exit "Failed to get guid of interface: $slapos_ifname."
echo Computer configuration information:
echo interface name: $slapos_ifname
echo GUID: $interface_guid
echo ipv4_local_network: $ipv4_local_network
echo computer_id: $computer_id
# 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
echo Check computer configure file OK.
#-------------------------------------------------
# Generate slapos client configure file
#-------------------------------------------------
echo Checking client certificate file ...
if [[ ! -f $client_certificate_file ]] ; then
read -p "Where is user certificate file: " certificate_file
read -p "Where is client certificate file (/certificate): " certificate_file
[[ X$certificate_file == X ]] && certificate_file=/certificate
[[ ! -f "$certificate_file" ]] && \
show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $client_certificate_file"
echo "Copy client certificate from $certificate_file to $client_certificate_file"
certificate_file=$(cygpath -u $certificate_file)
cp $certificate_file $client_certificate_file
fi
openssl x509 -noout -in $client_certificate_file || \
show_error_exit "Invalid client certificate: $client_certificate_file."
echo Check client certificate Ok.
echo Checking client key file ...
if [[ ! -f $client_key_file ]] ; then
read -p "Where is user key file: " key_file
read -p "Where is client key file (/key): " key_file
[[ X$key_file == X ]] && key_file=/key
[[ ! -f "$key_file" ]] && \
show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $client_key_file"
echo "Copy client key from $key_file to $client_key_file"
key_file=$(cygpath -u $key_file)
cp $key_file $client_key_file
fi
openssl rsa -noout -in $client_key_file -check || \
show_error_exit "Invalid client key: $client_key_file."
echo Checking computer key OK.
echo Checking client configure file ...
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
[[ -f $client_template_file ]] || \
(cd /etc/slapos; wget $url_client_template_file -O $client_template_file) || \
show_error_exit "Download slapos-client.cfg.example failed."
echo "Copy client configure file from $client_template_file to $client_config_file"
cp $client_template_file $client_configure_file
fi
echo Client configuration information:
echo client certificate file: $client_certificate_file
echo client key file: $client_key_file
echo
sed -i -e "s%^cert_file.*$%cert_file = $client_certificate_file%" \
-e "s%^key_file.*$%key_file = $client_key_file%" \
$client_configure_file
echo Check client configure file OK.
#
#-------------------------------------------------
# Re6stnet
#
#-------------------------------------------------
# Check ipv6, install it if it isn't installed.
netsh interface ipv6 show interface > /dev/null || netsh interface ipv6 install
echo Checking ipv6 protocol ...
netsh interface ipv6 show interface > /dev/null || netsh interface ipv6 install || \
show_error_exit "Failed to install ipv6 protocol."
echo IPv6 protocol has been installed.
# miniupnpc is required by re6stnet
echo Checking miniupnpc ...
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
[[ -f /miniupnpc.tar.gz ]] || show_error_exit "No package found: /miniupnpc.tar.gz"
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 || show_error_exit "Failed to install miniupnpc."
echo "Install miniupnpc OK."
else
echo Check miniupnpc OK.
fi
# pyOpenSSL is required by re6stnet
echo Checking pyOpenSSL ...
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
[[ -f /pyOpenSSL.tar.gz ]] || show_error_exit "No package found: /pyOpenSSL.tar.gz"
echo "Installing pyOpenSSL ..."
cd /opt
tar xzf /pyOpenSSL.tar.gz --no-same-owner
mv $(ls -d pyOpenSSL-*) pyOpenSSL
cd pyOpenSSL
python setup.py install || show_error_exit "Failed ot install pyOpenSSL."
echo "Install pyOpenSSL OK."
else
echo Check pyOpenSSL OK.
fi
# Install re6stnet
echo Checking re6stnet ...
if [[ ! -d /opt/re6stnet ]] ; then
echo "Installing re6stnet ..."
cd /opt
......@@ -286,35 +396,133 @@ if [[ ! -d /opt/re6stnet ]] ; then
git clone -b cygwin http://git.erp5.org/repos/re6stnet.git
fi
cd re6stnet
python setup.py install || echo "Install re6stnet failed."
python setup.py install || show_error_exit "Failed to install re6stnet."
echo "Install re6stnet OK."
else
echo Check re6stnet OK.
fi
echo Checking re6stent configuration ...
mkdir -p /etc/re6stnet
cd /etc/re6stnet
if [[ ! -f re6stnet.conf ]] ; then
re6st-conf --registry http://re6stnet.nexedi.com/
echo Register to http://re6stnet.nexedi.com ...
# Your subnet: 2001:67c:1254:e:19::/80 (CN=917529/32)
mysubnet=$(re6st-conf --registry http://re6stnet.nexedi.com/ --anonymous | grep "^Your subnet:") \
|| show_error_exit "Register to nexedi re6stnet failed"
echo Register OK.
echo
echo $mysubnet
echo
echo Write subnet information to re6stnet.conf
echo "# $mysubnet" >> re6stnet.conf
echo Write "table 0" to re6stnet.conf
echo "table 0" >> re6stnet.conf
fi
[[ ! -f re6stnet.conf ]] && show_error_exit "Register to nexedi re6stnet failed"
grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf
[[ ! -f re6stnet.conf ]] && \
show_error_exit "Failed to register to nexedi re6stnet: no /etc/re6stnet/re6stnet.conf found."
grep -q "^table " re6stnet.conf || \
show_error_exit "Error: no parameter 'table 0' found in the /etc/re6stnet/re6stnet.conf"
grep -q "^# Your subnet: " re6stnet.conf || \
show_error_exit "Error: no subnet found in the /etc/re6stnet/re6stnet.conf"
echo Check re6stnet configuration OK.
#-------------------------------------------------
# Create instance of Web Runner
#-------------------------------------------------
grep -q "location.reload" $slapos_runner_file
if (( $? )) ; then
echo
echo Installing Web Runner ...
echo
#
# 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
re6stnet_ipv6=$(cat /etc/re6stnet/re6stnet.conf | grep "Your subnet" | \
sed -e "s/^.*subnet: //g" -e "s/ (CN.*\$//g")1
echo "Re6stnet address in this computer: $re6stnet_ipv6"
netsh interface ipv6 show addr $slapos_ifname | grep -q $re6stnet_ipv6 || \
netsh interface ipv6 add addr $slapos_ifname re6stnet_ipv6
echo Run slapformat ...
/opt/slapos/bin/slapos node format -cv --now ||
show_error_exit "Failed to run slapos format."
echo
echo "Supply $slaprunner_cfg in the computer $computer_id"
/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 "Request an instance 'Node Runner' ..."
while true ; do
/opt/slapos/bin/slapos node software
/opt/slapos/bin/slapos node instance
/opt/slapos/bin/slapos request $slaprunner_title $slaprunner_cfg --node computer_guid=$computer_id && break
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 $slaprunner_title \
$slaprunner_cfg --node computer_guid=$computer_id \
| grep backend_url | sed -e "s/^.*': '//g" -e "s/',.*$//g")
echo Got node runner url: $slaprunner_url
echo <<EOF > $slapos_runner_file
<html>
<head><title>SlapOS Web Runner</title>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
location.reload("$slaprunner_url")
}
//-->
</script>
</head>
<body onload="openwin()"/>
</html>
EOF
echo Generate file: $slapos_runner_file
# Apply patches to slapos.cookbook for inotifix
patch_file=/etc/slapos/patches/slapos-cookbook-inotifyx.patch
if [[ -f $patch_file ]] ; then
echo "Apply patch: $patch_file"
for x in $(find /opt/slapgrid/ -name slapos.cookbook-*.egg) ; do
echo Apply to $x
cd $x
patch -p1 < $patch_file
done
fi
echo
echo Install Web Runner OK.
echo
fi
#-------------------------------------------------
# Configure crontab
#-------------------------------------------------
cron_file=/var/cron/tabs/$(whoami)
if [[ ! -f $cron_file ]] ; then
cat <<EOF > $cron_file
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin
MAILTO=""
# Run "Installation/Destruction of Software Releases" and "Deploy/Start/Stop Partitions" once per minute
* * * * * Administrator /opt/slapos/bin/slapos node software --verbose --logfile=/opt/slapos/log/slapos-node-software.log > /dev/null 2>&1
* * * * * Administrator /opt/slapos/bin/slapos node instance --verbose --logfile=/opt/slapos/log/slapos-node-instance.log > /dev/null 2>&1
# Run "Destroy Partitions to be destroyed" once per hour
0 * * * * Administrator /opt/slapos/bin/slapos node report --maximal_delay=3600 --verbose --logfile=/opt/slapos/log/slapos-node-report.log > /dev/null 2>&1
# Run "Check/add IPs and so on" once per hour
0 * * * * Administrator /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
# Make sure we have only good network routes if we use VPN
# * * * * * root if [ -f /etc/opt/slapos/openvpn-needed ]; then ifconfig tapVPN | grep "Scope:Global" > /dev/null ;if [ $? = 0 ]; then ROUTES=$(ip -6 r l | grep default | awk '{print $5}'); for GW in $ROUTES ; do if [ ! $GW = tapVPN ]; then /sbin/ip -6 route del default dev $GW > /dev/null 2>&1;fi ;done ;fi ;fi
EOF
fi
echo SlapOS Node configure successfully.
read -n 1 -p "Press any key to exit..."
......
......@@ -19,3 +19,22 @@ if [[ -f $current_path/node-runner.vbs ]] ; then
cyg_cscript $current_path/node-runner.vbs || (echo Failed to start slap-runner ; exit 1)
echo Start slap-runner OK.
fi
cat <<EOF > slap-runner.html
d>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
location.reload("url")
}
//-->
</script>
</head>
<body onload="openwin()">
</body>
</html>
EOF
#! /bin/bash
export PATH=/usr/local/bin:/usr/bin:$PATH
ifname=re6stnet-lo
#
# Check ipv6 connection by default ipv6 route
#
function check_ipv6_connection()
{
netsh interface ipv6 show route | grep -q " ::/0 "
}
ping6 slap.vifib.com > /dev/null
#
# Check cygwin service
#
function check_cygwin_service()
{
service_name=$1
echo Checking $1 service ...
if [ ! -e /usr/bin/cygrunsrv.exe ]; then
show_error_exit "No cygserver found, please install the cygrunsrv package first."
fi
service_account="$(cygrunsrv -VQ $service_name | sed -n -e 's/^Account[ :]*//p')" || \
show_error_exit "No $1 service install, please run Configure SlapOS to install it."
service_state=$(cygrunsrv --query $service_name | sed -n -e 's/^Current State[ :]*//p')
if [[ ! x$service_state == "xRunning" ]] ; then
echo Warning: Cygwin service $1 currnt state is $service_state, Running is expeted
echo Try to use cygrunsrv --start $1 to start this service
fi
echo Check $1 service OVER.
}
#
# 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
}
#-------------------------------------------------
# Constants
#-------------------------------------------------
slapos_ifname=re6stnet-lo
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo "Checking native IPv6 ..."
check_ipv6_connection
# 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 "No native IPv6."
echo Check re6stnet network ...
which re6stnet > /dev/null || show_error_exit "Error: no re6stnet installed, please run Configure SlapOS first."
# re6st-conf --is-needed --registry http://re6stnet.nexedi.com/
ps -ef | grep -q babeld.exe
if (( $? )) ; then
echo "Start re6stnet ..."
# It need root rights to install tap-driver
(cd /etc/re6stnet; re6stnet @re6stnet.conf --ovpnlog -I $slapos_ifname -i $slapos_ifname &)
echo "Start re6stent in the background OK. You can check log files in the /var/log/re6stnet"
echo "Waiting re6stent network work ..."
while true ; do
check_ipv6_connection && break
done
fi
echo "re6stnet network OK."
else
echo "Native IPv6 Found."
fi
# Format slapos node
#-------------------------------------------------
# Check cygserver, syslog-ng
#-------------------------------------------------
check_cygwin_service cygserver
check_cygwin_service syslog-ng
#-------------------------------------------------
# Format slapos node, need root right
#-------------------------------------------------
[[ -f /etc/opt/slapos/slapos.cfg ]] || \
show_error_exit "Error: no node configure file found, please run Configure SlapOS first."
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
/opt/slapos/bin/slapos node format -cv --now || \
show_error_exit "Failed to run slapos format."
echo "Format slapos node OK."
#-------------------------------------------------
# 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
/opt/slapos/bin/slapos node software --verbose
#-------------------------------------------------
# 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
/opt/slapos/bin/slapos node instance --verbose
#-------------------------------------------------
# Send report
/opt/slapos/bin/slapos node report
#-------------------------------------------------
echo "Sending report ..."
/opt/slapos/bin/slapos node report --verbose
exit 0
......@@ -58,6 +58,7 @@ Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app
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-node-runner.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\pre-uninstall.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
......@@ -65,19 +66,19 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.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 -h never -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Node Runner"; Filename: "http://{app}\cygwin\etc\slapos\scripts\slap-runner.html"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.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 -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 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}\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}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"" network"; 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;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Builout process"; StatusMsg: "Building SlapOS..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist;
[UninstallRun]
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist runhidden;
......
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