Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
slapos.package
Commits
13dc65e4
Commit
13dc65e4
authored
Jul 04, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix add tap-driver in different locale problem
parent
48aabca1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
63 deletions
+41
-63
windows/scripts/ip
windows/scripts/ip
+41
-63
No files found.
windows/scripts/ip
View file @
13dc65e4
...
@@ -309,7 +309,7 @@ function format_interface_name()
...
@@ -309,7 +309,7 @@ function format_interface_name()
echo
$1
echo
$1
else
else
which ipv6
>
/dev/null 2>&1
which ipv6
>
/dev/null 2>&1
if
((
$?
))
;
then
if
((
$?
))
;
then
getmac /fo list /v |
grep
-B3
"^Transport Name:.*
$guid
"
|
grep
"^Connection Name:"
|
sed
-e
"s/^Connection Name: *//g"
getmac /fo list /v |
grep
-B3
"^Transport Name:.*
$guid
"
|
grep
"^Connection Name:"
|
sed
-e
"s/^Connection Name: *//g"
else
else
ipv6
if
|
grep
-B1
"
${
guid
}
"
|
\
ipv6
if
|
grep
-B1
"
${
guid
}
"
|
\
...
@@ -318,6 +318,36 @@ function format_interface_name()
...
@@ -318,6 +318,36 @@ function format_interface_name()
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
...
@@ -330,8 +360,6 @@ function install_tap_driver()
...
@@ -330,8 +360,6 @@ function install_tap_driver()
local
FILENAME
=
"/etc/slapos/driver/OemWin2k.inf"
local
FILENAME
=
"/etc/slapos/driver/OemWin2k.inf"
local
DEVFILE
=
$(
cygpath
-w
$FILENAME
)
local
DEVFILE
=
$(
cygpath
-w
$FILENAME
)
local
HWID
=
tap0901
local
HWID
=
tap0901
local
CHECKSCRIPT
=
$(
cygpath
-m
/etc/slapos/scripts/check_driver_signing_dialog.vbs
)
local
GETSCRIPT
=
$(
cygpath
-m
/etc/slapos/scripts/get_last_connection.vbs
)
# check if ifname has been installed
# check if ifname has been installed
if
[[
!
"
$1
"
==
""
]]
;
then
if
[[
!
"
$1
"
==
""
]]
;
then
...
@@ -353,67 +381,17 @@ function install_tap_driver()
...
@@ -353,67 +381,17 @@ function install_tap_driver()
return
1
return
1
fi
fi
local
CSCRIPT
=
$(
which cscript.exe
)
original_connections
=
$(
echo
$(
get_all_connections
))
if
[[
!
-x
$CSCRIPT
]]
;
then
echo
"Error: no cscript.exe found"
return
1
fi
if
!
[[
-f
$CHECKSCRIPT
]]
;
then
cat
<<
EOF
>
$CHECKSCRIPT
Set oShell = CreateObject("WScript.Shell")
Do
If oShell.AppActivate("Hardware Installation") Then
WScript.Sleep 1000
oShell.SendKeys "%C"
WScript.Sleep 2000
End If
WScript.Sleep 1000
Loop While True
EOF
fi
# install driver
$CSCRIPT
$CHECKSCRIPT
>
/dev/null &
local
sid
=
$!
$DEVCON
install
$DEVFILE
$HWID
$DEVCON
install
$DEVFILE
$HWID
kill
$sid
# rename the connection name
# rename the connection name
if
[[
!
"
$1
"
==
""
]]
;
then
if
[[
!
"
$1
"
==
""
]]
;
then
OLDNAME
=
$(
get_new_connection
$original_connections
)
if
[[
!
-f
$GETSCRIPT
]]
;
then
if
[[
-n
$OLDNAME
]]
;
then
cat
<<
EOF
>
$GETSCRIPT
strComputer = "."
strPrefix = "Local Area Connection"
Set objWMIService = GetObject("winmgmts:
\\\\
" & strComputer & "
\r
oot
\C
IMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT NetConnectionID FROM Win32_NetworkAdapter WHERE " & _
"NetConnectionID Like '" & strPrefix & "%'", _
"WQL", 48)
strLastConnectionName = ""
i = -1
k = Len(strPrefix)
For Each objItem In colItems
s = Right(objItem.NetConnectionID, Len(objItem.NetConnectionID) - k)
If s = "" Then
j = 0
Else
j = Int(s)
End If
If j > i Then
strLastConnectionName = objItem.NetConnectionID
i = j
End If
Next
WScript.StdOut.Write(strLastConnectionName)
WScript.Quit(0)
EOF
fi
# nodosfilewarning
local
OLDNAME
=
$(
$CSCRIPT
//Nologo
$GETSCRIPT
)
if
((
$?
==
0
))
;
then
netsh interface
set
interface
name
=
"
$OLDNAME
"
newname
=
"
$1
"
netsh interface
set
interface
name
=
"
$OLDNAME
"
newname
=
"
$1
"
else
echo
Failed to get new connection name.
return
1
fi
fi
fi
fi
}
}
...
@@ -430,7 +408,7 @@ function uninstall_tap_driver()
...
@@ -430,7 +408,7 @@ function uninstall_tap_driver()
local
DEVCON
=
$(
which devcon.exe
)
local
DEVCON
=
$(
which devcon.exe
)
local
CSCRIPT
=
$(
which cscript.exe
)
local
CSCRIPT
=
$(
which cscript.exe
)
local
GETSCRIPT
=
$(
cygpath
-m
/etc/slapos/scripts/get_pnpid_connection.vbs
)
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
...
@@ -730,14 +708,14 @@ elif [[ $object == "route" ]] ; then
...
@@ -730,14 +708,14 @@ elif [[ $object == "route" ]] ; then
if
[[
"
$opt_family
"
==
"ipv4"
||
"
$opt_family
"
==
""
]]
;
then
if
[[
"
$opt_family
"
==
"ipv4"
||
"
$opt_family
"
==
""
]]
;
then
# rtmroute need that the Routing and Remote Access Service is running
# rtmroute need that the Routing and Remote Access Service is running
# ipcmd="netsh routing ip $command rtmroute"
# ipcmd="netsh routing ip $command rtmroute"
# ipcmd="netsh routing ip $command persistentroute"
# ipcmd="netsh routing ip $command persistentroute"
if
[[
$command
==
"list"
]]
;
then
if
[[
$command
==
"list"
]]
;
then
route print
route print
exit
$?
exit
$?
elif
[[
$command
==
"del"
]]
;
then
elif
[[
$command
==
"del"
]]
;
then
command
=
"delete"
command
=
"delete"
fi
fi
address
=
$(
dirname
$prefix
)
address
=
$(
dirname
$prefix
)
mask
=
$(
prefix_to_netmask
$(
basename
$prefix
))
mask
=
$(
prefix_to_netmask
$(
basename
$prefix
))
ipcmd
=
"route
$command
$address
MASK
$mask
$nexthop
"
ipcmd
=
"route
$command
$address
MASK
$mask
$nexthop
"
...
@@ -754,7 +732,7 @@ elif [[ $object == "route" ]] ; then
...
@@ -754,7 +732,7 @@ elif [[ $object == "route" ]] ; then
echo
$orig_cmd
echo
$orig_cmd
echo
"Error: unsupported family
\"
$opt_family
\"
"
echo
"Error: unsupported family
\"
$opt_family
\"
"
exit
1
exit
1
fi
fi
elif
[[
$object
==
"tuntap"
]]
;
then
elif
[[
$object
==
"tuntap"
]]
;
then
echo
$orig_cmd
echo
$orig_cmd
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment