Commit 96c6e8df authored by Jondy Zhao's avatar Jondy Zhao

refine slapos-configure scripts

parent 2eb41cbf
......@@ -557,7 +557,7 @@ Then upload the source packages dist/psutil-1.0.1.tar.gz to http://www.nexedi.or
</varlistentry>
<varlistentry>
<term>Create network interface for slapos</term>
<listitem><para>Slapos use a msloop insterface as its own interface, default name is 're6stnet-lo'. If there is more than one slapos node in the same machine, each node use a prefix.</para></listitem>
<listitem><para>Slapos use a msloop insterface as its own interface, default name is '$prefix-re6stnet-lo'. The usage of prefix is for running multi-nodes in one same machine.</para></listitem>
</varlistentry>
<varlistentry>
<term>Install re6stnet</term>
......@@ -608,6 +608,7 @@ Most of tasks list above section could be done by shell scripts, now we have the
<itemizedlist>
<listitem><para>setup-cygwin.bat</para></listitem>
<listitem><para>slapos-cygwin-bootstrap.sh</para></listitem>
<listitem><para>build-slapos.sh</para></listitem>
<listitem><para>slapos-configure.sh</para></listitem>
<listitem><para>slapos-node.sh</para></listitem>
<listitem><para>slapos-cleanup.sh</para></listitem>
......
diff --git a/options.py~ b/options.py
old mode 100644
new mode 100755
index 3ccab60..e220c10
--- a/options.py~
+++ b/options.py
diff --git a/supervisor/options.py b/supervisor/options.py
index 3ccab60..e220c10 100644
--- a/supervisor/options.py
+++ b/supervisor/options.py
@@ -1197,7 +1197,7 @@ class ServerOptions(Options):
return
......
#! /bin/bash
#
# This script is used to build slapos node from source.
#
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then
echo "Error: Missing csih package."
exit 1
fi
function show_error_exit()
function show_usage()
{
echo Error: ${1:-"build slapos failed."}
read -n 1 -p "Press any key to exit..."
exit 1
echo "This script is used to build slapos node in the Cygwin."
echo ""
echo "Usage: ./build-slapos.sh"
echo ""
}
readonly -f show_usage
function slapos_buildout()
{
# -----------------------------------------------------------
# Run the buildout of slapos node
# -----------------------------------------------------------
csih_inform "Starting run buildout of slapos node ..."
csih_inform "mkdir /opt/slapos/log"
mkdir -p ${slapos_home}/log
slapos_home=${1:-/opt/slapos}
slapos_cache=/opt/download-cache
slapos_url=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/component/slapos/buildout.cfg
slapos_cfg=$slapos_home/buildout.cfg
slapos_bootstrap=$slapos_home/bootstrap.py
patch_files=/etc/slapos/patches/slapos-core-format.patch
mkdir -p $slapos_home/log
mkdir -p $slapos_cache
echo "Checking $slapos_cfg ..."
if [[ -r $slapos_cfg ]] ; then
echo "Change $slapos_cfg:"
echo " extends = ${slapos_url}"
sed -i -e "s%^extends = .*$%extends = ${slapos_url}%g" $slapos_cfg
else
cat <<EOF > $slapos_cfg
[buildout]
csih_inform "mkdir /opt/download-cache"
mkdir -p ${slapos_cache}
[[ ! -f ${slapos_cfg} ]] &&
echo "[buildout]
extends = ${slapos_url}
download-cache = ${slapos_cache}
prefix = $${buildout:directory}
EOF
echo "File $slapos_cfg has been generated."
fi
prefix = ${buildout:directory}
" > ${slapos_cfg} &&
csih_inform "${slapos_cfg} generated"
echo "Checking $slapos_bootstrap ..."
if [[ ! -f $slapos_bootstrap ]] ; then
echo "Downloading $slapos_bootstrap ..."
python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > $slapos_bootstrap ||
show_error_exit "Error: download $slapos_bootstrap"
echo "Downlaod $slapos_bootstrap OK."
else
echo OK.
fi
[[ -f ${slapos_bootstrap} ]] ||
python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > ${slapos_bootstrap} ||
csih_error "download bootstrap.py failed"
csih_inform "download ${slapos_bootstrap} OK"
if [[ ! -x $slapos_home/run/buildout ]] ; then
echo "Bootstrap slapos ..."
(cd $slapos_home ; python -S bootstrap.py) || show_error_exit "Error: slapos bootstrap failed."
echo "Bootstrap slapos OK."
fi
[[ -x ${slapos_home}/bin/buildout ]] ||
(cd ${slapos_home} && python -S bootstrap.py) ||
csih_error "run bootstrap.py failed"
csih_inform "run bootstrap.py OK"
csih_inform "start bin/buildout"
(cd ${slapos_home} ; bin/buildout -v -N) || csih_error "bin/buildout failed"
_filename=~/slapos-core-format.patch
[[ -f ${_filename} ]] ||
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_filename}) -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
echo
echo Start buildout of slapos ...
echo
(cd $slapos_home ; $slapos_home/bin/buildout -v -N) || show_error_exit "Error slapos buildout failed."
# apply patches
for _filename in $patch_files ; do
if [[ -r ${_filename} ]] ; then
echo "Apply patch: ${_filename}"
for _path in $(find $slapos_home/eggs -name slapos.core-*.egg) ; do
echo " at ${_path} ..."
(cd ${_path} ; patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} && echo "OK.")
done
fi
csih_inform "applay patch ${_filename}"
(cd $(ls -d ${slapos_home}/eggs/slapos.core-*.egg/) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
_filename=~/supervisor-cygwin.patch
[[ -f ${_filename} ]] ||
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_filename}) -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
csih_inform "applay patch ${_filename}"
(cd $(ls -d ${slapos_home}/eggs/supervisor-*.egg) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
csih_inform "Run buildout of slapos node OK"
echo ""
}
readonly -f slapos_buildout
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
csih_inform "Start slapos node configure ..."
echo ""
# -----------------------------------------------------------
# Local variable
# -----------------------------------------------------------
declare -r slapos_home=/opt/slapos
declare -r slapos_cache=/opt/download-cache
declare -r slapos_url=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg
declare -r slapos_cfg=${slapos_home}/buildout.cfg
declare -r slapos_bootstrap=${slapos_home}/bootstrap.py
# -----------------------------------------------------------
# Command line options
# -----------------------------------------------------------
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
-h | --help)
show_usage
exit 0
;;
*)
show_usage
exit 1
;;
esac
# Next please.
shift
done
echo
echo Build slapos node successfully.
echo
# -----------------------------------------------------------
# Build SlapOS
# -----------------------------------------------------------
slapos_buildout
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo ""
csih_inform "Build slapos successfully."
echo ""
read -n 1 -t 60 -p "Press any key to exit..."
exit 0
......@@ -27,94 +27,9 @@ readonly -f show_error_exit
declare -r slapos_prefix=$1
declare -r _cygroot=$(cygpath -w /)
_filename=/etc/passwd
echo "Checking ${_filename} ..."
if [[ ! -f ${_filename} ]] ; then
mkpasswd -l > ${_filename} || show_error_exit "Error: mkpasswd failed"
echo "${_filename} has been generated."
else
echo OK.
fi
_filename=/etc/group
echo "Checking ${_filename} ..."
if [[ ! -f ${_filename} ]] ; then
mkgroup -l > ${_filename} || show_error_exit "Error: mkgroup failed"
echo "${_filename} has been generated."
else
echo OK.
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
_charset=$(ipwin codepage) || _charset=""
echo "Windows OEM Codepage is ${_charset}"
_filename=".minttyrc"
echo Checking ${_filename} ...
if [[ ! -f ${_filename} ]] ; then
cat <<EOF > ${_filename}
BoldAsFont=no
Font=Courier New
FontHeight=16
Scrollbar=none
Locale=C
Charset=${_charset}
EOF
echo "${_filename} has been generated."
else
echo OK.
fi
_filename="/cygtty.bat"
echo Checking ${_filename} ...
if [[ ! -x ${_filename} ]] ; then
cat <<EOF > ${_filename}
@echo off
${_cygroot:0:2}
chdir ${_cygroot}\\bin
start mintty.exe -i /Cygwin-Terminal.ico -
EOF
chmod +x ${_filename}
echo "${_filename} has been generated."
else
echo OK.
fi
_filename="/autorebase.bat"
echo Checking ${_filename} ...
if [[ ! -f ${_filename} ]] ; then
cat <<EOF > ${_filename}
@echo off
${_cygroot:0:2}
CHDIR ${_cygroot}
${_cygroot}\bin\find /opt/slapos -name "*.dll" > ${_cygroot}\myfile.list
IF EXIST ${_cygroot}\opt\slapgrid. ${_cygroot}\bin\find /opt/slapgrid -name "*.dll" >> ${_cygroot}\myfile.list
NET STOP ${slapos_prefix}cron
NET STOP ${slapos_prefix}re6stnet
NET STOP ${slapos_prefix}syslog-ng
NET STOP ${slapos_prefix}cygserver
bin\bash --login -c "for pid in \$(ps | grep '/usr/bin/python2.7' | gawk '{print \$4}') ; do TASKKILL /F /T /PID \$pid ; done"
PATH .\bin;%PATH%
dash /bin/rebaseall -T /myfile.list -v
EXIT 0
EOF
chmod +x ${_filename}
echo "${_filename} has been generated."
else
echo OK.
fi
# Change format of readme.txt
_filename=$(cygpath -u $(cygpath -m /)/../readme.txt)
......@@ -142,26 +57,6 @@ elif [[ ! -d /opt/slapos ]] ; then
echo "Warning: missing ${_filename}"
fi
# Patch cygport, so that we can specify package prefix by ourself.
_filename=/usr/bin/cygport
if [[ -f ${_filename} ]] ; then
echo "Patching ${_filename} ..."
sed -i -e 's/D="${workdir}\/inst"/D="${CYGCONF_PREFIX-${workdir}\/inst}"/g' ${_filename} &&
echo OK.
fi
_filename=/usr/share/cygport/cygclass/autotools.cygclass
if [[ -f ${_filename} ]] ; then
echo "Patching ${_filename} ..."
sed -i -e 's/prefix=$(__host_prefix)/prefix=${CYGCONF_PREFIX-$(__host_prefix)}/g' ${_filename} &&
echo OK.
fi
_filename=/usr/share/cygport/cygclass/cmake.cygclass
if [[ -f ${_filename} ]] ; then
echo "Patching ${_filename} ..."
sed -i -e 's/-DCMAKE_INSTALL_PREFIX=$(__host_prefix)/-DCMAKE_INSTALL_PREFIX=${CYGCONF_PREFIX-$(__host_prefix)}/g' ${_filename} &&
echo OK.
fi
# Set prefix for slapos
if [[ -n ${slapos_prefix} ]] ; then
echo "Set slapos prefix as ${slapos_prefix}"
......
@ECHO OFF
REM Usage: setup-cygwin.bat [install-path] [network | url]
REM
REM Before run this script, you must download setup-x86.exe or setup-x64_86.exe from cygwin.com
REM and save it as setup.exe in local machine.
REM
REM For examples,
REM
REM 1. Install cygwin in the current path
REM
REM C:/slapos> setup-cygwin.bat
REM
REM Before run this command, C:/slapos/setup.exe must be exists and you will downloads all
REM required cygwin packages in the path C:/slapos/cygwin-packages
REM
REM 2. Install cygwin from network, C:/slapos/setup.exe must be exists before run this command
REM
REM C:/slapos> setup-cygwin.bat network
REM
REM It will download cygwin packages and save them in the path C:/slapos/cygwin-packages,
REM then install cygwin in the C:/slapos/cygwin
REM
REM 3. Install cygwin in the C:/slapos-node, you need copy setup.exe to C:/slapos-node first
REM
REM C:/slapos> setup-cygwin.bat C:\slapos-node network
REM
REM Notice: Run above examples in the windows command box.
REM
SETLOCAL
SET CYGWINHOME=%~1\
SET CYGWINROOT="%~1\cygwin"
IF NOT "%1" == "" GOTO INIT
IF "%1" == "network" GOTO INIT0
IF NOT "%1" == "" GOTO INIT1
:INIT0
SET CYGWINHOME=%~dp0
SET CYGWINROOT="%~dp0cygwin"
:INIT
:INIT1
SET DOWNLOADPATH="%CYGWINHOME%cygwin-packages"
SET SETUPFILE="%CYGWINHOME%setup.exe"
SET OPTIONS=--no-shortcuts --no-startmenu --quiet-mode --no-verify
......@@ -33,7 +64,7 @@ GOTO END
:REMOTE_INSTALL
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 libwrap-devel
REM Only required by developer
REM SET PACKAGES=%PACKAGES% -P docbook-utils
REM SET PACKAGES=%PACKAGES% -P docbook-xsl -P docbook-xsl-ns -P mingw-gcc -P mingw64-i686-gcc -P mingw64-x86_64-gcc
SET SITEOPTIONS=-s http://www.netgull.com/cygwin
REM ECHO %2 | FINDSTR \. > /NULL
REM IF %ERRORLEVEL% == 0 SET SITEOPTIONS=--site %2 --only-site
......
......@@ -63,8 +63,8 @@ Source: "cygwin\opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver"
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-include.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-cygwin-bootstrap.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-cleanup.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
......@@ -84,8 +84,8 @@ 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;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-cygwin-bootstrap.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /usr/bin/tar -xzf /opt/downloads/slapos.tar.gz"; WorkingDir: "{app}\cygwin\opt"; Description: "Configure Cygwin"; StatusMsg: "Extract slapos node ...";
[UninstallRun]
Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Uninstall SlapOS"" /etc/slapos/scripts/slapos-cleanup.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist;
......
#! /bin/bash
#
# This script is used to build slapos installer of windows.
# This script is used to build slapos installer of windows. There are 2
# scripts need to run in prior:
#
# slapos-cygwin-bootstrap.sh
#
# build-slapos.sh
#
# In this script, it will do:
#
# * Prepare sources
#
# * Make installer
#
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then
echo "Error: Missing csih package."
exit 1
fi
# ======================================================================
# Functions
# ======================================================================
function check_os_is_wow64()
{
[[ $(uname) == CYGWIN_NT-*-WOW64 ]]
......@@ -17,12 +37,9 @@ function show_usage()
}
readonly -f show_usage
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then
echo "Error: Missing csih package."
exit 1
fi
# ======================================================================
# Start script
# ======================================================================
csih_inform "Starting build Slapos Windows installer ..."
echo ""
......@@ -33,7 +50,7 @@ declare -r cygwin_home=$(cygpath -a $(cygpath -w /)\\.. | sed -e "s%/$%%")
declare -r ISCC=${cygwin_home}/inno-setup/ISCC.exe
# -----------------------------------------------------------
# Command line options
# Start script
# -----------------------------------------------------------
while test $# -gt 0; do
# Normalize the prefix.
......@@ -43,9 +60,9 @@ while test $# -gt 0; do
esac
case "$1" in
install)
-h | --help)
show_usage
exit 0
;;
*)
show_usage
exit 1
......@@ -56,145 +73,6 @@ while test $# -gt 0; do
shift
done
# -----------------------------------------------------------
# Patch cygwin packages for building slapos
# -----------------------------------------------------------
csih_inform "Patching cygwin packages for building slapos"
csih_inform "libtool patched"
sed -i -e "s/4\.3\.4/4.5.3/g" /usr/bin/libtool
csih_inform "/etc/passwd generated"
[[ -f /etc/passwd ]] || mkpasswd > /etc/passwd
csih_inform "/etc/group generated"
[[ -f /etc/group ]] || mkgroup > /etc/group
_filename=/usr/bin/cygport
if [[ -f ${_filename} ]] ; then
csih_inform "Patching ${_filename} ..."
sed -i -e 's/D="${workdir}\/inst"/D="${CYGCONF_PREFIX-${workdir}\/inst}"/g' ${_filename} &&
csih_inform "OK"
else
csih_error "Missing cygport package, no ${_filename} found."
fi
_filename=/usr/share/cygport/cygclass/autotools.cygclass
if [[ -f ${_filename} ]] ; then
csih_inform "Patching ${_filename} ..."
sed -i -e 's/prefix=$(__host_prefix)/prefix=${CYGCONF_PREFIX-$(__host_prefix)}/g' ${_filename} &&
csih_inform "OK"
else
csih_error "Missing cygport package, no ${_filename} found."
fi
_filename=/usr/share/cygport/cygclass/cmake.cygclass
if [[ -f ${_filename} ]] ; then
csih_inform "Patching ${_filename} ..."
sed -i -e 's/-DCMAKE_INSTALL_PREFIX=$(__host_prefix)/-DCMAKE_INSTALL_PREFIX=${CYGCONF_PREFIX-$(__host_prefix)}/g' ${_filename} &&
csih_inform "OK"
else
csih_error "Missing cygport package, no ${_filename} found."
fi
for _cmdname in ip useradd usermod groupadd brctl tunctl ; do
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/scripts/${_cmdname} -O /usr/bin/${_cmdname} ||
csih_error "download ${_cmdname} failed"
csih_inform "download cygwin script ${_cmdname} OK"
chmod +x /usr/bin/${_cmdname} || csih_error "chmod /usr/bin/${_cmdname} failed"
done
if check_os_is_wow64 ; then
wget -c http://dashingsoft.com/products/slapos/ipwin_x64.exe -O /usr/bin/ipwin.exe ||
csih_error "download ipwin_x64.exe failed"
csih_inform "download ipwin_x64.exe OK"
else
wget -c http://dashingsoft.com/products/slapos/ipwin_x86.exe -O /usr/bin/ipwin.exe ||
csih_error "download ipwin_x86.exe failed"
csih_inform "download ipwin_x86.exe OK"
fi
chmod +x /usr/bin/ipwin.exe || csih_error "chmod /usr/bin/ipwin.exe failed"
csih_inform "Patch cygwin packages for building slapos OK"
echo ""
# -----------------------------------------------------------
# Make directories
# -----------------------------------------------------------
_optdir=${cygwin_home}/opt
csih_inform "mkdir ${_optdir}"
mkdir -p ${_optdir}
[[ -d /opt ]] && [[ ! -h /opt ]] &&
csih_error_multi "/opt isn't a symbol link" \
"in order to build the installer by this script, " \
"/opt should be link to ${_optdir}"
[[ -h /opt ]] &&
! ls -ld /opt | grep -q "\-> ${_optdir}" &&
csih_error_multi "in order to build the installer by this script, " \
"/opt should be link to ${_optdir}" \
"now /opt link to another directory"
[[ ! -d /opt ]] &&
csih_inform "link ${_optdir} to /opt" &&
(ln -s ${_optdir} /opt || csih_error "create link failed")
csih_inform "mkdir /opt/slapos/log"
mkdir -p /opt/slapos/log
csih_inform "mkdir /opt/download-cache"
mkdir -p /opt/download-cache
csih_inform "mkdir /opt/git"
mkdir -p /opt/git
csih_inform "mkdir /opt/downloads"
mkdir -p /opt/downloads
echo ""
# -----------------------------------------------------------
# Run the buildout of slapos node
# -----------------------------------------------------------
csih_inform "Starting run buildout of slapos node ..."
[[ -f /opt/slapos/buildout.cfg ]] ||
(cd /opt/slapos && echo "[buildout]
extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg
download-cache = /opt/download-cache
prefix = ${buildout:directory}
" > buildout.cfg) &&
csih_inform "buildout.cfg generated"
[[ -f /opt/slapos/bootstrap.py ]] ||
(cd /opt/slapos &&
python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > bootstrap.py ) ||
csih_error "download bootstrap.py failed"
csih_inform "download bootstrap.py OK"
[[ -f /opt/slapos/bin/buildout ]] ||
(cd /opt/slapos && python -S bootstrap.py) ||
csih_error "run bootstrap.py failed"
csih_inform "run bootstrap.py OK"
csih_inform "start bin/buildout"
(cd /opt/slapos && /opt/slapos/bin/buildout -v -N) || csih_error "bin/buildout failed"
_filename=~/slapos-core-format.patch
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/slapos-core-format.patch -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
csih_inform "applay patch ${_filename}"
(cd $(ls -d /opt/slapos/eggs/slapos.core-*.egg/) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
csih_inform "Run buildout of slapos node OK"
echo ""
# -----------------------------------------------------------
# Prepare the sources used to build installer
# -----------------------------------------------------------
......@@ -229,17 +107,25 @@ else
csih_error "make babeld failed"
fi
csih_inform "making openvpn for cygwin ..."
[[ -f /opt/git/slapos.package/windows/openvpn/Makefile ]] ||
(cd /opt/git/slapos.package/windows/openvpn &&
libtoolize &&
aclocal -I m4 &&
autoheader &&
automake --add-missing &&
autoreconf &&
ac_cv_type_socklen_t=yes IFCONFIG="C:/WINDOWS/system32" LDFLAGS="-liphlpapi -lws2_32" CFLAGS="-DWIN32 -DCYGWIN -D__USE_W32_SOCKETS -D__INSIDE_CYGWIN_NET__ -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0503 -g" OPENSSL_CRYPTO_CFLAGS=-I/usr/include OPENSSL_CRYPTO_LIBS="-L/usr/lib -lcrypto" OPENSSL_SSL_CFLAGS=-I/usr/include OPENSSL_SSL_LIBS="-L/usr/lib -lssl" ./configure --disable-lzo --disable-pkcs11 --disable-plugin-auth-pam --disable-plugin-down-root) ||
csih_error "openvpn configure failed"
(cd /opt/git/slapos.package/windows/openvpn && make)|| csih_error "make openvpn failed"
_filename=/opt/git/slapos.package/windows/scripts/regpwd.exe
[[ ! -f ${_filename} ]] &&
(cd /opt/git/slapos.package/windows/scripts ; gcc -o regpwd.exe regpwd.c) &&
csih_inform "make regpwd.exe"
_filename=~/openvpn-driver.tar.gz
if check_os_is_wow64 ; then
_url=http://www.dashingsoft.com/products/slapos/openvpn-x64.tar.gz
else
_url=http://www.dashingsoft.com/products/slapos/openvpn-x86.tar.gz
fi
wget -c ${_url} -O ${_filename} ||
csih_error_multi "download ${_filename} failed" " from ${_url}"
csih_inform "Got ${_filename}"
csih_inform " from ${_url}"
csih_inform "extracting ${_filename} ..."
(cd /opt ; tar xzf ${_filename} --no-same-owner) ||
csih_error "extract ${_filename} failed"
_filename=/opt/downloads/pyOpenSSL-0.13.tar.gz
wget -c --no-check-certificate https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz#md5=767bca18a71178ca353dff9e10941929 -O ${_filename} ||
......@@ -256,6 +142,14 @@ csih_inform "updating re6stnet.git ..."
(cd /opt/git ; git clone -b cygwin http://git.erp5.org/repos/re6stnet.git) ||
csih_error "clone/pull re6stnet.git failed"
# # Now package i686-w64-mingw32-gcc isn't installed, so ignore it in temporary
# csih_inform "building ovpn-client and ovpn-server ..."
# for _name in ovpn-client ovpn-server ; do
# (cd /opt/git/re6stnet/re6st ; i686-w64-mingw32-gcc -o ${_name}.exe ${_name}.c ovpn-pipe.c) ||
# csih_error "build ${_name}.exe failed"
# csih_inform "build ${_name}.exe OK"
# done
csih_inform "creating re6stnet source package ..."
(cd /opt/git/re6stnet ; python setup.py sdist) ||
csih_error "create re6stnet source package failed"
......@@ -269,26 +163,18 @@ csih_inform "extracting ${_filename} ..."
(cd /opt ; tar xzf ${_filename} --no-same-owner) ||
csih_error "extract ${_filename} failed"
_filename=~/openvpn-driver.tar.gz
# This command need microsoft sdk to build, so we just copy it
_filename=/opt/git/slapos.package/windows/ipwin/ipwin/ipwin.exe
if check_os_is_wow64 ; then
_url=http://www.dashingsoft.com/products/slapos/openvpn-driver-x64.tar.gz
_url=http://www.dashingsoft.com/products/slapos/ipwin-x64.tar.gz
else
_url=http://www.dashingsoft.com/products/slapos/openvpn-driver-x86.tar.gz
_url=http://www.dashingsoft.com/products/slapos/ipwin-x86.tar.gz
fi
wget -c ${_url} -O ${_filename} ||
csih_error_multi "download ${_filename} failed" " from ${_url}"
csih_inform "Got ${_filename}"
csih_inform " from ${_url}"
csih_inform "extracting ${_filename} ..."
(cd /opt ; tar xzf ${_filename} --no-same-owner) ||
csih_error "extract ${_filename} failed"
_filename=/opt/git/slapos.package/windows/ipwin/ipwin/ipwin.exe
[[ ! -f ${_filename} ]] &&
cp /usr/bin/ipwin.exe ${_filename} &&
csih_inform "copy ipwin.exe"
csih_inform "Prepare the sources OK"
echo ""
......@@ -311,7 +197,7 @@ csih_inform "patch ${_issfile} ..."
sed -i -e "s%^OutputBaseFilename=.*%OutputBaseFilename=${_installer_name}%" \
-e "s%^OutputDir=.*%OutputDir=${_output_dir}%" \
-e "s%^SourceDir=.*%SourceDir=${_source_dir}%" \
-e "s%/etc/slapos/scripts/post-install.sh%/etc/slapos/scripts/post-install.sh slaptest-%" \
-e "s%/etc/slapos/scripts/slapos-cygwin-bootstrap.sh%/etc/slapos/scripts/slapos-cygwin-bootstrap.sh --prefix=slaptest-%" \
${_issfile} || csih_error "patch failed"
csih_inform "run issc to build ${_issfile} ..."
......@@ -322,7 +208,7 @@ csih_inform "Generate Windows installer OK"
echo ""
# -----------------------------------------------------------
# Finish
# End scirpt
# -----------------------------------------------------------
echo ""
csih_inform "Build Slapos Windows installer successfully."
......
......@@ -3,23 +3,32 @@
# When uninstall slapos, it will be called by uninstaller. Root right
# required to run this script.
#
# /bin/bash/ --login -i pre-uninstall.sh
#
# It will do:
#
# * Remove virtual netcards installed by re6stnet
#
# * Remove service cron, cygserver syslog-ng re6stnet
#
# * Remove account/group added by slapos configure script
#
# * Remove instance and software root /srv/slapgrid /opt/slapgrid
#
# Required:
# grep gawk TASKKILL
# /bin/bash/ --login -i slapos-cleanup.sh
#
source $(/usr/bin/dirname $0)/slapos-include.sh
function show_usage()
{
echo "This script is used to remove everything added by slapos node."
echo ""
echo "Usage: ./slapos-cleanup.sh"
echo ""
echo " It will do:"
echo ""
echo " * Remove virtual netcards installed by re6stnet"
echo ""
echo " * Remove service cron, cygserver syslog-ng re6stnet"
echo ""
echo " * Remove account/group added by slapos configure script"
echo ""
echo " * Remove instance and software root /srv/slapgrid /opt/slapgrid"
echo ""
echo "After run this script, you got a clean enviroments. Then you can run"
echo "slapos-configure.sh to configure slapos node again."
echo ""
}
readonly -f show_usage
function slapos_kill_process()
{
name=$1
......@@ -31,6 +40,34 @@ function slapos_kill_process()
}
readonly -f slapos_kill_process
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
echo "Start cleanup slapos node ..."
echo ""
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
-h | --help)
show_usage
exit 0
;;
*)
show_usage
exit 1
;;
esac
# Next please.
shift
done
#
# Remove services installed by cygwin,
#
......@@ -112,8 +149,12 @@ done
echo "Creating /etc/group ..."
mkgroup -l > /etc/group && echo OK.
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo
echo Run pre-uninstall script complete.
echo
read -n 1 -t 60 -p "Press any key to exit..."
exit 0
#! /bin/bash
#
# This script need root rights. Before run it, make sure you have root
# right.
# right. In Windows 7 and later,, you can start terminal by clicking
# Run as Administrator, then run this script in this terminal.
#
# It used to 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
# * Create a super user who owns Administrator group rights
#
# * Check IPv6 protocol and install it if require
# * re6stnet: Install re6stnet and register to nexedi re6stnet
#
# * Create user slaproot who owns Administrator group rights
# * network: Install msloop network adapter for slapos node
#
# * Configure and start cygwin service: cygserver, syslog-ng
# * node: Create node configure file by ca/key
#
# * config: Create node and client configure file by parameters ca/key
# * client: Create client configure file by ca/key
#
# * re6stnet: Install re6stnet and register to nexedi re6stnet if required
# * openvpn: Install openvpn and re6stnet service if required
#
# * cron: create cron configure file
# * cron: Configure cron service if required
#
# * startup: add this script as startup item
# * slap-runner: Create slapos-webrunner instance in this node.
#
# * test-agent: Create test-agent instance in this node.
#
source $(/usr/bin/dirname $0)/slapos-include.sh
# ======================================================================
# Functions
# ======================================================================
function show_usage()
{
echo ""
echo "Usage:"
echo ""
echo " ./slapos-configure [options] [action] [configure item]"
echo " ./slapos-configure.sh [options] [configure items]"
echo ""
echo " Availabe options:"
echo ""
echo " -P, --password=XXX password of slapos administrator"
echo ""
echo " --computer-certificate=FILENAME"
echo " --computer-key=FILENAME"
echo " --client-certificate=FILENAME"
echo " --client-key=FILENAME"
echo " --ipv4-local-network=x.x.x.x/n"
echo " --ipv6-local-address=::"
echo " -f, --force Reinstall even the item has"
echo " been installed"
echo ""
echo " The action option:"
echo " The configure items could be one or more of the following values:"
echo ""
echo " --install Install only when the item hasn't been installed"
echo " --query Interactive to install all the item"
echo " --overwite Overwrite the item even it has been installed"
echo " --uninstall Remove the configure item"
echo " auto Install only required configure items (default)"
echo " re6stnet Install re6stnet and dependencies"
echo " network Install msloop network connection for slapos"
echo " node Generate slapos node configure files"
echo " client Generate slapos client configure files"
echo " openvpn Install openvpn and re6stnet service"
echo " cron Generate cron file and start cron job"
echo " runner Create slap-runner instance"
echo " test-agent Create test-agent instance"
echo ""
echo " Default is --install"
echo " If no configure items specified, it's same as 'auto'. In this way: "
echo ""
echo " The configure item option:"
echo " re6stnet will not be installed if --ipv6-local-address specified"
echo ""
echo " * All the configure item"
echo " re6stnet Install re6stnet and dependencies"
echo " config Generate slapos node and client configure files"
echo " cron Generate cron file and start cron job"
echo " openvpn will not be installed if native IPv6 works"
echo ""
echo " client will not be installed if no --client-x specified "
echo ""
echo " runner will not be installed"
echo ""
echo " test-agent will not be installed"
echo ""
}
readonly -f show_usage
source $(/usr/bin/dirname $0)/slapos-include.sh
csih_inform "Start slapos node configure ..."
echo ""
# -----------------------------------------------------------
# Local variable
# -----------------------------------------------------------
declare _administrator=${slapos_administrator}
declare _password=
declare _computer_certificate=
declare _computer_key=
declare _client_certificate=
declare _client_key=
declare _ipv4_local_network=${ipv4_local_network}
# -----------------------------------------------------------
# Command line options
# -----------------------------------------------------------
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--password=*)
_password=$optarg
;;
-P)
_password=$2
shift
;;
-P)
_administrator=$2
shift
;;
--computer-certificate=*)
_computer_certificate=$optarg
;;
--computer-key=*)
_computer_key=$optarg
;;
--client-certificate=*)
_client_certificate=$optarg
;;
--client-key=*)
_client_key=$optarg
;;
--ipv4-local-network=*)
[[ x$optarg == x*.*.*.*/* ]] ||
csih_error "invalid --ipv4-local-network=$optarg, no match x.x.x.x/x"
_ipv4_local_network=$optarg
;;
*)
show_usage
exit 1
;;
esac
# Next please.
shift
done
# -----------------------------------------------------------
# Check and configure cygwin environments
# -----------------------------------------------------------
if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then
for profile in ~/.bash_profile ~/.profile ; do
! grep -q "export PATH=/opt/slapos/bin:" $profile &&
csih_inform "add /opt/slapos/bin to PATH" &&
echo "export PATH=/opt/slapos/bin:\${PATH}" >> $profile
done
fi
csih_check_program_or_error /usr/bin/cygrunsrv cygserver
csih_check_program_or_error /usr/bin/syslog-ng-config syslog-ng
csih_check_program_or_error /usr/bin/openssl openssl
csih_check_program_or_error /usr/bin/slapos-cron-config slapos-cywgin
csih_check_program_or_error /usr/bin/ipwin slapos-cygwin
csih_check_program_or_error /usr/bin/ip slapos-cygwin
csih_check_program_or_error /usr/bin/useradd slapos-cygwin
csih_check_program_or_error /usr/bin/usermod slapos-cygwin
csih_check_program_or_error /usr/bin/regpwd slapos-cygwin
# -----------------------------------------------------------
# Create paths
# -----------------------------------------------------------
mkdir -p /etc/opt/slapos/ssl/partition_pki
mkdir -p ${slapos_client_home}
mkdir -p /opt/slapos/log
mkdir -p /opt/download-cache
mkdir -p /opt/downloads
mkdir -p /etc/slapos/scripts
mkdir -p /etc/re6stnet
# -----------------------------------------------------------
# Create account: slaproot
# -----------------------------------------------------------
# Start seclogon service in Windows XP
if csih_is_xp ; then
csih_inform "Set start property of seclogon to auto"
sc config seclogon start= auto ||
csih_warning "failed to set seclogon to auto start."
# In the later, it's RunAs service, and will start by default
fi
# echo Checking slapos account ${_administrator} ...
slapos_check_and_create_privileged_user ${_administrator} ${_password} ||
csih_error "failed to create account ${_administrator}."
function configure_sanity_check()
{
csih_check_program_or_error /usr/bin/cygrunsrv cygserver
csih_check_program_or_error /usr/bin/syslog-ng-config syslog-ng
csih_check_program_or_error /usr/sbin/cron cron
csih_check_program_or_error /usr/bin/slapos-cron-config slapos-cywgin
csih_check_program_or_error /usr/bin/ipwin slapos-cygwin
csih_check_program_or_error /usr/bin/ip slapos-cygwin
csih_check_program_or_error /usr/bin/useradd slapos-cygwin
csih_check_program_or_error /usr/bin/usermod slapos-cygwin
csih_check_program_or_error /usr/bin/regpwd slapos-cygwin
}
readonly -f configure_sanity_check
# -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng
# -----------------------------------------------------------
csih_inform "Starting configure cygwin services ..."
if ! cygrunsrv --query ${cygserver_service_name} > /dev/null 2>&1 ; then
function configure_create_cygwin_service()
{
if ! cygrunsrv --query ${cygserver_service_name} > /dev/null 2>&1 ; then
csih_inform "run cygserver-config ..."
/usr/bin/cygserver-config --yes || \
csih_error "failed to run cygserver-config"
[[ ${cygserver_service_name} == cygserver ]] ||
cygrunsrv -I ${cygserver_service_name} -d "CYGWIN ${cygserver_service_name}" -p /usr/sbin/cygserver ||
csih_error "failed to install service ${cygserver_service_name}"
else
else
csih_inform "the cygserver service has been installed"
fi
check_cygwin_service ${cygserver_service_name}
fi
check_cygwin_service ${cygserver_service_name}
if ! cygrunsrv --query ${syslog_service_name} > /dev/null 2>&1 ; then
if ! cygrunsrv --query ${syslog_service_name} > /dev/null 2>&1 ; then
csih_inform "run syslog-ng-config ..."
/usr/bin/syslog-ng-config --yes || \
csih_error "failed to run syslog-ng-config"
......@@ -194,193 +113,17 @@ if ! cygrunsrv --query ${syslog_service_name} > /dev/null 2>&1 ; then
cygrunsrv -I ${syslog_service_name} -d "CYGWIN ${syslog_service_name}" -p /usr/sbin/syslog-ng -a "-F" ||
csih_error "failed to install service ${syslog_service_name}"
else
else
csih_inform "the syslog-ng service has been installed"
fi
check_cygwin_service ${syslog_service_name}
# Use slapos-cron-config to configure slapos cron service.
if ! cygrunsrv --query ${cron_service_name} > /dev/null 2>&1 ; then
[[ -x ${slapos_cron_config} ]] ||
csih_error "Couldn't find slapos cron config script: ${slapos_cron_config}"
if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install cron service need the password of ${_administrator}."
fi
check_cygwin_service ${syslog_service_name}
}
readonly -f configure_create_cygwin_service
csih_inform "run slapos-cron-config ..."
${slapos_cron_config} ${cron_service_name} ${_administrator} ${csih_PRIVILEGED_PASSWORD} ||
csih_error "Failed to run ${slapos_cron_config}"
else
csih_inform "the cron service has been installed"
fi
check_cygwin_service ${cron_service_name}
csih_inform "Configure cygwin services OK"
echo ""
# -----------------------------------------------------------
# Install network connection used by slapos node
# -----------------------------------------------------------
csih_inform "Starting configure slapos network ..."
if ! netsh interface ipv6 show interface | grep -q "\\b${slapos_ifname}\\b" ; then
csih_inform "Installing network interface ${slapos_ifname} ..."
ipwin install netloop.inf *msloop ${slapos_ifname} ||
csih_error "install network interface ${slapos_ifname} failed"
fi
ip -4 addr add $(echo ${_ipv4_local_network} | sed -e "s%\.0/%.1/%g") dev ${slapos_ifname} ||
csih_error "add ipv4 address failed"
csih_inform "Configure slapos network OK"
echo ""
# -----------------------------------------------------------
# Check IPv6 protocol, install it if it isn't installed
# -----------------------------------------------------------
csih_inform "Starting configure IPv6 protocol ..."
netsh interface ipv6 show interface > /dev/null || \
netsh interface ipv6 install || \
csih_error "install IPv6 protocol failed"
csih_inform "Configure IPv6 protocol OK"
echo ""
# -----------------------------------------------------------
# config: Generate slapos node and client configure file
# -----------------------------------------------------------
csih_inform "Starting configure slapos client and node ..."
[[ -r ${node_template_file} && -r ${client_template_file} ]] || \
create_template_configure_file || \
csih_error "Failed to create template configure file."
sed -i -e "/^alias/,\$d" ${client_template_file}
echo "alias =
apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/apache-frontend/software.cfg
erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg
mariadb http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/mariadb/software.cfg
mysql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/mysql-5.1/software.cfg
slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slaprunner-lite/software.cfg
wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/wordpress/software.cfg
netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/netdrive-reporter/software.cfg" \
>> ${client_template_file}
if [[ ! -f ${node_certificate_file} ]] ; then
_filename=${_computer_certificate}
[[ -z "${_filename}" ]] &&
read -p "Where is computer certificate file $(cygpath -w /computer.crt): " _filename
[[ -z "${_filename}" ]] && _filename="/computer.crt"
[[ ! -r "${_filename}" ]] && \
csih_error "Computer certificate file ${_filename} doesn't exists."
csih_inform "copy certificate from ${_filename} to ${node_certificate_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${node_certificate_file}
else
csih_inform "found computer certificate file: ${node_certificate_file}"
fi
openssl x509 -noout -in ${node_certificate_file} || \
csih_error "Invalid computer certificate: ${node_certificate_file}."
if [[ ! -f ${node_key_file} ]] ; then
_filename=${_computer_key}
[[ -z "${_filename}" ]] &&
read -p "Where is computer key file $(cygpath -w /computer.key): " _filename
[[ -z "${_filename}" ]] && _filename="/computer.key"
[[ ! -f "${_filename}" ]] && \
csih_error "Key file ${_filename} doesn't exists."
csih_inform "copy key from ${_filename} to ${node_key_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${node_key_file}
else
csih_inform "found computer key file: ${node_key_file}"
fi
openssl rsa -noout -in ${node_key_file} -check ||
csih_error "Invalid node key: ${node_key_file}."
if [[ ! -f ${node_configure_file} ]] ; then
csih_inform "copy computer configure file from ${node_template_file} to ${node_configure_file}"
cp ${node_template_file} ${node_configure_file}
fi
interface_guid=$(ipwin guid *msloop ${slapos_ifname}) ||
csih_error "Failed to get guid of interface: ${slapos_ifname}."
[[ "$interface_guid" == {*-*-*-*} ]] ||
csih_error "Invalid interface guid $interface_guid specified."
computer_guid=$(grep "CN=COMP" ${node_certificate_file} | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
[[ "$computer_guid" == COMP-+([0-9]) ]] ||
csih_error "Invalid computer id '$computer_guid' specified."
csih_inform "Computer configuration information:"
csih_inform " interface name: ${slapos_ifname}"
csih_inform " GUID: ${interface_guid}"
csih_inform " ipv4_local_network: ${_ipv4_local_network}"
csih_inform " computer_id: ${computer_guid}"
csih_inform " user_base_name: ${slapos_user_basename}"
csih_inform
csih_inform " If ipv4_local_network confilcts with your local network, change it"
csih_inform " in the file: ${node_configure_file} "
csih_inform " Or change it in $(dirname $0)/slapos-include.sh"
csih_inform " and run Configure SlapOS again."
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_guid}%" \
-e "s%^user_base_name =.*$%user_base_name = ${slapos_user_basename}%" \
${node_configure_file}
if [[ ! -f ${client_certificate_file} ]] ; then
_filename=${_client_certificate}
[[ -z "${_filename}" ]] &&
read -p "Where is client certificate file $(cygpath -w /certificate): " _filename
[[ -z "${_filename}" ]] && _filename="/certificate"
[[ ! -f "${_filename}" ]] && \
csih_error "Client certificate file ${_filename} doesn't exists."
csih_inform "copy client certificate from ${_filename} to ${client_certificate_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${client_certificate_file}
fi
openssl x509 -noout -in ${client_certificate_file} || \
csih_error "Invalid client certificate: ${client_certificate_file}."
if [[ ! -f ${client_key_file} ]] ; then
_filename=${_client_key}
[[ -z "${_filename}" ]] &&
read -p "Where is client key file $(cygpath -w /key): " _filename
[[ -z "${_filename}" ]] && _filename="/key"
[[ ! -f "${_filename}" ]] && \
csih_error "Key file ${_filename} doesn't exists."
csih_inform "copy client key from ${_filename} to ${client_key_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${client_key_file}
fi
openssl rsa -noout -in ${client_key_file} -check || \
csih_error "Invalid client key: ${client_key_file}."
if [[ ! -f ${client_configure_file} ]] ; then
csih_inform "copy client configure file from ${client_template_file} to ${client_configure_file}"
cp ${client_template_file} ${client_configure_file}
fi
csih_inform "Client configuration information:"
csih_inform " client certificate file: ${client_certificate_file}"
csih_inform " client key file: ${client_key_file}"
sed -i -e "s%^cert_file.*$%cert_file = ${client_certificate_file}%" \
-e "s%^key_file.*$%key_file = ${client_key_file}%" \
${client_configure_file}
csih_inform "Configure slapos client and node OK"
echo ""
# -----------------------------------------------------------
# re6stnet: Install required packages and register to nexedi
# -----------------------------------------------------------
csih_inform "Starting configure section re6stnet ..."
csih_inform "checking miniupnpc ..."
if [[ ! -d /opt/miniupnpc ]] ; then
function configure_section_re6stnet()
{
csih_inform "checking miniupnpc ..."
if [[ ! -d /opt/miniupnpc ]] ; then
_filename=/opt/downloads/miniupnpc.tar.gz
[[ -r ${_filename} ]] || csih_error "No package found: ${_filename}"
csih_inform "installing miniupnpc ..."
......@@ -391,12 +134,12 @@ if [[ ! -d /opt/miniupnpc ]] ; then
make
python setup.py install || csih_error "Failed to install miniupnpc."
csih_inform "install miniupnpc OK"
else
else
csih_inform "check miniupnpc OK"
fi
fi
csih_inform "checking pyOpenSSL ..."
if [[ ! -d /opt/pyOpenSSL ]] ; then
csih_inform "checking pyOpenSSL ..."
if [[ ! -d /opt/pyOpenSSL ]] ; then
_filename=/opt/downloads/pyOpenSSL.tar.gz
[[ -r ${_filename} ]] || csih_error "No package found: ${_filename}"
csih_inform "installing pyOpenSSL ..."
......@@ -406,12 +149,12 @@ if [[ ! -d /opt/pyOpenSSL ]] ; then
cd pyOpenSSL
python setup.py install || csih_error "Failed ot install pyOpenSSL."
csih_inform "install pyOpenSSL OK"
else
else
csih_inform "check pyOpenSSL OK"
fi
fi
echo Checking re6stnet ...
if [[ ! -d /opt/re6stnet ]] ; then
echo Checking re6stnet ...
if [[ ! -d /opt/re6stnet ]] ; then
csih_inform "installing re6stnet ..."
_filename=/opt/downloads/re6stnet.tar.gz
cd /opt
......@@ -426,12 +169,12 @@ if [[ ! -d /opt/re6stnet ]] ; then
cd re6stnet
python setup.py install || csih_error "Failed to install re6stnet."
csih_inform "install re6stnet OK"
else
else
csih_inform "check re6stnet OK"
fi
fi
csih_inform "checking re6stnet configuration ..."
if [[ ! -r ${re6stnet_configure_file} ]] ; then
csih_inform "checking re6stnet configuration ..."
if [[ ! -r ${re6stnet_configure_file} ]] ; then
csih_inform "registering to http://re6stnet.nexedi.com ..."
cd $(dirname ${re6stnet_configure_file})
# Your subnet: 2001:67c:1254:e:19::/80 (CN=917529/32)
......@@ -453,9 +196,159 @@ if [[ ! -r ${re6stnet_configure_file} ]] ; then
echo -e "# $subnet\ntable 0\nlog ${_log_path}\novpnlog" \
"\nmain-interface ${slapos_ifname}\ninterface ${slapos_ifname}" \
>> ${re6stnet_configure_file}
fi
fi
}
readonly -f configure_section_re6stnet
function configure_section_network()
{
if ! netsh interface ipv6 show interface | grep -q "\\b${slapos_ifname}\\b" ; then
csih_inform "Installing network interface ${slapos_ifname} ..."
ipwin install netloop.inf *msloop ${slapos_ifname} ||
csih_error "install network interface ${slapos_ifname} failed"
fi
_addr4=$(echo ${_ipv4_local_network} | sed -e "s%\.0/%.1/%g")
if [[ -n "${_addr}" ]] ; then
netsh interface ip show addr ${slapos_ifname} | grep -q "${_addr4}" ||
ip -4 addr add ${_addr4} dev ${slapos_ifname} ||
csih_error "add ipv4 address failed"
else
csih_warning "No IPv4 address assigned to slapos network"
fi
if [[ -n "${_ipv6_local_address}" ]] ; then
_addr6=${_ipv6_local_address}
elif [[ -r ${re6stnet_configure_file} ]] ; then
_addr6=$(grep "Your subnet" ${re6stnet_configure_file} | \
sed -e "s/^.*subnet: //g" -e "s/\/80 (CN.*\$/1/g")
fi
if [[ -n "${_addr6}" ]] ; then
csih_inform "IPv6 address for slapos network : ${_addr6}"
netsh interface ipv6 show addr ${slapos_ifname} level=normal | \
grep -q " ${_addr6}\$" || \
netsh interface ipv6 add addr ${slapos_ifname} ${_addr6}
else
csih_warning "No IPv6 address assigned to slapos network"
fi
}
readonly -f configure_section_network
function get_configure_filename()
{
local dest_file=$1
local default_file=$2
local src_file=$3
if [[ ! -f ${dest_file} ]] ; then
_filename=${src_file}
[[ -z "${_filename}" ]] &&
read -p "Where is computer certificate file $(cygpath -w ${default_file}): " _filename
[[ -z "${_filename}" ]] && _filename="${default_file}"
[[ ! -r "${_filename}" ]] && \
csih_error "File ${_filename} doesn't exists."
csih_inform "copy file from ${_filename} to ${dest_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${dest_file}
else
csih_inform "found file: ${dest_file}"
fi
}
readonly -f get_configure_filename
function configure_section_node()
{
[[ -r ${node_template_file} ]] ||
slapos_wget_file ${node_template_file_url} ${node_template_file} ||
csih_error "Failed to download node configure file."
get_configure_filename ${node_certificate_file} "/computer.crt" ${_computer_certificate}
openssl x509 -noout -in ${node_certificate_file} || \
csih_error "Invalid computer certificate: ${node_certificate_file}."
get_configure_filename ${node_key_file} "/computer.key" ${_computer_key}
openssl rsa -noout -in ${node_key_file} -check ||
csih_error "Invalid node key: ${node_key_file}."
if [[ ! -f ${node_configure_file} ]] ; then
csih_inform "copy computer configure file from ${node_template_file} to ${node_configure_file}"
cp ${node_template_file} ${node_configure_file}
fi
interface_guid=$(ipwin guid *msloop ${slapos_ifname}) ||
csih_error "Failed to get guid of interface: ${slapos_ifname}."
[[ "$interface_guid" == {*-*-*-*} ]] ||
csih_error "Invalid interface guid $interface_guid specified."
_computer_guid=$(grep "CN=COMP" ${node_certificate_file} | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
[[ "${_computer_guid}" == COMP-+([0-9]) ]] ||
csih_error "Invalid computer id '$_computer_guid' specified."
csih_inform "Computer configuration information:"
csih_inform " interface name: ${slapos_ifname}"
csih_inform " GUID: ${interface_guid}"
csih_inform " ipv4_local_network: ${_ipv4_local_network}"
csih_inform " computer_id: ${_computer_guid}"
csih_inform " user_base_name: ${slapos_user_basename}"
csih_inform
csih_inform " If ipv4_local_network confilcts with your local network, change it"
csih_inform " in the file: ${node_configure_file} "
csih_inform " Or change it in $(dirname $0)/slapos-include.sh"
csih_inform " and run Configure SlapOS again."
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_guid}%" \
-e "s%^user_base_name =.*$%user_base_name = ${slapos_user_basename}%" \
${node_configure_file}
}
readonly -f configure_section_node
function configure_section_client()
{
[[ -r ${client_template_file} ]] ||
slapos_wget_file ${client_template_file_url} ${client_template_file} ||
csih_error "Failed to download client configure file."
sed -i -e "/^alias/,\$d" ${client_template_file}
echo "alias =
apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/apache-frontend/software.cfg
erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg
mariadb http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/mariadb/software.cfg
mysql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/mysql-5.1/software.cfg
slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slaprunner-lite/software.cfg
wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/wordpress/software.cfg
netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/netdrive-reporter/software.cfg
" >> ${client_template_file}
get_configure_filename ${client_certificate_file} "/certificate" ${_client_certificate}
openssl x509 -noout -in ${client_certificate_file} || \
csih_error "Invalid client certificate: ${client_certificate_file}."
get_configure_filename ${client_key_file} "/key" ${_client_key}
openssl rsa -noout -in ${client_key_file} -check || \
csih_error "Invalid client key: ${client_key_file}."
if check_re6stnet_needed ; then
if [[ ! -f ${client_configure_file} ]] ; then
csih_inform "copy client configure file from ${client_template_file} to ${client_configure_file}"
cp ${client_template_file} ${client_configure_file}
fi
csih_inform "Client configuration information:"
csih_inform " client certificate file: ${client_certificate_file}"
csih_inform " client key file: ${client_key_file}"
sed -i -e "s%^cert_file.*$%cert_file = ${client_certificate_file}%" \
-e "s%^key_file.*$%key_file = ${client_key_file}%" \
${client_configure_file}
}
readonly -f configure_section_client
function configure_section_openvpn()
{
local _arch
if check_openvpn_needed ; then
csih_inform "Disable IPv6 6to4 interface ... "
netsh interface ipv6 6to4 set state disable && csih_inform "OK."
csih_inform "Disable IPv6 isatap interface ... "
......@@ -463,33 +356,51 @@ if check_re6stnet_needed ; then
csih_inform "Disable IPv6 teredo interface ... "
netsh interface teredo set state disable && csih_inform "OK."
# _count=$(sed -n -e "s/^client-count *//p" ${re6stnet_configure_file})
# [[ -z "${_count}" ]] && _count=10
# csih_inform "re6stnet client-count: ${_count}"
# _name_list="re6stnet-tcp re6stnet-udp"
# for (( i=1; i<=${_count}; i=i+1 )) ; do
# _name_list="${_name_list} re6stnet$i"
# done
# _filename=$(cygpath -w ${openvpn_tap_driver_inf})
# for _name in ${_name_list} ; do
# csih_inform "checking interface ${_name} ..."
# if ! netsh interface ipv6 show interface | grep -q "\\b${_name}\\b" ; then
# [[ -r ${openvpn_tap_driver_inf} ]] ||
# csih_error "Failed to install OpenVPN Tap-Windows Driver, missing driver inf file: ${_filename}"
# csih_inform "installing interface ${_name} ..."
# # ipwin install \"${_filename}\" $openvpn_tap_driver_hwid ${_name}; ||
# ip vpntap add dev ${_name} ||
# csih_error "Failed to install OpenVPN Tap-Windows Driver."
# csih_inform "interface ${_name} installed."
# else
# csih_inform "${_name} has been installed."
# fi
# done
# Run re6stnet if no native ipv6
check_re6stnet_configure ||
csih_error "Failed to configure re6stnet."
csih_error "re6stnet hasn't been configured."
# Check openvpn
_arch=x86
check_os_is_wow64 && _arch=x64
if [[ ! -x /usr/bin/openvpn.exe ]] ; then
[[ ! -x /opt/openvpn/bin/openvpn.exe ]] &&
slapos_wget_file http://dashingsoft.com/products/openvpn-${_arch}.tar.gz -O ~/openvpn.tar.gz &&
(cd /opt ; tar --no-same-owner xzf ~/openvpn.tar.gz)
for name in openvpn.exe devcon.exe \
libeay32.dll liblzo2-2.dll libpkcs11-helper-1.dll ssleay32.dll ; do
csih_inform "copy /opt/openvpn/bin/${name} to /usr/bin"
cp /opt/openvpn/bin/${name} /usr/bin ||csih_error "No available openvpn: ${name}"
done
fi
# Check driver
_path=/etc/slapos/driver
if [[ ! -f ${_path}/OemWin2k.inf ]] ; then
mkdir -p ${_path}
[[ ! -f /opt/openvpn/driver/OemWin2k.inf ]] &&
slapos_wget_file http://dashingsoft.com/products/openvpn-${_arch}.tar.gz -O ~/openvpn.tar.gz &&
(cd /opt ; tar --no-same-owner xzf ~/openvpn.tar.gz)
for name in OemWin2k.inf tap0901.cat tap0901.sys ; do
csih_inform "copy /opt/openvpn/driver/${name} to ${_path}"
cp /opt/openvpn/driver/${name} ${_path} ||csih_error "No available openvpn tap-driver: ${name}"
done
fi
# Check ovpn scripts
_path=/usr/lib/python2.7/site-packages/re6stnet/re6st
for name in ovpn-client ovpn-server ; do
[[ -x ${_path}/${name}.exe ]] && continue
[[ ! -f /opt/openvpn/re6st/${name}.exe ]] &&
slapos_wget_file http://dashingsoft.com/products/openvpn-${_arch}.tar.gz -O ~/openvpn.tar.gz &&
(cd /opt ; tar --no-same-owner xzf ~/openvpn.tar.gz)
csih_inform "copy /opt/openvpn/re6st/${name}.exe to ${_path}"
cp /opt/openvpn/re6st/${name}.exe ${_path} ||csih_error "No available ovpn scripts: ${name}"
fi
# Install re6stnet service if no native ipv6
if ! cygrunsrv --query ${re6stnet_service_name} >/dev/null 2>&1 ; then
if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install re6stnet service need the password of ${_administrator}."
......@@ -510,21 +421,34 @@ if check_re6stnet_needed ; then
check_cygwin_service ${re6stnet_service_name} ||
csih_error "Failed to start ${re6stnet_service_name} service."
fi
else
csih_inform "native IPv6 found, no taps required."
fi
else
csih_inform "native IPv6 found, no openvpn required."
fi
}
readonly -f configure_section_openvpn
csih_inform "Configure section re6stnet OK"
echo ""
function configure_section_cron()
{
# Use slapos-cron-config to configure slapos cron service.
if ! cygrunsrv --query ${cron_service_name} > /dev/null 2>&1 ; then
[[ -x ${slapos_cron_config} ]] ||
csih_error "Couldn't find slapos cron config script: ${slapos_cron_config}"
# -----------------------------------------------------------
# cron: Install cron service and create crontab
# -----------------------------------------------------------
csih_inform "Starting configure section cron ..."
if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install cron service need the password of ${_administrator}."
fi
csih_inform "run slapos-cron-config ..."
${slapos_cron_config} ${cron_service_name} ${_administrator} ${csih_PRIVILEGED_PASSWORD} ||
csih_error "Failed to run ${slapos_cron_config}"
else
csih_inform "the cron service has been installed"
fi
check_cygwin_service ${cron_service_name}
_cron_user=${_administrator}
_crontab_file="/var/cron/tabs/${_cron_user}"
if [[ ! -f ${_crontab_file} ]] ; then
_cron_user=${_administrator}
_crontab_file="/var/cron/tabs/${_cron_user}"
if [[ ! -f ${_crontab_file} ]] ; then
cat <<EOF > ${_crontab_file}
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
......@@ -540,42 +464,288 @@ MAILTO=""
# Run "Check/add IPs and so on" once per hour
0 * * * * /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
EOF
fi
csih_inform "change owner of ${_crontab_file} to ${_cron_user}"
chown ${_cron_user} ${_crontab_file}
csih_inform "change mode of ${_crontab_file} to 644"
chmod 644 ${_crontab_file}
ls -l ${_crontab_file}
csih_inform "begin of crontab of ${_administrator}:"
csih_inform "************************************************************"
cat ${_crontab_file} || csih_error "No crob tab found."
csih_inform "************************************************************"
csih_inform "end of crontab of ${_administrator}"
}
readonly -f configure_section_cron
function configure_section_slap_runner()
{
local _title="SlapOS-WebRunner-In-${_computer_guid}"
local _patch_file="/etc/slapos/patches/slapos-cookbook-inotifyx.patch"
csih_check_program_or_error /opt/slapos/bin/slapos slapos
[[ -z "${_computer_guid}" ]] &&
csih_error "computer_guid is not set"
csih_inform "Supply slaposwebrunner in the computer ${_computer_guid}"
/opt/slapos/bin/slapos supply slaposwebrunner ${_computer_guid}
csih_inform "Request slaposwebrunner instance as ${_title}"
/opt/slapos/bin/slapos request ${client_configure_file} \
${_title} slaposwebrunner --node computer_guid=${_computer_guid}
# Apply patch
[[ -r ${_patch_file} ]] ||
slapos_wget_file \
http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_patch_file}) \
${_patch_file} ||
csih_warning "download $(basename ${_patch_file}) failed "
if [[ -r ${_patch_file} ]] ; then
for _x in $(find /opt/slapgrid/ -name slapos.cookbook-*.egg) ; do
patch -d ${_x} -f --dry-run -p1 < ${_patch_file} > /dev/null &&
csih_inform "Apply patch ${_patch_file} on ${_x}" &&
patch -d ${_x} -p1 < ${_patch_file}
done
fi
get_slapos_webrunner_instance ${_computer_guid} ${_title}
}
readonly -f configure_section_slap_runner
function configure_section_test_agent()
{
create_test_agent_instance
}
readonly -f configure_section_test_agent
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
csih_inform "Start slapos node configure ..."
echo ""
# -----------------------------------------------------------
# Local variable
# -----------------------------------------------------------
declare _administrator=${slapos_administrator}
declare _password=
declare _computer_certificate=
declare _computer_key=
declare _client_certificate=
declare _client_key=
declare _ipv4_local_network=
declare _ipv6_local_address=
declare _install_mode=
declare _configure_sections=
declare _computer_guid=
# -----------------------------------------------------------
# Command line options
# -----------------------------------------------------------
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--password=*)
_password=$optarg
;;
-P)
_password=$2
shift
;;
--user)
_administrator=$optarg
shift
;;
-U)
_administrator=$2
shift
;;
--computer-certificate=*)
_computer_certificate=$optarg
;;
--computer-key=*)
_computer_key=$optarg
;;
--client-certificate=*)
_client_certificate=$optarg
;;
--client-key=*)
_client_key=$optarg
;;
--ipv4-local-network=*)
[[ x$optarg == x*.*.*.*/* ]] ||
csih_error "invalid --ipv4-local-network=$optarg, no match x.x.x.x/x"
_ipv4_local_network=$optarg
;;
--ipv6-local-address=*)
echo $optarg | grep -q "^[:a-fA-F0-9]\+:[a-fA-F0-9]\+$" ||
csih_error "invalid ipv6-local-address: $optarg"
_ipv6_local_address=$optarg
;;
-f | --force)
_install_mode=force
;;
auto | client | cron | openvpn | network | node | re6stnet | \
slap-runner | test-agent)
_configure_sections="${_configure_sections} _$1_"
;;
-h | --help)
show_usage
exit 0
;;
*)
show_usage
exit 1
;;
esac
# Next please.
shift
done
if [[ "${_configure_sections}" == *_auto_* ]] ; then
_configure_sections=""
fi
csih_inform "change owner of ${_crontab_file} to ${_cron_user}"
chown ${_cron_user} ${_crontab_file}
if [[ -z "${_ipv4_local_network}" ]] ; then
_ipv4_local_network=$(get_free_local_ipv4_network) ||
csih_error "no ipv4_local_network specified"
fi
exit 0
# -----------------------------------------------------------
# Check and configure cygwin environments
# -----------------------------------------------------------
configure_sanity_check
csih_inform "change mode of ${_crontab_file} to 644"
chmod 644 ${_crontab_file}
ls -l ${_crontab_file}
if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then
for profile in ~/.bash_profile ~/.profile ; do
! grep -q "export PATH=/opt/slapos/bin:" $profile &&
csih_inform "add /opt/slapos/bin to PATH" &&
echo "export PATH=/opt/slapos/bin:\${PATH}" >> $profile
done
fi
csih_inform "begin of crontab of ${_administrator}:"
csih_inform "************************************************************"
cat ${_crontab_file} || csih_error "No crob tab found."
csih_inform "************************************************************"
csih_inform "end of crontab of ${_administrator}"
# -----------------------------------------------------------
# Create paths
# -----------------------------------------------------------
mkdir -p /etc/opt/slapos/ssl/partition_pki
mkdir -p ${slapos_client_home}
mkdir -p /opt/slapos/log
mkdir -p /opt/download-cache
mkdir -p /opt/downloads
mkdir -p /etc/slapos/scripts
mkdir -p /etc/re6stnet
# -----------------------------------------------------------
# Create a super user as slapos administrator
# -----------------------------------------------------------
# echo Checking slapos account ${_administrator} ...
slapos_check_and_create_privileged_user ${_administrator} ${_password} ||
csih_error "failed to create account ${_administrator}."
# Start seclogon service in Windows XP
if csih_is_xp ; then
csih_inform "Set start property of seclogon to auto"
sc config seclogon start= auto ||
csih_warning "failed to set seclogon to auto start."
# In the later, it's RunAs service, and will start by default
fi
# -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng
# -----------------------------------------------------------
csih_inform "Starting configure cygwin services ..."
configure_create_cygwin_service
csih_inform "Configure cygwin services OK"
echo ""
# -----------------------------------------------------------
# re6stnet: Install required packages and register to nexedi
# -----------------------------------------------------------
if [[ -z "${_ipv6_local_address}" || \
"${_configure_sections}" == *_re6stnet_* ]] then
csih_inform "Starting configure section re6stnet ..."
configure_section_re6stnet
csih_inform "Configure section re6stnet OK"
echo ""
fi
# -----------------------------------------------------------
# network: Install network connection used by slapos node
# -----------------------------------------------------------
csih_inform "Starting configure slapos network ..."
configure_section_network
csih_inform "Configure section network OK"
echo ""
# -----------------------------------------------------------
# node: Generate slapos node and client configure file
# -----------------------------------------------------------
csih_inform "Starting configure slapos node ..."
configure_section_node
csih_inform "Configure section node OK"
echo ""
# -----------------------------------------------------------
# client: Generate client configure file
# -----------------------------------------------------------
csih_inform "Starting configure slapos client ..."
configure_section_client
csih_inform "Configure slapos client OK"
echo ""
# -----------------------------------------------------------
# openvpn: Install openvpn and re6stnet service
# -----------------------------------------------------------
if [[ -z "${_ipv6_local_address}" || \
"${_configure_sections}" == *_openvpn_* ]] then
csih_inform "Starting configure section openvpn ..."
configure_section_openvpn
csih_inform "Configure section openvpn OK"
echo ""
fi
# -----------------------------------------------------------
# cron: Install cron service and create crontab
# -----------------------------------------------------------
csih_inform "Starting configure section cron ..."
configure_section_cron
csih_inform "Configure section cron OK"
echo ""
# -----------------------------------------------------------
# startup: Start slapos-configure when windows startup
# slap-runner: create instance of slap-runner
# -----------------------------------------------------------
# echo
# echo Starting configure section startup ...
# echo
# slapos_run_script=$(cygpath -a $0)
# regtool -q get "$slapos_run_key\\$slapos_run_entry" || \
# regtool -q set "$slapos_run_key\\$slapos_run_entry" \
# "\"$(cygpath -w /usr/bin/bash)\" --login -i $slapos_run_script" || \
# csih_error "Failed to add slapos-configure.sh as windows startup item."
# echo "Windows startup item:"
# echo " $slapos_run_key\\$slapos_run_entry = " \
# $(regtool get "$slapos_run_key\\$slapos_run_entry")
# echo
# echo Configure section startup OK.
# echo
if [[ "${_configure_sections}" == *_slap-runner_* ]] ; then
csih_inform "Starting configure section slap-runner ..."
configure_section_slap_runner &&
csih_inform "Configure section slap-runner OK"
echo ""
fi
# -----------------------------------------------------------
# test-agent: create instance of test-agent
# -----------------------------------------------------------
if [[ "${_configure_sections}" == *_test-agent_* ]] ; then
csih_inform "Starting configure section test-agent ..."
configure_section_test_agent ${_computer_guid} &&
csih_inform "Configure section test-agent OK"
echo ""
fi
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo ""
csih_inform "SlapOS has been successfully configured"
echo ""
......
......@@ -28,21 +28,6 @@ function show_usage()
echo ""
echo " setup_cygwin.bat C:\slapos network"
echo ""
echo "Then sign up slapos.org, got the following certificate files:"
echo ""
echo " certificate"
echo " key"
echo " computer.key"
echo " computer.crt"
echo ""
echo "save them in your home path."
echo ""
echo "Register another computer for test node, save them in the root path"
echo ""
echo " test-computer.key"
echo " test-computer.crt"
echo ""
echo ""
}
readonly -f show_usage
......@@ -231,47 +216,17 @@ function install_ipv6_protocol()
}
readonly -f install_ipv6_protocol
function install_cygserver_service()
{
csih_inform "Starting configure cygwin services ..."
if ! cygrunsrv --query ${cygserver_service_name} > /dev/null 2>&1 ; then
csih_inform "run cygserver-config ..."
/usr/bin/cygserver-config --yes || \
csih_error "failed to run cygserver-config"
[[ ${cygserver_service_name} == cygserver ]] ||
cygrunsrv -I ${cygserver_service_name} -d "CYGWIN ${cygserver_service_name}" -p /usr/sbin/cygserver ||
csih_error "failed to install service ${cygserver_service_name}"
else
csih_inform "the cygserver service has been installed"
fi
}
readonly -f install_cygserver_service
function install_syslog_service()
{
if ! cygrunsrv --query ${syslog_service_name} > /dev/null 2>&1 ; then
csih_inform "run syslog-ng-config ..."
/usr/bin/syslog-ng-config --yes || \
csih_error "failed to run syslog-ng-config"
[[ ${syslog_service_name} == "syslog-ng" ]] ||
cygrunsrv -I ${syslog_service_name} -d "CYGWIN ${syslog_service_name}" -p /usr/sbin/syslog-ng -a "-F" ||
csih_error "failed to install service ${syslog_service_name}"
else
csih_inform "the syslog-ng service has been installed"
fi
}
readonly -f install_cygserver_service
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
csih_inform "Starting bootstrap slapos node ..."
echo ""
# -----------------------------------------------------------
# Command line options
# -----------------------------------------------------------
_prefix=
_install_mode=
while test $# -gt 0; do
# Normalize the prefix.
case "$1" in
......@@ -304,8 +259,6 @@ done
# Constants: slapos bootstrap node use prefiix "slapboot-"
# ======================================================================
declare -r slapos_prefix=${_prefix}
declare -r cygserver_service_name=${slapos_prefix}cygserver
declare -r syslog_service_name=${slapos_prefix}syslog-ng
declare -r slapos_cygroot=$(cygpath -w /)
# -----------------------------------------------------------
......@@ -328,12 +281,6 @@ install_slapos_cygwin_package
# -----------------------------------------------------------
install_ipv6_protocol
# -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng
# -----------------------------------------------------------
install_cygserver_service
install_syslog_service
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
......
......@@ -27,14 +27,13 @@ declare -r client_configure_file=$slapos_client_home/slapos.cfg
declare -r client_certificate_file=$slapos_client_home/certificate
declare -r client_key_file=$slapos_client_home/key
declare -r client_template_file=/etc/slapos/slapos-client.cfg.example
declare -r client_template_file_url=http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example
declare -r node_certificate_file=/etc/opt/slapos/ssl/computer.crt
declare -r node_key_file=/etc/opt/slapos/ssl/computer.key
declare -r node_configure_file=/etc/opt/slapos/slapos.cfg
declare -r node_template_file=/etc/slapos/slapos.cfg.example
# Change it if it confilcts with your local network
declare -r ipv4_local_network=10.201.67.0/24
declare -r node_template_file_url=http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example
declare -r openvpn_tap_driver_inf=/etc/slapos/driver/OemWin2k.inf
declare -r openvpn_tap_driver_hwid=tap0901
......@@ -42,9 +41,7 @@ declare -r openvpn_tap_driver_hwid=tap0901
declare -r re6stnet_configure_file=/etc/re6stnet/re6stnet.conf
declare -r slapos_cron_config=/usr/bin/slapos-cron-config
declare -r slaprunner_startup_file=/etc/slapos/scripts/slap-runner.html
declare -r slapos_run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
declare -r slapos_run_entry=${slapos_prefix:-slapos}-configure
declare -r slapos_administrator=${slapos_prefix:-slap}root
declare -r slapos_user_basename=${slapos_prefix:-slap}user
declare -r slapos_ifname=${slapos_prefix}re6stnet-lo
......@@ -53,6 +50,14 @@ declare -r cron_service_name=${slapos_prefix}cron
declare -r syslog_service_name=${slapos_prefix}syslog-ng
declare -r cygserver_service_name=${slapos_prefix}cygserver
# ======================================================================
# Routine: check_os_is_wow64
# ======================================================================
function check_os_is_wow64()
{
[[ $(uname) == CYGWIN_NT-*-WOW64 ]]
} # === check_os_is_wow64 === #
readonly -f check_os_is_wow64
# ======================================================================
# Routine: check_cygwin_service
......@@ -152,10 +157,10 @@ function check_re6stnet_configure()
} # === check_re6stnet_configure() === #
# ======================================================================
# Routine: check_re6stnet_needed
# Routine: check_openvpn_needed
# Check re6stnet required or not
# ======================================================================
function check_re6stnet_needed()
function check_openvpn_needed()
{
# This doesn't work in cygwin now, need hack ip script
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
......@@ -164,7 +169,7 @@ function check_re6stnet_needed()
fi
# re6stnet is required
return 0
} # === check_re6stnet_needed() === #
} # === check_openvpn_needed() === #
# ======================================================================
# Routine: reset_slapos_connection
......@@ -172,7 +177,7 @@ function check_re6stnet_needed()
# ======================================================================
function reset_slapos_connection()
{
ifname=${1-re6stnet-lo}
ifname=${1:-re6stnet-lo}
netsh interface ip set address $ifname source=dhcp
} # === reset_slapos_connection() === #
......@@ -240,7 +245,7 @@ function start_cygwin_service()
# ======================================================================
slapos_request_password()
{
local username="${1-slaproot}"
local username="${1:-slaproot}"
csih_inform "$2"
csih_get_value "Please enter the password:" -s
......@@ -252,18 +257,29 @@ slapos_request_password()
csih_PRIVILEGED_PASSWORD="${_password}"
} # === slapos_request_password() === #
# ======================================================================
# Routine: wget_slapos_file
# Generate the template file for node and client
# ======================================================================
function slapos_wget_file()
{
wget $1 -O $2 || return 1
csih_inform "Got $2."
} # === wget_slapos_file() === #
readonly -f wget_slapos_file
# ======================================================================
# Routine: slapos_create_privileged_user
#
# Copied from csih_check_and_create_privileged_user, just create fix account:
# slaproot
# Copied from csih_check_and_create_privileged_user
#
# ======================================================================
slapos_check_and_create_privileged_user()
{
csih_stacktrace "${@}"
$_csih_trace
local username_in_sam
local username="${1-slaproot}"
local username="${1:-slaproot}"
local admingroup
local dos_var_empty
local _password="$2"
......@@ -405,19 +421,6 @@ slapos_check_and_create_privileged_user()
} # === End of csih_check_and_create_privileged_user() === #
readonly -f slapos_check_and_create_privileged_user
# ======================================================================
# Routine: create_template_configure_file
# Generate the template file for node and client
# ======================================================================
function create_template_configure_file()
{
wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example -O $client_template_file || return 1
echo Got $client_template_file.
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.
} # === create_template_configure_file() === #
# ======================================================================
# Routine: get_slapos_webrunner_instance
# Get instance connection information and create slaprunner startup file
......@@ -427,7 +430,7 @@ function get_slapos_webrunner_instance()
local _guid=$1
local _title=$2
local _feature_code="#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
local _url
local _url=
local _ret=0
csih_inform "Trying to get connection information of SlapOS WebRunner instance ..."
......@@ -446,10 +449,6 @@ function get_slapos_webrunner_instance()
if [[ -n "${_url}" ]] ; then
csih_inform "SlapOS WebRunner URL: ${_url}"
if grep -q -F "${_feature_code}" ${slaprunner_startup_file} ; then
csih_inform "Find feature code ${_feature_code} in the ${slaprunner_startup_file}"
echo "Check SlapOS Webrunner OK."
else
csih_inform "Generate SlapOS WebRunner startup file ${slaprunner_startup_file}"
cat <<EOF > ${slaprunner_startup_file}
<html>
......@@ -466,10 +465,99 @@ function openwin() {
<!-- $feature_code -->
</html>
EOF
fi
else
csih_error_multi "Request returned true, but I can't find connection information," \
"something is wrong with slapos webrunner software."
fi
return ${_ret}
} # === get_slapos_webrunner_instance() === #
readonly -f get_slapos_webrunner_instance
# ======================================================================
# Routine: create_test_agent_instance
# Create test-agent instance
# ======================================================================
function create_test_agent_instance()
{
local computer_guid=${1:-COMP-XXXX}
cat <<EOF > ~/test-agent.template
<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="usercertificate">-----BEGIN CERTIFICATE-----
MIIEBTCCAu2gAwIBAgIDAJNnMA0GCSqGSIb3DQEBBQUAMIGZMQswCQYDVQQGEwJG
UjEbMBkGA1UECAwSTm9yZC1QYXMtZGUtQ2FsYWlzMQ4wDAYDVQQHDAVMaWxsZTET
MBEGA1UECgwKVmlGaUIgU0FSTDEoMCYGA1UEAwwfQXV0b21hdGljIENlcnRpZmlj
YXRlIEF1dGhvcml0eTEeMBwGCSqGSIb3DQEJARYPYWRtaW5AdmlmaWIuY29tMB4X
DTEzMDYyNzEzMzUxNVoXDTIzMDYyNTEzMzUxNVowczELMAkGA1UEBhMCRlIxGzAZ
BgNVBAgMEk5vcmQtUGFzLWRlLUNhbGFpczETMBEGA1UECgwKVmlGaUIgU0FSTDES
MBAGA1UEAwwJQ09NUC0xNjU1MR4wHAYJKoZIhvcNAQkBFg9hZG1pbkB2aWZpYi5v
cmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDwFsiIAFuoSeZmp1tP
dtdgvf63fV6BRMqcmoi14lDXE6A6a6GZSUJfcjE/hl1pMTkSb2C6t652z64Xg9oR
GMlBmrHX6WeZkgcw5wxU1aKeS4yZ6kPvdVf+RvnGiez1yHaAfb/A1OjrbhyH5nn+
yXvWMU+5jIKdTvnHtft02tjOS1s80JNFyP6i8WqJ5Ui6DOVj6TmRQitw4hw3h+4b
VBCPBtOX8qN0ASRWi4IdQToBkzkspYPYtuWFhqEG0gxi2M3M7NAnBLs4vfveOo7C
fCsMOrf1XgpkOg9U8pGv93ot+cCEgaLbldcmUvrFGEaPUTiGfrXB3/ViLHg9eCeY
xgmPAgMBAAGjezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wg
R2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBTyDEjz/fIvjVo2j6Jay7my
Zlu5lTAfBgNVHSMEGDAWgBRjhJik1R6prfda41XfXWOP+F65uzANBgkqhkiG9w0B
AQUFAAOCAQEANaJzQ+0Ifn3AIf1DrJoXO1g6ywfHTSeDFOmnfVCYb1uECnElBccB
gV/MHl9hq6nyGawamPki9kTqZE6RhM72y+btNxqLELEaMZaXXkZn3ROT0oz2PWFT
WOgTyI/QsHKlMhwa0rxX68G8sSoSw448ICPOQWT0eYAWxnniDW4QCxRZscSlVDFU
heRljeJjwHrz1sRJev4CrOrg44tAlLdJpnO1ZHc+wtXRUJK6YQqKj8UQ/KmvuvWX
br3Xyhksoy67Y+TsS7NzUy+3TFXUpe23JTqETHUPvUU0w4VMUBCcAMYIoh46SHvZ
Dc8/wOQ7Z31zs02v/EQL76HQAfq4n+QvOQ==
-----END CERTIFICATE-----
</parameter>
<parameter id="userkey">-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDwFsiIAFuoSeZm
p1tPdtdgvf63fV6BRMqcmoi14lDXE6A6a6GZSUJfcjE/hl1pMTkSb2C6t652z64X
g9oRGMlBmrHX6WeZkgcw5wxU1aKeS4yZ6kPvdVf+RvnGiez1yHaAfb/A1OjrbhyH
5nn+yXvWMU+5jIKdTvnHtft02tjOS1s80JNFyP6i8WqJ5Ui6DOVj6TmRQitw4hw3
h+4bVBCPBtOX8qN0ASRWi4IdQToBkzkspYPYtuWFhqEG0gxi2M3M7NAnBLs4vfve
Oo7CfCsMOrf1XgpkOg9U8pGv93ot+cCEgaLbldcmUvrFGEaPUTiGfrXB3/ViLHg9
eCeYxgmPAgMBAAECggEARY+UUjMoWz3uD1f10LQx+smRf0BHnVR9D5qGeYw0t9vr
1IFStMLRBC5lrm4TqmKkkn7Km86UMcBCRHXjPIjd5rAXTuNFLO1uP/DxVbMABrUE
66NAQ6TP9dBClg9oJF4MV3YXlJsbUPr6MTXJqtRdmNV4r93SChnTrNVBIb42iq4i
9bpVSnql8Yr+9jZZnpRDz4IbSxlE3KAHXFmbJThtwc1FcvnYargNdjX9TGx25hyx
hCUsyoCuJURmbwOd3DQjzfxKZT7uLt/nduNYbBNjstzc/HJ4qpuV500DT1kTDPf8
LSp1LnjxzRCHdZwV+jtFebBOfa9euKMAVVYn5fBVIQKBgQD8nPDjrQEfj2igei3l
R9E2KCeS0L+3scVPnytUAvgmZdlCyMcmNvnLl5W2Lwt8zgZaYAlcZpUR+m/zz0PX
Ms9Pwr57CXyQo6K49l819myEPgeVXgETFY3F5/6Nmq6ma4w0GGvaSjxetlYb46D9
oB9iBUzQzEEczO+ozbUxVm2QHQKBgQDzTtr0E07LqMvsgW8752Ufn8S90ThM8jmY
7R/wV9bHPSUOFSACtF3mYuk84Pk9dpbaJmtIL1kz1XnbEHvAmJP7O9kerjR5/sde
22pSR4+FEdGiRuigadmGtCdf+RMU7o3/i2+msB06cjirrGf5hRmS6z+ynfYLHTkF
rzPDrDRomwKBgQC2HTKxANVxekLUhqC1zfuuzm4RMvs0JC36Q+bJr0ZU8FIcCoFA
NJwLQaIF8I6YkDMWTmwROEc56dFx9LeU2iWI+/2019b8s2uparyjO59qCwoOjfG6
X2yRA7qJPb2xbpFqMTz351L0eQFFI+q5Tgmx8d46HTbH25rfmEWLZyKfpQKBgCm4
recIoIxfx4gosdBN35NKrEv4YnUfXC0TDFUEWvoTTBVcHf8YurlU4LXlxhd6DGgg
Cml4ZQ10X87mxrHB+C4ulw6hxLHetIVZjqPJTZz97zqqeh13yStGHTJh3ZnLRmI5
oM2uiXSKPZmCmNm6ryX4XRXd7GD/g9Wrs26sSthdAoGACzZqufKsXBhW71qJAPNO
KK90Fb4QQPjaATY0tUe/Y3I18N7vkD7Z5nhj6R+i1UBSzAD0YKrXi6ROpy3mHeRt
Sz8iN27b5Hyh461RFz6FLKiLofxY9gMaFYewayhvjKrOJXZ84xHS6Nfw5S6Ub5sz
Eb4Vzgi4hhbpk2KbAHOy7Xw=
-----END PRIVATE KEY-----</parameter>
<parameter id="master-url">https://slap.vifib.com/</parameter>
<parameter id="default_max_install_duration">36000</parameter>
<parameter id="default_max_uninstall_duration">36000</parameter>
<parameter id="default_max_request_duration">36000</parameter>
<parameter id="default_max_destroy_duration">36000</parameter>
<parameter id="configuration">
[agent]
node_title = VIFIB-TEST-AGENT-ON-${computer_guid}
test_title = VIFIB-TEST-AGENT-FOR-WINDOWS-INSTALLER
project_title = SlapOS For Windows
task_count = 1
report_url = https://webbuildbot:a2fgt5e1@www.tiolive.com/nexedi/
###### windows self installer ############################################
[test-windows-installer-on-windows7-64bits]
computer_list = ["${computer_guid}"]
url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slapos-windows-installer/software.cfg
request_kw = {"filter_kw": {"computer_guid": "${computer_guid}"},"partition_parameter_kw": {}}
</parameter>
</instance>
EOF
} # === create_test_agent_instance() === #
readonly -f create_test_agent_instance
#! /bin/bash
source $(/usr/bin/dirname $0)/slapos-include.sh
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
csih_inform "Start slapos-node script ..."
echo ""
# -----------------------------------------------------------
# Local variables
# -----------------------------------------------------------
declare computer_guid
# -----------------------------------------------------------
......@@ -22,7 +30,7 @@ check_cygwin_service ${cron_service_name}
check_re6stnet_needed && check_cygwin_service ${re6stnet_service_name}
# -----------------------------------------------------------
# Get computer reference and re6stnet network
# Get computer reference
# -----------------------------------------------------------
computer_guid=$(grep "CN=COMP" ${node_certificate_file} | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
......@@ -32,20 +40,6 @@ csih_error_multi "${computer_guid} is invalid computer guid." \
"to fix it."
csih_inform "Got computer reference id: ${computer_guid}"
# -----------------------------------------------------------
# Get re6stnet network
# -----------------------------------------------------------
if [[ -r ${re6stnet_configure_file} ]] ; then
_addr6=$(grep "Your subnet" ${re6stnet_configure_file} | \
sed -e "s/^.*subnet: //g" -e "s/\/80 (CN.*\$/1/g")
if [[ -n "${_addr6}" ]] ; then
csih_inform "Re6stnet address in this computer: ${_addr6}"
netsh interface ipv6 show addr ${slapos_ifname} level=normal | \
grep -q " ${_addr6}\$" || \
netsh interface ipv6 add addr ${slapos_ifname} ${_addr6}
fi
fi
# -----------------------------------------------------------
# Format slapos node
# -----------------------------------------------------------
......@@ -54,40 +48,25 @@ csih_inform "Formatting SlapOS Node ..."
csih_error "Run slapos node format failed. "
# -----------------------------------------------------------
# Request an instance of slapos webrunner
# Run slapos software
# -----------------------------------------------------------
csih_inform "Supply slaposwebrunner in the computer ${computer_guid}"
/opt/slapos/bin/slapos supply slaposwebrunner ${computer_guid}
_title="SlapOS-WebRunner-In-${computer_guid}"
csih_inform "Request slaposwebrunner instance as ${_title}"
/opt/slapos/bin/slapos request ${client_configure_file} \
${_title} slaposwebrunner --node computer_guid=${computer_guid}
/opt/slapos/bin/slapos node software --verbose
# -----------------------------------------------------------
# Enter loop to release software, create instance, report
# Run slapos instance
# -----------------------------------------------------------
_patch_file=/etc/slapos/patches/slapos-cookbook-inotifyx.patch
while true ; do
csih_inform "Releasing software ..."
/opt/slapos/bin/slapos node software --verbose || continue
csih_inform "Creating instance ..."
/opt/slapos/bin/slapos node instance --verbose
if [[ -r ${_patch_file} ]] ; then
for _x in $(find /opt/slapgrid/ -name slapos.cookbook-*.egg) ; do
patch -d ${_x} -f --dry-run -p1 < ${_patch_file} > /dev/null &&
csih_inform "Apply patch ${_patch_file} on ${_x}" &&
patch -d ${_x} -p1 < ${_patch_file}
done
fi
csih_inform "Creating instance ..."
/opt/slapos/bin/slapos node instance --verbose
csih_inform "Sending report ..."
/opt/slapos/bin/slapos node report --verbose
get_slapos_webrunner_instance ${computer_guid} ${_title} && break
done
# -----------------------------------------------------------
# Run slapos report
# -----------------------------------------------------------
csih_inform "Sending report ..."
/opt/slapos/bin/slapos node report --verbose
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo ""
csih_inform "Run slapos-node script successfully."
echo ""
......
......@@ -57,8 +57,8 @@ Source: "cygwin\opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver"
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-include.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-cygwin-bootstrap.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
Source: "cygwin\opt\git\slapos.package\windows\scripts\slapos-cleanup.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts"; Permissions: everyone-readexec;
......@@ -78,9 +78,8 @@ 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;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-cygwin-bootstrap.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;
[UninstallRun]
Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Uninstall SlapOS"" /etc/slapos/scripts/slapos-cleanup.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist;
......
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