Commit a9a9a49c authored by Jondy Zhao's avatar Jondy Zhao

slapos-cygwin-bootstrip:

  fix missing copy certificate/key files
  support re-run
parent a6f041e1
...@@ -25,6 +25,7 @@ echo "" ...@@ -25,6 +25,7 @@ echo ""
# Constants # Constants
# ====================================================================== # ======================================================================
declare -r cygwin_home=$(cygpath -a $(cygpath -w /)\\..) declare -r cygwin_home=$(cygpath -a $(cygpath -w /)\\..)
declare -r ISCC=/opt/inno-setup/ISCC.exe
# ----------------------------------------------------------- # -----------------------------------------------------------
# Command line options # Command line options
...@@ -232,10 +233,12 @@ wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.c ...@@ -232,10 +233,12 @@ wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.c
# ----------------------------------------------------------- # -----------------------------------------------------------
# Generate installer # Generate installer
# ----------------------------------------------------------- # -----------------------------------------------------------
[[ -x "$ISCC" ]] || csih_error "missing $ISCC"
_issfile=~/slapos.iss _issfile=~/slapos.iss
_installer_name=slapos-windows-all-in-one.exe _installer_name=slapos-windows-all-in-one.exe
_output_dir= _output_dir=$(cygpath -w ~/)
_source_dir= _source_dir=$(cygpath -a -w $(cygpath -w /)\\..)
cp /opt/git/slapos.package/windows/scripts/slapos-all-in-one.iss ${_issfile} cp /opt/git/slapos.package/windows/scripts/slapos-all-in-one.iss ${_issfile}
sed -i -e "s/^DefaultDirName=.*/DefaultDirName=?/" \ sed -i -e "s/^DefaultDirName=.*/DefaultDirName=?/" \
-e "s/^OutputBaseFilename=.*/OutputBaseFilename=$(basename ${_installer_name})/" \ -e "s/^OutputBaseFilename=.*/OutputBaseFilename=$(basename ${_installer_name})/" \
...@@ -243,7 +246,7 @@ sed -i -e "s/^DefaultDirName=.*/DefaultDirName=?/" \ ...@@ -243,7 +246,7 @@ sed -i -e "s/^DefaultDirName=.*/DefaultDirName=?/" \
-e "s/^SourceDir=.*/SourceDir=${_source_dir}/" \ -e "s/^SourceDir=.*/SourceDir=${_source_dir}/" \
${_issfile} ${_issfile}
$ISSC /Q /O ${_output_dir} /F ${_installer_name} ${_issfile} $ISCC /Q $(cygpath -w ${_issfile})
echo "" echo ""
csih_inform "Build Slapos Windows installer successfully." csih_inform "Build Slapos Windows installer successfully."
......
...@@ -89,22 +89,25 @@ else ...@@ -89,22 +89,25 @@ else
fi fi
for _cmdname in ip useradd usermod groupadd brctl tunctl ; do for _cmdname in ip useradd usermod groupadd brctl tunctl ; do
[[ -x /usr/bin/${_cmdname} ]] && continue
wget http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/scripts/${_cmdname} -O /usr/bin/${_cmdname} || wget 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_error "download ${_cmdname} failed"
csih_inform "download cygwin script ${_cmdname} OK" csih_inform "download cygwin script ${_cmdname} OK"
chmod +x /usr/bin/${_cmdname} || csih_error "chmod /usr/bin/${_cmdname} failed" chmod +x /usr/bin/${_cmdname} || csih_error "chmod /usr/bin/${_cmdname} failed"
done done
if [[ $(uname) == CYGWIN_NT-*-WOW64 ]] ; then if [[ ! -x /usr/bin/ipwin.exe ]] ; then
if [[ $(uname) == CYGWIN_NT-*-WOW64 ]] ; then
wget http://dashingsoft.com/products/slapos/ipwin_x64.exe -O /usr/bin/ipwin.exe || wget http://dashingsoft.com/products/slapos/ipwin_x64.exe -O /usr/bin/ipwin.exe ||
csih_error "download ipwin_x64.exe failed" csih_error "download ipwin_x64.exe failed"
csih_inform "download ipwin_x64.exe OK" csih_inform "download ipwin_x64.exe OK"
else else
wget http://dashingsoft.com/products/slapos/ipwin_x86.exe -O /usr/bin/ipwin.exe || wget http://dashingsoft.com/products/slapos/ipwin_x86.exe -O /usr/bin/ipwin.exe ||
csih_error "download ipwin_x86.exe failed" csih_error "download ipwin_x86.exe failed"
csih_inform "download ipwin_x86.exe OK" csih_inform "download ipwin_x86.exe OK"
fi
chmod +x /usr/bin/ipwin.exe || csih_error "chmod /usr/bin/ipwin.exe failed"
fi fi
chmod +x /usr/bin/ipwin.exe || csih_error "chmod /usr/bin/ipwin.exe failed"
csih_inform "Patch cygwin packages for building slapos OK" csih_inform "Patch cygwin packages for building slapos OK"
echo "" echo ""
...@@ -146,6 +149,7 @@ mkdir -p /opt/slapos/log ...@@ -146,6 +149,7 @@ mkdir -p /opt/slapos/log
csih_inform "mkdir /opt/download-cache" csih_inform "mkdir /opt/download-cache"
mkdir -p /opt/download-cache mkdir -p /opt/download-cache
[[ -f /opt/slapos/buildout.cfg ]] ||
(cd /opt/slapos && echo "[buildout] (cd /opt/slapos && echo "[buildout]
extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg
download-cache = /opt/download-cache download-cache = /opt/download-cache
...@@ -153,11 +157,13 @@ prefix = ${buildout:directory} ...@@ -153,11 +157,13 @@ prefix = ${buildout:directory}
" > buildout.cfg && " > buildout.cfg &&
csih_inform "buildout.cfg generated") csih_inform "buildout.cfg generated")
[[ -f /opt/slapos/bootstrap.py ]] ||
(cd /opt/slapos ; (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 || 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_error "download bootstrap.py failed"
csih_inform "download bootstrap.py OK") csih_inform "download bootstrap.py OK")
[[ -f /opt/slapos/bin/buildout ]] ||
(cd /opt/slapos ; (cd /opt/slapos ;
python -S bootstrap.py || csih_error "run bootstrap.py failed" python -S bootstrap.py || csih_error "run bootstrap.py failed"
csih_inform "run bootstrap.py OK") csih_inform "run bootstrap.py OK")
...@@ -166,15 +172,17 @@ csih_inform "start bin/buildout" ...@@ -166,15 +172,17 @@ csih_inform "start bin/buildout"
(cd /opt/slapos ; bin/buildout -v -N || csih_error "bin/buildout failed") (cd /opt/slapos ; bin/buildout -v -N || csih_error "bin/buildout failed")
_filename=~/slapos-core-format.patch _filename=~/slapos-core-format.patch
[[ -f ${_filename} ]] ||
wget http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/slapos-core-format.patch -O ${_filename} || wget 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_error "download ${_filename} failed"
csih_inform "download ${_filename} OK" csih_inform "download ${_filename} OK"
((cd $(ls -d /opt/slapos/eggs/slapos.core-*.egg/) || csih_error "no slapos.core egg found") && csih_inform "applay patch ${_filename}"
(cd $(ls -d /opt/slapos/eggs/slapos.core-*.egg/) &&
csih_inform "patch at $(pwd)" && csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null && patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} && patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename}") csih_inform "apply patch ${_filename} OK")
csih_inform "Run buildout of slapos node OK" csih_inform "Run buildout of slapos node OK"
echo "" echo ""
...@@ -193,6 +201,13 @@ mkdir -p /etc/opt/slapos/ssl/partition_pki ...@@ -193,6 +201,13 @@ mkdir -p /etc/opt/slapos/ssl/partition_pki
csih_inform "mkdir ${slapos_client_home}" csih_inform "mkdir ${slapos_client_home}"
mkdir -p ${slapos_client_home} mkdir -p ${slapos_client_home}
(cp ~/certificate ${client_certificate_file} &&
cp ~/key ${client_key_file} &&
cp ~/computer.crt ${node_certificate_file} &&
cp ~/computer.key ${node_key_file} &&
csih_inform "copy certificate/key files OK") ||
csih_error "copy certificate/key files failed"
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")
[[ "${computer_guid}" == COMP-+([0-9]) ]] || [[ "${computer_guid}" == COMP-+([0-9]) ]] ||
...@@ -242,6 +257,7 @@ echo "" ...@@ -242,6 +257,7 @@ echo ""
# ----------------------------------------------------------- # -----------------------------------------------------------
csih_inform "Formating SlapOS Node ..." csih_inform "Formating SlapOS Node ..."
netsh interface ipv6 add addr ${slapos_ifname} ${ipv6_local_address}
/opt/slapos/bin/slapos node format -cv --now || /opt/slapos/bin/slapos node format -cv --now ||
csih_error "Run slapos node format failed. " csih_error "Run slapos node format failed. "
......
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