Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
S1OVS
openvpn-server
Commits
47f8dd80
Commit
47f8dd80
authored
Jan 13, 2016
by
Matthew Smith
Browse files
Fix bugs in make-static-ip
parent
43d97337
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/make-static-ip
View file @
47f8dd80
...
...
@@ -11,8 +11,7 @@ COMMONNAME=$1
.
/etc/openvpn-server/config.sh
CCDDIR
=
/etc/openvpn/ccd/
#SHOREWALLVARS=/etc/shorewall/openvpn.vars
SHOREWALLVARS
=
/tmp/openvpn.vars
SHOREWALLVARS
=
/etc/shorewall/openvpn.vars
IPPREFIX
=
`
cat
/etc/openvpn/
$OVPN_ORGNICK
-server
.conf |grep
'server '
|cut
-f2
-d
' '
|cut
-f1
,2,3
-d
.
`
.
IP
=
`
cat
/etc/openvpn/
$OVPN_ORGNICK
-server
.conf |
grep
'^server '
|
cut
-f2
-d
' '
`
...
...
@@ -44,16 +43,15 @@ function prompt_restart_shorewall () {
}
function
get_new_ip
()
{
local
newip
=
local
newip
=
""
local
s_ip
=
$1
local
s_subnet
=
$2
# TODO: Make sure calc-ip-range.sh is set correctly before building
for
i
in
`
/usr/share/openvpn-server/calc-ip-range.sh
-i
$s_ip
-s
$s_subnet
|
sed
-n
"6~4p"
`
;
do
if
!
grep
"
$i
"
"
$CCDDIR
/*"
;
then
newip
=
"
$i
"
;
break
;
fi
if
[
`
grep
"ifconfig-push
"
$CCDDIR
*
|
grep
"
$i
"
|
wc
-l
`
-eq
0
]
;
then
local
newip
=
"
$i
"
;
break
;
fi
done
...
...
@@ -81,23 +79,23 @@ function get_new_ip() {
# [241,242] [245,246] [249,250] [253,254]
#
new
ip
=
$(
get_new_ip
$IP
$SUBNET
)
;
ip
=
$(
get_new_ip
$IP
$SUBNET
)
;
if
[
-x
$
new
ip
]
;
then
if
[
-x
$ip
]
;
then
echo
"we appear to have run out of ip's, fix it"
echo
"then run
\$
$0
$COMMONNAME
"
else
IFS
=
'.'
read
-ra
ipnums
<<<
$
new
ip
IFS
=
'.'
read
-ra
ipnums
<<<
$ip
((
ipnums[3]++
))
newgw
=
$(
echo
${
ipnums
[*]
}
|
sed
"s/ /
\.
/g"
)
echo
"your new ip will be
$
new
ip
"
echo
"your new ip will be
$ip
"
echo
"your new gateway will be
$newgw
"
echo
"writing new ccd for you"
echo
ifconfig-push
$
new
ip
$newgw
>
$CCDDIR
/
$COMMONNAME
echo
ifconfig-push
$ip
$newgw
>
$CCDDIR$COMMONNAME
echo
"writing new shorewall vars"
grep
"ifconfig-push"
/etc/openvpn/ccd/
*
|
sed
"s/[
\/
|:]/ /g"
|
awk
'{print $4 "=" $6}'
>
$SHOREWALLVARS
prompt_restart_shorewall
echo
"writing new shorewall vars"
grep
"ifconfig-push"
$CCDDIR
*
|
sed
"s/[
\/
|:]/ /g"
|
awk
'{print $4 "=" $6}'
>
$SHOREWALLVARS
prompt_restart_shorewall
fi
...
...
Write
Preview
Supports
Markdown
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