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 ...@@ -557,7 +557,7 @@ Then upload the source packages dist/psutil-1.0.1.tar.gz to http://www.nexedi.or
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Create network interface for slapos</term> <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>
<varlistentry> <varlistentry>
<term>Install re6stnet</term> <term>Install re6stnet</term>
...@@ -608,6 +608,7 @@ Most of tasks list above section could be done by shell scripts, now we have the ...@@ -608,6 +608,7 @@ Most of tasks list above section could be done by shell scripts, now we have the
<itemizedlist> <itemizedlist>
<listitem><para>setup-cygwin.bat</para></listitem> <listitem><para>setup-cygwin.bat</para></listitem>
<listitem><para>slapos-cygwin-bootstrap.sh</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-configure.sh</para></listitem>
<listitem><para>slapos-node.sh</para></listitem> <listitem><para>slapos-node.sh</para></listitem>
<listitem><para>slapos-cleanup.sh</para></listitem> <listitem><para>slapos-cleanup.sh</para></listitem>
......
diff --git a/options.py~ b/options.py diff --git a/supervisor/options.py b/supervisor/options.py
old mode 100644 index 3ccab60..e220c10 100644
new mode 100755 --- a/supervisor/options.py
index 3ccab60..e220c10 +++ b/supervisor/options.py
--- a/options.py~
+++ b/options.py
@@ -1197,7 +1197,7 @@ class ServerOptions(Options): @@ -1197,7 +1197,7 @@ class ServerOptions(Options):
return return
......
#! /bin/bash #! /bin/bash
#
# This script is used to build slapos node from source.
#
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH 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."} echo "This script is used to build slapos node in the Cygwin."
read -n 1 -p "Press any key to exit..." echo ""
exit 1 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} csih_inform "mkdir /opt/download-cache"
slapos_cache=/opt/download-cache mkdir -p ${slapos_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 [[ ! -f ${slapos_cfg} ]] &&
slapos_bootstrap=$slapos_home/bootstrap.py echo "[buildout]
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]
extends = ${slapos_url} extends = ${slapos_url}
download-cache = ${slapos_cache} download-cache = ${slapos_cache}
prefix = $${buildout:directory} prefix = ${buildout:directory}
EOF " > ${slapos_cfg} &&
echo "File $slapos_cfg has been generated." csih_inform "${slapos_cfg} generated"
fi
echo "Checking $slapos_bootstrap ..." [[ -f ${slapos_bootstrap} ]] ||
if [[ ! -f $slapos_bootstrap ]] ; then python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > ${slapos_bootstrap} ||
echo "Downloading $slapos_bootstrap ..." csih_error "download bootstrap.py failed"
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_inform "download ${slapos_bootstrap} OK"
show_error_exit "Error: download $slapos_bootstrap"
echo "Downlaod $slapos_bootstrap OK."
else
echo OK.
fi
if [[ ! -x $slapos_home/run/buildout ]] ; then [[ -x ${slapos_home}/bin/buildout ]] ||
echo "Bootstrap slapos ..." (cd ${slapos_home} && python -S bootstrap.py) ||
(cd $slapos_home ; python -S bootstrap.py) || show_error_exit "Error: slapos bootstrap failed." csih_error "run bootstrap.py failed"
echo "Bootstrap slapos OK." csih_inform "run bootstrap.py OK"
fi
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 csih_inform "applay patch ${_filename}"
echo Start buildout of slapos ... (cd $(ls -d ${slapos_home}/eggs/slapos.core-*.egg/) &&
echo csih_inform "patch at $(pwd)" &&
(cd $slapos_home ; $slapos_home/bin/buildout -v -N) || show_error_exit "Error slapos buildout failed." patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
# apply patches csih_inform "apply patch ${_filename} OK")
for _filename in $patch_files ; do
if [[ -r ${_filename} ]] ; then _filename=~/supervisor-cygwin.patch
echo "Apply patch: ${_filename}" [[ -f ${_filename} ]] ||
for _path in $(find $slapos_home/eggs -name slapos.core-*.egg) ; do wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_filename}) -O ${_filename} ||
echo " at ${_path} ..." csih_error "download ${_filename} failed"
(cd ${_path} ; patch -f --dry-run -p1 < ${_filename} > /dev/null && csih_inform "download ${_filename} OK"
patch -p1 < ${_filename} && echo "OK.")
done csih_inform "applay patch ${_filename}"
fi (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 done
echo # -----------------------------------------------------------
echo Build slapos node successfully. # Build SlapOS
echo # -----------------------------------------------------------
slapos_buildout
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo ""
csih_inform "Build slapos successfully."
echo ""
read -n 1 -t 60 -p "Press any key to exit..." read -n 1 -t 60 -p "Press any key to exit..."
exit 0 exit 0
...@@ -27,94 +27,9 @@ readonly -f show_error_exit ...@@ -27,94 +27,9 @@ readonly -f show_error_exit
declare -r slapos_prefix=$1 declare -r slapos_prefix=$1
declare -r _cygroot=$(cygpath -w /) 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="" _charset=$(ipwin codepage) || _charset=""
echo "Windows OEM Codepage is ${_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 # Change format of readme.txt
_filename=$(cygpath -u $(cygpath -m /)/../readme.txt) _filename=$(cygpath -u $(cygpath -m /)/../readme.txt)
...@@ -142,26 +57,6 @@ elif [[ ! -d /opt/slapos ]] ; then ...@@ -142,26 +57,6 @@ elif [[ ! -d /opt/slapos ]] ; then
echo "Warning: missing ${_filename}" echo "Warning: missing ${_filename}"
fi 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 # Set prefix for slapos
if [[ -n ${slapos_prefix} ]] ; then if [[ -n ${slapos_prefix} ]] ; then
echo "Set slapos prefix as ${slapos_prefix}" echo "Set slapos prefix as ${slapos_prefix}"
......
@ECHO OFF @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 SETLOCAL
SET CYGWINHOME=%~1\ SET CYGWINHOME=%~1\
SET CYGWINROOT="%~1\cygwin" SET CYGWINROOT="%~1\cygwin"
IF NOT "%1" == "" GOTO INIT IF "%1" == "network" GOTO INIT0
IF NOT "%1" == "" GOTO INIT1
:INIT0
SET CYGWINHOME=%~dp0 SET CYGWINHOME=%~dp0
SET CYGWINROOT="%~dp0cygwin" SET CYGWINROOT="%~dp0cygwin"
:INIT :INIT1
SET DOWNLOADPATH="%CYGWINHOME%cygwin-packages" SET DOWNLOADPATH="%CYGWINHOME%cygwin-packages"
SET SETUPFILE="%CYGWINHOME%setup.exe" SET SETUPFILE="%CYGWINHOME%setup.exe"
SET OPTIONS=--no-shortcuts --no-startmenu --quiet-mode --no-verify SET OPTIONS=--no-shortcuts --no-startmenu --quiet-mode --no-verify
...@@ -24,7 +55,7 @@ EXIT 1 ...@@ -24,7 +55,7 @@ EXIT 1
IF NOT "%2" == "" GOTO REMOTE_INSTALL IF NOT "%2" == "" GOTO REMOTE_INSTALL
:LOCAL_INSTALL :LOCAL_INSTALL
SET PACKAGES=-C All SET PACKAGES=-C All
ECHO Install cygwin at %CYGWINROOT% from %DOWNLOADPATH% ... ECHO Install cygwin at %CYGWINROOT% from %DOWNLOADPATH% ...
ECHO Packages: %PACKAGES% ECHO Packages: %PACKAGES%
%SETUPFILE% --local-install %PACKAGES% -l %DOWNLOADPATH% -R %CYGWINROOT% %OPTIONS% %SETUPFILE% --local-install %PACKAGES% -l %DOWNLOADPATH% -R %CYGWINROOT% %OPTIONS%
...@@ -33,13 +64,13 @@ GOTO END ...@@ -33,13 +64,13 @@ GOTO END
:REMOTE_INSTALL :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 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 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 SET SITEOPTIONS=-s http://www.netgull.com/cygwin
REM ECHO %2 | FINDSTR \. > /NULL REM ECHO %2 | FINDSTR \. > /NULL
REM IF %ERRORLEVEL% == 0 SET SITEOPTIONS=--site %2 --only-site REM IF %ERRORLEVEL% == 0 SET SITEOPTIONS=--site %2 --only-site
IF /I %2 NEQ network SET SITEOPTIONS=-s %2 --only-site IF /I %2 NEQ network SET SITEOPTIONS=-s %2 --only-site
ECHO Install cygwin at %CYGWINROOT% from %SITE% ... ECHO Install cygwin at %CYGWINROOT% from %SITE% ...
REM setup.exe -D -X --site http://mirrors.163.com/cygwin -l D:/slapos/slapos-cygwin-packages -R D:/slapos/cygwin REM setup.exe -D -X --site http://mirrors.163.com/cygwin -l D:/slapos/slapos-cygwin-packages -R D:/slapos/cygwin
REM -P cygrunsrv -P binutils -P gcc4 -P libtool -P make -P autobuild -P autoconf -P automake -P libiconv REM -P cygrunsrv -P binutils -P gcc4 -P libtool -P make -P autobuild -P autoconf -P automake -P libiconv
%SETUPFILE% %PACKAGES% %SITEOPTIONS% -D -L -l %DOWNLOADPATH% -R %CYGWINROOT% %OPTIONS% %SETUPFILE% %PACKAGES% %SITEOPTIONS% -D -L -l %DOWNLOADPATH% -R %CYGWINROOT% %OPTIONS%
GOTO END GOTO END
......
...@@ -63,8 +63,8 @@ Source: "cygwin\opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver" ...@@ -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-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\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\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\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\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; 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"; ...@@ -84,8 +84,8 @@ Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run] [Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden; Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist; 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\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden; 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] [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; 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;
......
This diff is collapsed.
...@@ -3,23 +3,32 @@ ...@@ -3,23 +3,32 @@
# When uninstall slapos, it will be called by uninstaller. Root right # When uninstall slapos, it will be called by uninstaller. Root right
# required to run this script. # required to run this script.
# #
# /bin/bash/ --login -i pre-uninstall.sh # /bin/bash/ --login -i slapos-cleanup.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
# #
source $(/usr/bin/dirname $0)/slapos-include.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() function slapos_kill_process()
{ {
name=$1 name=$1
...@@ -31,6 +40,34 @@ function slapos_kill_process() ...@@ -31,6 +40,34 @@ function slapos_kill_process()
} }
readonly -f 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, # Remove services installed by cygwin,
# #
...@@ -112,8 +149,12 @@ done ...@@ -112,8 +149,12 @@ done
echo "Creating /etc/group ..." echo "Creating /etc/group ..."
mkgroup -l > /etc/group && echo OK. mkgroup -l > /etc/group && echo OK.
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo echo
echo Run pre-uninstall script complete. echo Run pre-uninstall script complete.
echo echo
read -n 1 -t 60 -p "Press any key to exit..." read -n 1 -t 60 -p "Press any key to exit..."
exit 0 exit 0
This diff is collapsed.
...@@ -28,21 +28,6 @@ function show_usage() ...@@ -28,21 +28,6 @@ function show_usage()
echo "" echo ""
echo " setup_cygwin.bat C:\slapos network" echo " setup_cygwin.bat C:\slapos network"
echo "" 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 readonly -f show_usage
...@@ -231,47 +216,17 @@ function install_ipv6_protocol() ...@@ -231,47 +216,17 @@ function install_ipv6_protocol()
} }
readonly -f 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 # Start script
# ----------------------------------------------------------- # -----------------------------------------------------------
csih_inform "Starting bootstrap slapos node ..." csih_inform "Starting bootstrap slapos node ..."
echo "" echo ""
# -----------------------------------------------------------
# Command line options
# -----------------------------------------------------------
_prefix= _prefix=
_install_mode= _install_mode=
while test $# -gt 0; do while test $# -gt 0; do
# Normalize the prefix. # Normalize the prefix.
case "$1" in case "$1" in
...@@ -304,8 +259,6 @@ done ...@@ -304,8 +259,6 @@ done
# Constants: slapos bootstrap node use prefiix "slapboot-" # Constants: slapos bootstrap node use prefiix "slapboot-"
# ====================================================================== # ======================================================================
declare -r slapos_prefix=${_prefix} 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 /) declare -r slapos_cygroot=$(cygpath -w /)
# ----------------------------------------------------------- # -----------------------------------------------------------
...@@ -328,12 +281,6 @@ install_slapos_cygwin_package ...@@ -328,12 +281,6 @@ install_slapos_cygwin_package
# ----------------------------------------------------------- # -----------------------------------------------------------
install_ipv6_protocol install_ipv6_protocol
# -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng
# -----------------------------------------------------------
install_cygserver_service
install_syslog_service
# ----------------------------------------------------------- # -----------------------------------------------------------
# End script # End script
# ----------------------------------------------------------- # -----------------------------------------------------------
......
This diff is collapsed.
#! /bin/bash #! /bin/bash
source $(/usr/bin/dirname $0)/slapos-include.sh source $(/usr/bin/dirname $0)/slapos-include.sh
# -----------------------------------------------------------
# Start script
# -----------------------------------------------------------
csih_inform "Start slapos-node script ..." csih_inform "Start slapos-node script ..."
echo ""
# -----------------------------------------------------------
# Local variables
# -----------------------------------------------------------
declare computer_guid declare computer_guid
# ----------------------------------------------------------- # -----------------------------------------------------------
...@@ -22,7 +30,7 @@ check_cygwin_service ${cron_service_name} ...@@ -22,7 +30,7 @@ check_cygwin_service ${cron_service_name}
check_re6stnet_needed && check_cygwin_service ${re6stnet_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} | \ computer_guid=$(grep "CN=COMP" ${node_certificate_file} | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g") sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
...@@ -32,20 +40,6 @@ csih_error_multi "${computer_guid} is invalid computer guid." \ ...@@ -32,20 +40,6 @@ csih_error_multi "${computer_guid} is invalid computer guid." \
"to fix it." "to fix it."
csih_inform "Got computer reference id: ${computer_guid}" 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 # Format slapos node
# ----------------------------------------------------------- # -----------------------------------------------------------
...@@ -54,40 +48,25 @@ csih_inform "Formatting SlapOS Node ..." ...@@ -54,40 +48,25 @@ csih_inform "Formatting SlapOS Node ..."
csih_error "Run slapos node format failed. " 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 node software --verbose
/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}
# ----------------------------------------------------------- # -----------------------------------------------------------
# Enter loop to release software, create instance, report # Run slapos instance
# ----------------------------------------------------------- # -----------------------------------------------------------
_patch_file=/etc/slapos/patches/slapos-cookbook-inotifyx.patch csih_inform "Creating instance ..."
while true ; do /opt/slapos/bin/slapos node instance --verbose
csih_inform "Releasing software ..."
/opt/slapos/bin/slapos node software --verbose || continue
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 # Run slapos report
# -----------------------------------------------------------
get_slapos_webrunner_instance ${computer_guid} ${_title} && break csih_inform "Sending report ..."
done /opt/slapos/bin/slapos node report --verbose
# -----------------------------------------------------------
# End script
# -----------------------------------------------------------
echo "" echo ""
csih_inform "Run slapos-node script successfully." csih_inform "Run slapos-node script successfully."
echo "" echo ""
......
...@@ -57,8 +57,8 @@ Source: "cygwin\opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver" ...@@ -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-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\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\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\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\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; 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"; ...@@ -78,9 +78,8 @@ Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run] [Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"" network"; StatusMsg: "Installing Cygwin..."; Flags: runhidden; 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\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] [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; 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