This repository has been archived by the owner on Sep 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 180
/
upgrade_libreswan.sh
79 lines (64 loc) · 1.95 KB
/
upgrade_libreswan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
# Simple LibreSwan Upgrade Script
#
# Copyright (C) 2015 Edwin Ang <[email protected]>
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
if [ `id -u` -ne 0 ]
then
echo "Please start this script with root privileges!"
echo "Try again with sudo."
exit 0
fi
ipsec --version | grep "Libreswan 3.17" > /dev/null
if [ "$?" = "0" ]
then
echo "You already have LibreSwan 3.17 installed!"
echo "Do you wish to continue anyway?"
while true; do
read -p "" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
* ) echo "Please answer with Yes or No [y|n].";;
esac
done
echo ""
fi
echo "This script will build and install LibreSwan 3.17 on your server."
echo "This is intended for users who have already installed a VPN server but have LibreSwan of version < 3.17 installed."
echo "Do you wish to continue?"
while true; do
read -p "" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
* ) echo "Please answer with Yes or No [y|n].";;
esac
done
echo ""
echo "Updating apt-get and installing new dependencies needed to build LibreSwan 3.17..."
apt-get update > /dev/null
apt-get install libevent-dev xmlto -y > /dev/null
mkdir -p /opt/src
cd /opt/src
echo "Downloading LibreSwan's source..."
wget -qO- https://download.libreswan.org/libreswan-3.17.tar.gz | tar xvz > /dev/null
cd libreswan-3.17
echo "Compiling LibreSwan..."
make programs > /dev/null
echo "Installing LibreSwan..."
make install > /dev/null
ipsec --version | grep "Libreswan 3.17" > /dev/null
if [ "$?" = "0" ]
then
echo "LibreSwan 3.17 was installed successfully!"
# this script is for users with an existing installation, so they most probably will not have the ipsec-assist service installed.
service xl2tpd restart
service ipsec restart
exit 0
fi
echo "LibreSwan 3.17 was not installed successfully :/"
echo "Exiting script."
exit 0