Commit 3bcd34bc authored by Jondy Zhao's avatar Jondy Zhao

Use ipwin to install/uninstall netadapter and get guid

parent b0a417ab
...@@ -297,6 +297,12 @@ make ...@@ -297,6 +297,12 @@ make
cp src/openvpn/.libs/openvpn.exe /usr/bin cp src/openvpn/.libs/openvpn.exe /usr/bin
</programlisting> </programlisting>
<!-- Now downlaod openvpn 2.3 for your window version, and install it. We need OpenVPN Tap-Windows Drivers files. --> <!-- Now downlaod openvpn 2.3 for your window version, and install it. We need OpenVPN Tap-Windows Drivers files. -->
Now, build ipwin.exe which used to manage slapos network. If you have msvc build environments, build the solution "D:/slapos/opt/git/slapos.packages/windows/ipwin/ipwin.sln" as your perfer. If you have no idea about msvc, do as the following steps:
<itemizedlist>
<listitem><para>Install Microsoft Visual C++ 2008 Express Edition, you can download package from <ulink url=""/>, it's free.</para></listitem>
<listitem><para>If you're running X64 environments, install Microsoft Windows SDK v7.0. You can download the package from <ulink url="http://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDKX_EN_DVD.iso"/>.</para></listitem>
<listitem><para>Double click D:/slapos/opt/git/slapos.packages/windows/ipwin/ipwin/build.bat, be sure there is no error.</para></listitem>
</itemizedlist>
</para> </para>
<para> <para>
Then generate user-guide.html from using-slapos-in-windows.xml, generally you need not do this, just copy this file (you're looking now) to /opt/git/slapos.package/windows/docs. If you require want to generate the document by your self, make sure docbook-utils package installed in the Cygwin. Refer to <xref linkend="package-docbook-utils"/> to know what about docbook-utils. Then generate user-guide.html from using-slapos-in-windows.xml, generally you need not do this, just copy this file (you're looking now) to /opt/git/slapos.package/windows/docs. If you require want to generate the document by your self, make sure docbook-utils package installed in the Cygwin. Refer to <xref linkend="package-docbook-utils"/> to know what about docbook-utils.
......
...@@ -295,7 +295,7 @@ function prefix_to_netmask() ...@@ -295,7 +295,7 @@ function prefix_to_netmask()
# Parameter: # Parameter:
# ifname: interface name or guid name # ifname: interface name or guid name
# #
# If ifname is guid name, return the corresponding connection name, # If ifname is guid name, return fix connection name: re6stnet-lo,
# otherwise return the original ifname. # otherwise return the original ifname.
# #
function format_interface_name() function format_interface_name()
...@@ -308,46 +308,10 @@ function format_interface_name() ...@@ -308,46 +308,10 @@ function format_interface_name()
if ! [[ "${guid:0:1}" == "{" ]] ; then if ! [[ "${guid:0:1}" == "{" ]] ; then
echo $1 echo $1
else else
which ipv6 > /dev/null 2>&1 echo "re6stnet-lo"
if (( $? )) ; then
getmac /fo list /v | grep -B3 "^Transport Name:.*$guid" | grep "^Connection Name:" | sed -e "s/^Connection Name: *//g"
else
ipv6 if | grep -B1 "${guid}" | \
sed -e "2d" -e "s/^Interface[0-9: ]\+\(Ethernet: \)\?//g"
fi
fi fi
} }
# ======================================================================
# Routine: get_all_connections
# Return all connection names line by line, and replace space with '%'
# ======================================================================
function get_all_connections()
{
netsh interface ipv6 show interface | \
grep "^[ 0-9]\+ " | \
sed -e "s/^[ 0-9]\+[a-zA-Z]\+//" -e "s/^\s*//" -e "s/ /%/g"
} # === get_all_connections() === #
# ======================================================================
# Routine: get_new_connection
# Check all the connection names, and compare the original connection
# list, return the new connection name
#
# Note: If nothing found, return empty
# If more than one, return the first one
# ======================================================================
function get_new_connection()
{
original_connections=" $* "
current_connections=$(get_all_connections)
for name in $current_connections ; do
[[ ! "$original_connections" == *[\ ]$name[\ ]* ]] && \
echo ${name//%/ } && return 0
done
} # === get_new_connections() === #
# #
# Parameter: # Parameter:
# ifname: connection name # ifname: connection name
...@@ -375,25 +339,13 @@ function install_tap_driver() ...@@ -375,25 +339,13 @@ function install_tap_driver()
return 1 return 1
fi fi
local DEVCON=$(which devcon.exe) local IPWIN=$(which ipwin.exe)
if [[ ! -x $DEVCON ]] ; then if [[ ! -x "$IPWIN" ]] ; then
echo "Error: no devcon.exe found" echo "Error: no ipwin.exe found"
return 1 return 1
fi fi
original_connections=$(echo $(get_all_connections)) $IPWIN install $DEVFILE $HWID $1
$DEVCON install $DEVFILE $HWID
# rename the connection name
if [[ ! "$1" == "" ]] ; then
connection_name=$(get_new_connection $original_connections)
if [[ -n "$connection_name" ]] ; then
netsh interface set interface name="$connection_name" newname="$1"
else
echo Failed to get new connection name.
return 1
fi
fi
} }
# #
...@@ -405,56 +357,21 @@ function install_tap_driver() ...@@ -405,56 +357,21 @@ function install_tap_driver()
# #
function uninstall_tap_driver() function uninstall_tap_driver()
{ {
local DEVCON=$(which devcon.exe) local ipwin=$(which ipwin.exe)
local CSCRIPT=$(which cscript.exe)
local GETSCRIPT=$(cygpath -m /etc/slapos/scripts/get_pnpid_connection.vbs)
if [[ "$1" == "" ]] ; then if [[ "$1" == "" ]] ; then
echo "Error: missing connection name" echo "Error: missing connection name"
return 1 return 1
fi fi
local IFNAME=$1 local ifname=$1
if [[ ! -x $DEVCON ]] ; then
echo "Error: no devcon.exe found"
return 1
fi
if [[ ! -x $CSCRIPT ]] ; then if [[ ! -x "$ipwin" ]] ; then
echo "Error: no cscript.exe found" echo "Error: no ipwin.exe found"
return 1 return 1
fi fi
if [[ ! -f $GETSCRIPT ]] ; then $ipwin remove tap0901 $ifname
cat <<EOF > $GETSCRIPT
If WScript.Arguments.Count < 1 Then
WScript.Echo "Error: missing paramter connection name"
WScript.Quit(1)
End If
strComputer = "."
strDriverName = "TAP-Windows Adapter V9"
strConnectionName = WScript.Arguments(0)
Set objWMIService = GetObject("winmgmts:\\\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery(_
"SELECT PNPDeviceID FROM Win32_NetworkAdapter WHERE Name='" _
& strDriverName & "' AND NetConnectionID='" & strConnectionName & "'", _
"WQL", 48)
strDeviceID = ""
For Each objItem In colItems
strDeviceID = objItem.PNPDeviceID
Next
WScript.StdOut.Write(strDeviceId)
WScript.Quit(0)
EOF
fi
local PNPDEVICEID=$($CSCRIPT //Nologo "$GETSCRIPT" "$IFNAME")
if (( $? == 0 )) ; then
$DEVCON remove =Net "@$PNPDEVICEID"
return $?
fi
} }
orig_cmd="$0 $*" orig_cmd="$0 $*"
......
...@@ -105,9 +105,9 @@ fi ...@@ -105,9 +105,9 @@ fi
# Remove cygwin services to be sure these services will be configured # Remove cygwin services to be sure these services will be configured
# in this cygwin enviroments when there are many cygwin instances # in this cygwin enviroments when there are many cygwin instances
# installed in this computer. # installed in this computer.
for x in $(cygrunsrv --list) ; do for name in $(cygrunsrv --list) ; do
echo Removing cygservice $x echo Removing cygservice $name
cygrunsrv -R $x cygrunsrv -R $name
done done
# Backup slap-runner.html # Backup slap-runner.html
......
...@@ -21,18 +21,21 @@ export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH ...@@ -21,18 +21,21 @@ export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
# Remove virtual netcard installed by re6stnet # Remove virtual netcard installed by re6stnet
# #
for ifname in $(netsh interface ipv6 show interface | gawk '{ print $5 }') ; do for ifname in $(netsh interface ipv6 show interface | gawk '{ print $5 }') ; do
if [[ ("$ifname" == re6stnet*) && ("$ifname" != "re6stnet-lo") ]] ; then if [[ "$ifname" == "re6stnet-lo" ]] ; then
echo Removing network connection: $ifname echo Removing network connection: $ifname
ip vpntap del dev $ifname mode true ipwin remove *msloop re6stnet-lo
elif [[ "$ifname" == re6stnet* ]] ; then
echo Removing network connection: $ifname
ipwin remove tap0901 $ifname
fi fi
done done
# #
# Remove services installed by cygwin # Remove services installed by cygwin
# #
for x in $(cygrunsrv --list) ; do for name in $(cygrunsrv --list) ; do
echo Removing cygservice $x echo Removing cygservice $name
cygrunsrv -R $x cygrunsrv -R $name
done done
# #
...@@ -75,4 +78,3 @@ regtool -q unset "$slapos_run_key\\$slapos_run_entry" ...@@ -75,4 +78,3 @@ regtool -q unset "$slapos_run_key\\$slapos_run_entry"
echo Run pre-uninstall script successfully. echo Run pre-uninstall script successfully.
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
...@@ -48,6 +48,8 @@ Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\b ...@@ -48,6 +48,8 @@ Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\b
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\ipwin\ipwin\ipwin.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
......
#! /bin/bash
#
# Configure slapos desktop,
#
# Usage:
#
# ./slapos-client-config certificate_file key_file
#
export PATH=/usr/local/bin:/usr/bin:$PATH
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Configure node failed.}
echo $msg
read -n 1 -t 15 -p "Press any key to exit..."
exit 1
}
slapos_client_home=~/.slapos
client_configure_file=$slapos_client_home/slapos.cfg
client_certificate_file=$slapos_client_home/certificate
client_key_file=$slapos_client_home/key
template_configure_file=/etc/slapos/slapos-client.cfg.example
mkdir -p $slapos_client_home
#
# Generate desktop configure file
#
echo
echo Before continue to configure, make sure you have an account in the
echo slapos.org community, and have obtained X509 certificate and key
echo which are needed for the following configuration process.
echo
echo Refer to http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Installing.SlapOS.Client
echo
if [[ -f "$1" ]] ; then
echo "Copy certificate from $2 to $client_certificate_file"
cp $1 $client_certificate_file
elif [[ ! -f $client_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \
show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $client_certificate_file"
certificate_file=$(cygpath -u $certificate_file)
cp $certificate_file $client_certificate_file
fi
if [[ -f "$2" ]] ; then
echo "Copy key from $3 to $client_key_file"
cp $2 $client_key_file
elif [[ ! -f $client_key_file ]] ; then
read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \
show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $client_key_file"
key_file=$(cygpath -u $key_file)
cp $key_file $client_key_file
fi
if [[ ! -f $client_configure_file ]] ; then
[[ -f $template_configure_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example) || \
show_error_exit "Download slapos-client.cfg.example failed."
cp $template_configure_file $client_configure_file
fi
sed -i -e "s%^cert_file.*$%cert_file = $client_certificate_file%" \
-e "s%^key_file.*$%key_file = $client_key_file%" \
$client_configure_file
echo SlapOS Client configure successfully.
read -n 1 -p "Press any key to exit..."
exit 0
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
# taps Install OpenVPN Tap-Windows Driver for re6stnet # taps Install OpenVPN Tap-Windows Driver for re6stnet
# config Generate slapos node and client configure files # config Generate slapos node and client configure files
# cron Generate cron file and start cron job # cron Generate cron file and start cron job
# startup Run slapos-configure.sh on windows startup
# runner Install web runner for this node # runner Install web runner for this node
# #
source $(/usr/bin/dirname $0)/slapos-include.sh source $(/usr/bin/dirname $0)/slapos-include.sh
...@@ -62,6 +61,7 @@ fi ...@@ -62,6 +61,7 @@ fi
# devcon # devcon
# openssl # openssl
# export WINDIR # export WINDIR
# ipwin
# ----------------------------------------------------------- # -----------------------------------------------------------
# Create paths # Create paths
......
...@@ -163,36 +163,6 @@ function check_re6stnet_needed() ...@@ -163,36 +163,6 @@ function check_re6stnet_needed()
return 0 return 0
} # === check_re6stnet_needed() === # } # === check_re6stnet_needed() === #
# ======================================================================
# Routine: get_all_connections
# Return all connection names line by line, and replace space with '%'
# ======================================================================
function get_all_connections()
{
netsh interface ipv6 show interface | \
grep "^[ 0-9]\+ " | \
sed -e "s/^[ 0-9]\+[a-zA-Z]\+//" -e "s/^\s*//" -e "s/ /%/g"
} # === get_all_connections() === #
# ======================================================================
# Routine: get_new_connection
# Check all the connection names, and compare the original connection
# list, return the new connection name
#
# Note: If nothing found, return empty
# If more than one, return the first one
# ======================================================================
function get_new_connection()
{
original_connections=" $* "
current_connections=$(get_all_connections)
for name in $current_connections ; do
[[ ! "$original_connections" == *[\ ]$name[\ ]* ]] && \
echo ${name//%/ } && return 0
done
} # === get_new_connections() === #
# ====================================================================== # ======================================================================
# Routine: reset_slapos_connection # Routine: reset_slapos_connection
# Remove all ipv4/ipv6 addresses in the connection re6stnet-lo # Remove all ipv4/ipv6 addresses in the connection re6stnet-lo
...@@ -200,17 +170,7 @@ function get_new_connection() ...@@ -200,17 +170,7 @@ function get_new_connection()
function reset_slapos_connection() function reset_slapos_connection()
{ {
ifname=${1-re6stnet-lo} ifname=${1-re6stnet-lo}
for addr in $(netsh interface ipv6 show address $ifname level=normal | \
grep "^Manual" | \
sed -e "s/^\(\w\+\s\+\)\{4\}//") ; do
netsh interface ipv6 del address $ifname $addr
done
netsh interface ip set address $ifname source=dhcp netsh interface ip set address $ifname source=dhcp
# for addr in $(netsh interface ip show address $ifname | \
# grep "IP Address:" | \
# sed -e "s/IP Address://") ; do
# netsh interface del address $ifname $addr
# done
} # === reset_slapos_connection() === # } # === reset_slapos_connection() === #
# ====================================================================== # ======================================================================
...@@ -219,39 +179,11 @@ function reset_slapos_connection() ...@@ -219,39 +179,11 @@ function reset_slapos_connection()
# ====================================================================== # ======================================================================
function connection2guid() function connection2guid()
{ {
ifname=${1-re6stnet-lo} local ifname=${1-re6stnet-lo}
# local hwid=${2-*msloop}
# This command doesn't work in the Windows 7, Window 8, maybe ipwin guid tap0901 $hwid $ifname
# Vista. Because no guid information in these platforms.
#
# netsh interface ipv6 show interface $ifname | \
# grep "^GUID\s*:" | \
# sed -e "s/^GUID\s*:\s*//"
#
# So we use getmac to repleace it:
getmac /fo list /v | grep -A3 "^Connection Name: *$ifname\$" \
| grep "^Transport Name:" | sed -e "s/^.*Tcpip_//g"
} # === connection2guid() === # } # === connection2guid() === #
# ======================================================================
# Routine: rename_connection_name
# Rename connection name by guid by changing registry
# $1 guid
# $2 new name
# ======================================================================
function rename_connection_name()
{
local guid=$1
local name=$2
local key='\HKLMHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\$guid\Connection'
if regtool check $key ; then
regtool set $key\\Name $name
else
echo Missing key name in the registry.
return 1
fi
} # === rename_connection_name() === #
# ====================================================================== # ======================================================================
# Routine: show_error_exit # Routine: show_error_exit
# Show error message and wait for user to press any key to exit # Show error message and wait for user to press any key to exit
......
#! /bin/bash
#
# Configure slapos node,
#
# 1. Install re6stnet if it hasn't
#
# 2. Register to nexedi re6stnet
#
# 3. Install msloop network adapter, named to re6stnet-lo
#
# It'll used as main interface for slapos and re6stnet
#
# 4. Create node configure file by parameters ca/key and computer id
#
# 5. Add init-slapos-node.sh as system startup item
#
# Usage:
#
# ./slapos-node-config
#
export PATH=/usr/local/bin:/usr/bin:$PATH
#
# Return connection name by line, and replace space with '%'
#
function get_all_connections()
{
netsh interface ipv6 show interface | \
grep "^[ 0-9]\+ " | \
sed -e "s/^[ 0-9]\+[a-zA-Z]\+//" -e "s/^\s*//" -e "s/ /%/g"
}
#
# Check all the connection names, and compare the original connection
# list, return the new connection name
#
# If nothing found, return empty
# If more than one, return the first one
#
function get_new_connection()
{
original_connections=" $* "
current_connections=$(get_all_connections)
for name in $current_connections ; do
[[ ! "$original_connections" == *[\ ]$name[\ ]* ]] && \
echo ${name//%/ } && return 0
done
}
#
# Remove all ipv4/ipv6 addresses in the connection re6stnet-lo
#
function reset_connection()
{
ifname=${1-re6stnet-lo}
for addr in $(netsh interface ipv6 show address $ifname level=normal | \
grep "^Manual" | \
sed -e "s/^\(\w\+\s\+\)\{4\}//") ; do
netsh interface ipv6 del address $ifname $addr
done
netsh interface ip set address $ifname source=dhcp
# for addr in $(netsh interface ip show address $ifname | \
# grep "IP Address:" | \
# sed -e "s/IP Address://") ; do
# netsh interface del address $ifname $addr
# done
}
#
# Transfer connection name to GUID
#
function connection2guid()
{
ifname=${1-re6stnet-lo}
getmac /fo list /v | grep -A3 "^Connection Name: *$ifname\$" \
| grep "^Transport Name:" | sed -e "s/^.*Tcpip_//g"
}
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Configure node failed.}
echo $msg
read -n 1 -t 15 -p "Press any key to exit..."
exit 1
}
node_certificate_file=/etc/opt/slapos/ssl/computer.crt
node_key_file=/etc/opt/slapos/ssl/computer.key
node_config_file=/etc/opt/slapos/slapos.cfg
node_template_file=/etc/slapos/slapos.cfg.example
run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=SlapOS-Node
slapos_ifname=re6stnet-lo
# Remove startup item first.
regtool -q unset "$run_key\\$slapos_run_entry"
#
# Add msloop network adapter, ane name it as "re6stnet-lo"
#
echo Checking slapos network adapter: $slapos_ifname ...
original_connections=$(echo $(get_all_connections))
if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then
echo Installing slapos network adapter ...
devcon install $WINDIR\\inf\\netloop.inf *MSLOOP
connection_name=$(get_new_connection $original_connections)
[[ "X$connection_name" == "X" ]] && \
show_error_exit "Add msloop network adapter failed."
echo
netsh interface set interface name="$connection_name" newname="$slapos_ifname"
fi
reset_connection $slapos_ifname
echo SlapOS network adapter OK.
#
# Generate Node Configure file
#
echo
echo Before continue to configure, make sure you have register your server to
echo slapos.org community Cloud, and have obtained X509 certificate and key
echo which are needed for the following configuration process.
echo
echo Refer to http://community.slapos.org/wiki/osoe-Lecture.SlapOS.Extended/developer-Installing.SlapOS.Slave.Node.Source
echo
mkdir -p /etc/opt/slapos/ssl/partition_pki
if [[ "$1" == COMP-+([0-9]) ]] ; then
computer_id=$1
else
[[ "X$1" == "X" ]] || echo "Invalid computer id: $1"
echo
echo Please input computer id you have registered, it looks like COMP-XXXX
read -p "computer id: " computer_id
fi
[[ "$computer_id" == COMP-+([0-9]) ]] || \
show_error_exit "Invalid computer id specified."
if [[ -f "$2" ]] ; then
echo "Copy certificate from $2 to $node_certificate_file"
cp $2 $node_certificate_file
elif [[ ! -f $node_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \
show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $node_certificate_file"
certificate_file=$(cygpath -u $certificate_file)
cp $certificate_file $node_certificate_file
fi
if [[ -f "$3" ]] ; then
echo "Copy key from $3 to $node_key_file"
cp $3 $node_key_file
elif [[ ! -f $node_key_file ]] ; then
read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \
show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $node_key_file"
key_file=$(cygpath -u $key_file)
cp $key_file $node_key_file
fi
# Hope it will not confilct with original network in the local machine
ipv4_local_network=10.201.67.0/24
# Add ipv4 address
ip -4 addr add $ipv4_local_network dev $slapos_ifname
# Create node configure file, replace interface_name with guid of
# re6stnet-lo
if [[ ! -f $node_config_file ]] ; then
[[ -f $node_template_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example) || \
show_error_exit "Download slapos.cfg.example failed."
cp $node_template_file $node_config_file
fi
interface_guid=$(connection2guid $slapos_ifname)
# generate /etc/slapos/slapos.cfg
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_id%" \
$node_config_file
# Config slapproxy
if ! $(grep -q "^\[slapproxy\]" $node_config_file) ; then
echo "
[slapproxy]
host = 127.0.0.1
port = 28080
database_uri = /var/lib/slapproxy.db
" >> $node_config_file
fi
#
# Re6stnet
#
# Check ipv6, install it if it isn't installed.
netsh interface ipv6 show interface > /dev/null || netsh interface ipv6 install
# miniupnpc is required by re6stnet
if [[ ! -d /opt/miniupnpc ]] ; then
if [[ -f /miniupnpc.tar.gz ]] ; then
echo "Installing miniupnpc ..."
cd /opt
tar xzf /miniupnpc.tar.gz --no-same-owner
mv $(ls -d miniupnpc-*) miniupnpc
cd miniupnpc
make
python setup.py install || echo "Install miniupnpc failed."
else
echo "No miniupnpc source package found."
fi
fi
# pyOpenSSL is required by re6stnet
if [[ ! -d /opt/pyOpenSSL ]] ; then
if [[ -f /pyOpenSSL.tar.gz ]] ; then
echo "Installing pyOpenSSL ..."
cd /opt
tar xzf /pyOpenSSL.tar.gz --no-same-owner
mv $(ls -d pyOpenSSL-*) pyOpenSSL
cd pyOpenSSL
python setup.py install || echo "Install pyOpenSSL failed."
fi
fi
# Install re6stnet
if [[ ! -d /opt/re6stnet ]] ; then
echo "Installing re6stnet ..."
cd /opt
if [[ -f /re6stnet.tar.gz ]] ; then
tar xzf /re6stnet.tar.gz --no-same-owner
mv $(ls -d re6stnet-*) re6stnet
else
echo "Clone re6stnet from http://git.erp5.org/repos/re6stnet.git"
git clone -b cygwin http://git.erp5.org/repos/re6stnet.git
fi
cd re6stnet
python setup.py install || echo "Install re6stnet failed."
fi
mkdir -p /etc/re6stnet
cd /etc/re6stnet
if [[ ! -f re6stnet.conf ]] ; then
re6st-conf --registry http://re6stnet.nexedi.com/
fi
[[ ! -f re6stnet.conf ]] && show_error_exit "Register to nexedi re6stnet failed"
grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf
#
# Add run item when windows startup
#
init_script=/etc/slapos/scripts/init-slapos-node
password_file=/etc/passwd
password_orig=/etc/slapos-format-passwd.orig
cygroot=$(cygpath -w -a /)
echo "Add ${init_script}.sh as Windows startup item."
[[ ! -f ${init_script}.bat ]] && cat <<EOF > ${init_script}.bat
@ECHO OFF
SETLOCAL
${cygroot:0:2}
CD "$(cygpath -w /usr/bin)"
.\cp $password_file $password_orig
.\sed -i -e "s/^Administrator:unused:500:513/Administrator:unused:0:513/" $password_file
START /B bash --login -i "${init_script}.sh"
.\sleep 3
.\cp $password_orig $password_file
ENDLOCAL
EXIT 0
EOF
# regtool -q set "$run_key\\$slapos_run_entry" \
# "\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \
# show_error_exit "Add startup item failed."
regtool -q set "$run_key\\$slapos_run_entry" \
"\"$(cygpath -w ${init_script}.bat)\"" || \
show_error_exit "Add startup item failed."
echo SlapOS Node configure successfully.
read -n 1 -p "Press any key to exit..."
exit 0
...@@ -43,6 +43,8 @@ Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\b ...@@ -43,6 +43,8 @@ Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\b
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\ipwin\ipwin\ipwin.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec; Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin"; Permissions: everyone-readexec;
......
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