Commit f11575b5 authored by Jondy Zhao's avatar Jondy Zhao

Change the directory of installed files in the setup scripts

parent ccc6348b
#! /bin/bash
#
#------------------------------------------------------------------------------
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#------------------------------------------------------------------------------
#
# Run this script need the administrator priviledge.
#
# return GUID of physical netcard only
#
# Get the value of Characteristics of each interface,
#
# Characteristics & NCF_VIRTUAL == NCF_VIRTUAL
# Characteristics & NCF_PHYSICAL == NCF_PHYSICAL
#
function get_all_physical_netcard()
{
local -r NCF_VIRTUAL=1
local -r NCF_PHYSICAL=4
local -r NCF_HIDDEN=8
local -r NCF_HAS_UI=0x80
local -r NCF_EXPECTED=$((NCF_PHYSICAL | NCF_HAS_UI))
key='\HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}'
for subkey in $(regtool -q list "$key") ; do
local -i flags=$(regtool -q get "$key\\$subkey\Characteristics")
if (( (flags & NCF_EXPECTED) == NCF_EXPECTED )) ; then
regtool -q get "$key\\$subkey\NetCfgInstanceId" && return 0
fi
done
}
# get connection name by IF_GUID
function get_connection_name()
{
key='\HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002bE10318}'
echo $(regtool -q get "$key\\$IF_GUID\Connection\Name")
}
#
# Tell by getmac, if GUID can be found, it's ok, else disabled or not connected
function get_interface_state()
{
getmac /V /FO list | grep "${INTERFACENAME}"
return $?
}
# test code
# slist=$(get_all_physical_netcard)
# echo physical netcards: $slist
# for s in $slist ; do
# INTERFACE_NAME=$s
# echo conn name is $(get_connection_name)
# done
# get_local_ip_version
# echo version is $local_ip_version
# exit 0
if [[ ! $(whoami) == Administrator ]] ; then
echo "Error: only administrator can run this script."
exit 1
fi
if [[ ! -d ~/.slapos ]] ; then
echo "INFO: mkdir ~/.slapos"
mkdir ~/.slapos
fi
if [[ ! ( -f ~/.slapos/certificate && -f ~/.slapos/key ) ]] ; then
echo "Error: missing certificate and key in the ~/.slapos \
If you haven't an account in the slapos.org, please login https://www.slapos.org and signup. Otherwise to be sure both of files are stored in the ~/.slapos
"
exit 1
fi
if [[ ! -f ~/.slapos/slapos.cfg ]] ; then
echo "INFO: generate configure file '~/.slapos/slapos.cfg'"
echo "[slapos]
master_url = https://slap.vifib.com/
[slapconsole]
# Put here retrieved certificate from vifib.
# Beware: put certificate from YOUR account, not the one from your node.
# You (as identified person from vifib) will request an instance, node your node.
# Conclusion: node certificate != person certificate.
cert_file = ~/.slapos/certificate
key_file = ~/.slapos/key
# Below are softwares supported by Vifib
alias =
" > ~/.slapos/slapos.cfg
fi
# Remove startup item first.
RUNKEY='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
SLAPOSNODEINIT=SlapOS-Node
regtool -q unset "$RUNKEY\\$SLAPOSNODEINIT"
nodename=$(hostname)
cd /opt/slapos
bin/slapos node register $nodename
# Check computer configure file: /etc/opt/slapos/slapos.cfg
nodecfg=/etc/opt/slapos/slapos.cfg
if [[ ! -f $nodecfg ]] ; then
echo Error: something is wrong when register node. Can not find the configure file $nodecfg.
exit 1
fi
# check ipv6
netsh interface ipv6 show interface > /dev/null || netsh interface ipv6 install
# get GUID of the first physics netcard
guidname=get_all_physical_netcard
if [[ "$guidname" == "" ]] ; then
echo Error: no any physical netcard found.
exit 1
fi
#
# Replace interface_name in the configure name
#
# generate /etc/slapos/slapos.cfg
sed -i -e "s/^\\s*interface_name.*$/interface_name = ${IPINTERFACE}/g" \
-e "s/^#\?\\s*ipv6_interface.*$/# ipv6_interface =/g" \
$nodecfg
#
# Add run item when windows startup
echo Set slapos init script as Windows startup item.
regtool -q set "$RUNKEY\\$SLAPOSNODEINIT" "\"$(cygpath -w /usr/bin/sh)\" --login -i /etc/slapos/scripts/init-slapos-node.sh"
(( $? )) && echo Fail to set init script as startup item.
......@@ -22,7 +22,10 @@ Name: "{app}\cygwin\etc\slapos\scripts"
Source: "cygwin-packages\*"; DestDir: "{app}\cygwin-packages"; Flags: recursesubdirs;
Source: "publish\buildout\slapos\*"; DestDir: "{app}\cygwin\opt\slapos"; Flags: recursesubdirs;
Source: "opt\git\re6stnet\dist\re6stnet-0.1.tar.gz"; DestDir: "{app}\cygwin"; DestName: "re6stnet.tar.gz"; Flags: deleteafterinstall;
Source: "opt\git\slapos\component\cygwin\slapos-core.patch"; DestDir: "{app}\cygwin\etc\slapos\patches";
Source: "opt\git\slapos\component\cygwin\slapos-cookbook-inotifyx.patch"; DestDir: "{app}\cygwin\etc\slapos\patches";
Source: "opt\git\re6stnet\dist\re6stnet-0.1.tar.gz"; DestDir: "{app}\cygwin"; DestName: "re6stnet-0.1.tar.gz"; Flags: deleteafterinstall;
Source: "opt\downloads\miniupnpc-1.8.tar.gz"; DestDir: "{app}\cygwin"; DestName: "miniupnpc.tar.gz"; Flags: deleteafterinstall;
Source: "opt\git\slapos.recipe.cmmi\dist\slapos.recipe.cmmi-0.1.tar.gz"; DestDir: "{app}\opt\download-cache\dist";
......@@ -35,15 +38,12 @@ Source: "images\register.ico"; DestDir: "{app}\images";
Source: "images\updater.ico"; DestDir: "{app}\images";
Source: "images\manager.ico"; DestDir: "{app}\images";
Source: "src\setup-cygwin.bat"; DestDir: "{app}";
Source: "setup.exe"; DestDir: "{app}\cygwin-packages";
Source: "src\win32\ip"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\useradd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\usermod"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\groupadd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\brctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\tunctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\ip"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\useradd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\usermod"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\groupadd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\usr\local\bin";
......@@ -51,14 +51,14 @@ Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe";
Source: "src\docs\openvpn\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\docs\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "src\win32\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\init-cygwin.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\init-re6stnet.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-cygwin.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-re6stnet.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
Source: "src\win32\README.cygwin"; DestDir: "{app}"; DestName: "readme.txt";
Source: "src\docs\README.cygwin"; DestDir: "{app}"; DestName: "readme.txt";
[Icons]
Name: "{commondesktop}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\desktop"; IconFilename: "{app}\imapges\slapos.ico";
......
......@@ -37,12 +37,12 @@ Source: "images\register.ico"; DestDir: "{app}\images";
Source: "images\updater.ico"; DestDir: "{app}\images";
Source: "images\manager.ico"; DestDir: "{app}\images";
Source: "src\win32\ip"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\useradd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\usermod"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\groupadd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\brctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\win32\tunctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\ip"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\useradd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\usermod"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\groupadd"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\usr\local\bin";
......@@ -50,14 +50,14 @@ Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe";
Source: "src\docs\openvpn\devcon.exe"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "src\docs\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "src\win32\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\init-cygwin.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\init-re6stnet.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\win32\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-cygwin.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\init-re6stnet.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "src\docs\using-slapos-in-windows.html"; DestDir: "{app}"; DestName: "user-guide.html";
Source: "src\win32\README.cygwin"; DestDir: "{app}"; DestName: "readme.txt";
Source: "src\docs\README.cygwin"; DestDir: "{app}"; DestName: "readme.txt";
[Icons]
Name: "{commondesktop}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\desktop"; IconFilename: "{app}\imapges\slapos.ico";
......
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