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

Change windows installer scripts

parent 51a4a9f5
This diff is collapsed.
......@@ -6,47 +6,57 @@
#
# It will do:
#
# 1. Set uid of Adminstrator to 0, and create root account
# * Set uid of Adminstrator to 0, and create root account
#
# 2. Create .minttyrc and cygtty.bat, which used to start comand console
# * Create .minttyrc and cygtty.bat, which used to start comand console
#
# 3. Configure cygserver
# * Create autorebase.bat, it used to fix cygwin dll problem
#
# 4. Configure syslog-ng
#
if [[ ! "$(whoami)" == "Administrator" ]] ; then
exit 1
# * Change readme.txt to dos format
#
password_filename=/etc/passwd
echo Checking passwd file ...
if [[ ! -f $password_filename ]] ; then
echo No passwd file found.
mkpasswd > $password_filename
echo Generate passwd file OK.
else
echo Check passwd file OK.
fi
if [[ ! -f /etc/passwd ]] ; then
mkpasswd > /etc/passwd
echo Checking group file ...
if [[ ! -f /etc/group ]] ; then
echo No group file found.
mkgroup > /etc/group
echo Generate group file OK.
else
cp /etc/passwd /etc/passwd.orig
echo Check group file OK.
fi
# sed -i -e "s/Administrator:unused:500:/Administrator:unused:0:/g" /etc/passwd
grep -q "^root:" /etc/passwd
if (( $? != 0 )) ; then
myaccount=$(grep "^Administrator:" /etc/passwd | \
sed -e "s/Administrator:unused:500:/root:unused:0:/g")
if [[ "${myaccount:0:4}" == root ]] ; then
echo $myaccount >> /etc/passwd
else
exit 1
fi
fi
# grep -q "^root:" $password_filename
# if (( $? != 0 )) ; then
# myaccount=$(grep "^Administrator:" $password_filename | \
# sed -e "s/Administrator:unused:500:/root:unused:0:/g")
# if [[ "${myaccount:0:4}" == root ]] ; then
# echo $myaccount >> $password_filename
# else
# exit 1
# fi
# fi
if [[ ! -f ~/.minttyrc ]] ; then
echo Creating ~/.minttyrc
cat <<EOF > ~/.minttyrc
BoldAsFont=no
Font=Courier New
FontHeight=16
Scrollbar=none
EOF
echo File ~/.minttyrc created
fi
if [[ ! -f /cygtty.bat ]] ; then
echo Creating /cygtty.bat
cyghome=$(cygpath -w /)
cat <<EOF > /cygtty.bat
@echo off
......@@ -57,24 +67,37 @@ chdir ${cyghome}\\bin
start mintty.exe -i /Cygwin-Terminal.ico -
EOF
chmod +x /cygtty.bat
echo File /cygtty.bat created.
fi
# Configure cygserver
/usr/bin/cygserver-config --yes
# Configure syslog-ng
/usr/bin/syslog-ng-config --yes
# Copy rebaseall.bat to /
if [[ -f /etc/postinstall/autorebase.bat.done ]] ; then
cp /etc/postinstall/autorebase.bat.done /autorebase.bat
if [[ ! -f /autorebase.bat ]] ; then
echo Create /autorebase.bat
copy <<EOF > /autorebase.bat
@echo off
rem Postinstall scripts are always started from the Cygwin root dir
rem so we can just call dash from here
path .\bin;%path%
dash /bin/rebaseall -p
EOF
chmod +x /autorebase.bat
echo /autorebase.bat created.
fi
# Change format of readme.txt
readme_filepath=$(cygpath -m /)/..
if [[ -f $readme_filepath/Readme.txt ]] ; then
unix2dos $readme_filepath/Readme.txt
echo Change readme.txt to dos format OK.
fi
# Remove cygwin services to be sure these services will be configured
# in this cygwin enviroments when there are many cygwin instances
# installed in this computer.
for x in $(cygrunsrv --list) ; do
echo Removing cygservice $x
cygrunsrv -R $x
done
exit 0
#! /bin/bash
#
# When uninstall slapos, it will be called by uninstaller.
# When uninstall slapos, it will be called by uninstaller. Root right
# required to run this script.
#
# /bin/bash/ --login -i pre-uninstall.sh
#
......@@ -8,24 +9,15 @@
#
# 1. Remove virtual netcards installed by re6stnet
#
# 2. Remove service cygserver and syslog-ng
# 2. Remove service cron, cygserver and syslog-ng
#
if [[ ! "$(whoami)" == "Administrator" ]] ; then
exit 1
fi
#
# Remove slapos-init script when windows startup
#
run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=SlapOS-Node
regtool -q unset "$run_key\\$slapos_run_entry"
#
# Remove virtual netcard installed by re6stnet
#
for ifname in $(netsh interface show interface | gawk '{ print $3 }') ; do
if [[ ("$ifname" == re6stnet*) && ("$ifname" != "re6stnet-lo") ]] ; then
echo Removing network connection: $ifname
ip vpntap del dev $ifname mode true
fi
done
......@@ -33,8 +25,10 @@ done
#
# Remove services installed by cygwin
#
cygrunsrv.exe --remove syslog-ng
cygrunsrv.exe --remove cygserver
for x in $(cygrunsrv --list) ; do
echo Removing cygservice $x
cygrunsrv -R $x
done
exit 0
......@@ -64,6 +64,7 @@ Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node-runner.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\pre-uninstall.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
......@@ -71,18 +72,18 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Node Runner"; Filename: "http://{app}\cygwin\etc\slapos\scripts\slap-runner.html"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -h never -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\SlapOS Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist;
[UninstallRun]
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist runhidden;
......
This diff is collapsed.
......@@ -19,3 +19,22 @@ if [[ -f $current_path/node-runner.vbs ]] ; then
cyg_cscript $current_path/node-runner.vbs || (echo Failed to start slap-runner ; exit 1)
echo Start slap-runner OK.
fi
cat <<EOF > slap-runner.html
d>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
location.reload("url")
}
//-->
</script>
</head>
<body onload="openwin()">
</body>
</html>
EOF
#! /bin/bash
export PATH=/usr/local/bin:/usr/bin:$PATH
ifname=re6stnet-lo
#
# Check ipv6 connection by default ipv6 route
#
function check_ipv6_connection()
{
netsh interface ipv6 show route | grep -q " ::/0 "
}
ping6 slap.vifib.com > /dev/null
#
# Check cygwin service
#
function check_cygwin_service()
{
service_name=$1
echo Checking $1 service ...
if [ ! -e /usr/bin/cygrunsrv.exe ]; then
show_error_exit "No cygserver found, please install the cygrunsrv package first."
fi
service_account="$(cygrunsrv -VQ $service_name | sed -n -e 's/^Account[ :]*//p')" || \
show_error_exit "No $1 service install, please run Configure SlapOS to install it."
service_state=$(cygrunsrv --query $service_name | sed -n -e 's/^Current State[ :]*//p')
if [[ ! x$service_state == "xRunning" ]] ; then
echo Warning: Cygwin service $1 currnt state is $service_state, Running is expeted
echo Try to use cygrunsrv --start $1 to start this service
fi
echo Check $1 service OVER.
}
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Failed to configure Slapos Node in this computer.}
echo $msg
read -n 1 -p "Press any key to exit..."
exit 1
}
#-------------------------------------------------
# Constants
#-------------------------------------------------
slapos_ifname=re6stnet-lo
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo "Checking native IPv6 ..."
check_ipv6_connection
# Run re6stnet if no native ipv6
if (( $? )) ; then
echo "Start re6stnet ..."
(cd /etc/re6stnet; re6stnet @re6stnet.conf --ovpnlog -I $ifname -i $ifname &)
echo "Start re6stent in the background OK."
echo "Waiting re6stent network work ..."
while true ; do
ping6 slap.vifib.com && break
done
echo "No native IPv6."
echo Check re6stnet network ...
which re6stnet > /dev/null || show_error_exit "Error: no re6stnet installed, please run Configure SlapOS first."
# re6st-conf --is-needed --registry http://re6stnet.nexedi.com/
ps -ef | grep -q babeld.exe
if (( $? )) ; then
echo "Start re6stnet ..."
# It need root rights to install tap-driver
(cd /etc/re6stnet; re6stnet @re6stnet.conf --ovpnlog -I $slapos_ifname -i $slapos_ifname &)
echo "Start re6stent in the background OK. You can check log files in the /var/log/re6stnet"
echo "Waiting re6stent network work ..."
while true ; do
check_ipv6_connection && break
done
fi
echo "re6stnet network OK."
else
echo "Native IPv6 Found."
fi
# Format slapos node
#-------------------------------------------------
# Check cygserver, syslog-ng
#-------------------------------------------------
check_cygwin_service cygserver
check_cygwin_service syslog-ng
#-------------------------------------------------
# Format slapos node, need root right
#-------------------------------------------------
[[ -f /etc/opt/slapos/slapos.cfg ]] || \
show_error_exit "Error: no node configure file found, please run Configure SlapOS first."
echo "Run Slapos format ..."
/opt/slapos/bin/slapos node format -cv --now
if (( $? )) ; then
echo "Failed to run slapos format."
exit 1
else
echo "Format slapos node OK."
fi
/opt/slapos/bin/slapos node format -cv --now || \
show_error_exit "Failed to run slapos format."
echo "Format slapos node OK."
#-------------------------------------------------
# Release software
#-------------------------------------------------
echo "Releasing software ..."
/opt/slapos/bin/slapos node software
if (( $? )) ; then
echo "Failed to relase software in the slapos node."
exit 1
else
echo "Release software OK."
fi
/opt/slapos/bin/slapos node software --verbose
#-------------------------------------------------
# Instance software
#-------------------------------------------------
echo "Creating instance ..."
/opt/slapos/bin/slapos node instance
if (( $? )) ; then
echo "Failed to create instance in the slapos node."
exit 1
else
echo "Create instance OK."
fi
/opt/slapos/bin/slapos node instance --verbose
#-------------------------------------------------
# Send report
/opt/slapos/bin/slapos node report
#-------------------------------------------------
echo "Sending report ..."
/opt/slapos/bin/slapos node report --verbose
exit 0
......@@ -58,6 +58,7 @@ Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-configure.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node-runner.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slap-runner.html"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\pre-uninstall.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
......@@ -65,19 +66,19 @@ Source: "opt\git\slapos.package\windows\docs\README.cygwin"; DestDir: "{app}"; D
[Icons]
Name: "{commondesktop}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Node"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Node Runner"; Filename: "http://{app}\cygwin\etc\slapos\scripts\slap-runner.html"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\SlapOS Desktop"; Filename: "https://www.slapos.org/"; IconFilename: "{app}\cygwin\etc\slapos\images\slapos.ico";
Name: "{group}\Node Runner"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-w hide -h never -l /var/log/slapos-node-runner.log /etc/slapos/scripts/slapos-node-runner.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\SlapOS Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\cygtty.bat"; WorkingDir: "{app}\cygwin\opt\slapos"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Configure SlapOS"; Filename: "{app}\cygwin\bin\mintty.exe"; Parameters: "-c ~/.minttyrc -h never -t ""Configure SlapOS Client"" /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\bin"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Uninstall SlapOS"; Filename: "{uninstallexe}";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"" network"; StatusMsg: "Installing Cygwin..."; Flags: runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Builout process"; StatusMsg: "Building SlapOS..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist;
[UninstallRun]
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist runhidden;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment