Improve Libreswan install
- Skip downloading and installing Libreswan if the same version is already installed.
This commit is contained in:
parent
217bf2a237
commit
df6c02bf95
@ -184,9 +184,16 @@ get_ikev2_script() {
|
||||
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
bigecho "Downloading Libreswan..."
|
||||
check_libreswan() {
|
||||
SWAN_VER=4.5
|
||||
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
|
||||
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
|
||||
[ "$swan_ver_old" = "$SWAN_VER" ]
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Downloading Libreswan..."
|
||||
swan_file="libreswan-$SWAN_VER.tar.gz"
|
||||
swan_url1="https://github.com/libreswan/libreswan/archive/v$SWAN_VER.tar.gz"
|
||||
swan_url2="https://download.libreswan.org/$swan_file"
|
||||
@ -196,9 +203,13 @@ get_libreswan() {
|
||||
) || exit 1
|
||||
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
|
||||
tar xzf "$swan_file" && /bin/rm -f "$swan_file"
|
||||
else
|
||||
bigecho "Libreswan $SWAN_VER is already installed, skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Compiling and installing Libreswan, please wait..."
|
||||
cd "libreswan-$SWAN_VER" || exit 1
|
||||
cat > Makefile.inc.local <<'EOF'
|
||||
@ -223,6 +234,7 @@ EOF
|
||||
if ! /usr/local/sbin/ipsec --version 2>/dev/null | grep -qF "$SWAN_VER"; then
|
||||
exiterr "Libreswan $SWAN_VER failed to build."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
create_vpn_config() {
|
||||
|
@ -238,9 +238,16 @@ get_ikev2_script() {
|
||||
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
bigecho "Downloading Libreswan..."
|
||||
check_libreswan() {
|
||||
SWAN_VER=4.5
|
||||
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
|
||||
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
|
||||
[ "$swan_ver_old" = "$SWAN_VER" ]
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Downloading Libreswan..."
|
||||
swan_file="libreswan-$SWAN_VER.tar.gz"
|
||||
swan_url1="https://github.com/libreswan/libreswan/archive/v$SWAN_VER.tar.gz"
|
||||
swan_url2="https://download.libreswan.org/$swan_file"
|
||||
@ -250,9 +257,13 @@ get_libreswan() {
|
||||
) || exit 1
|
||||
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
|
||||
tar xzf "$swan_file" && /bin/rm -f "$swan_file"
|
||||
else
|
||||
bigecho "Libreswan $SWAN_VER is already installed, skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Compiling and installing Libreswan, please wait..."
|
||||
cd "libreswan-$SWAN_VER" || exit 1
|
||||
cat > Makefile.inc.local <<'EOF'
|
||||
@ -277,6 +288,7 @@ EOF
|
||||
if ! /usr/local/sbin/ipsec --version 2>/dev/null | grep -qF "$SWAN_VER"; then
|
||||
exiterr "Libreswan $SWAN_VER failed to build."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
create_vpn_config() {
|
||||
|
@ -226,9 +226,16 @@ get_ikev2_script() {
|
||||
[ -s ikev2.sh ] && chmod +x ikev2.sh && ln -s /opt/src/ikev2.sh /usr/bin 2>/dev/null
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
bigecho "Downloading Libreswan..."
|
||||
check_libreswan() {
|
||||
SWAN_VER=4.5
|
||||
ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null)
|
||||
swan_ver_old=$(printf '%s' "$ipsec_ver" | sed -e 's/.*Libreswan U\?//' -e 's/\( (\|\/K\).*//')
|
||||
[ "$swan_ver_old" = "$SWAN_VER" ]
|
||||
}
|
||||
|
||||
get_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Downloading Libreswan..."
|
||||
swan_file="libreswan-$SWAN_VER.tar.gz"
|
||||
swan_url1="https://github.com/libreswan/libreswan/archive/v$SWAN_VER.tar.gz"
|
||||
swan_url2="https://download.libreswan.org/$swan_file"
|
||||
@ -238,9 +245,13 @@ get_libreswan() {
|
||||
) || exit 1
|
||||
/bin/rm -rf "/opt/src/libreswan-$SWAN_VER"
|
||||
tar xzf "$swan_file" && /bin/rm -f "$swan_file"
|
||||
else
|
||||
bigecho "Libreswan $SWAN_VER is already installed, skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
install_libreswan() {
|
||||
if ! check_libreswan; then
|
||||
bigecho "Compiling and installing Libreswan, please wait..."
|
||||
cd "libreswan-$SWAN_VER" || exit 1
|
||||
cat > Makefile.inc.local <<'EOF'
|
||||
@ -273,6 +284,7 @@ EOF
|
||||
if ! /usr/local/sbin/ipsec --version 2>/dev/null | grep -qF "$SWAN_VER"; then
|
||||
exiterr "Libreswan $SWAN_VER failed to build."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
create_vpn_config() {
|
||||
|
Loading…
Reference in New Issue
Block a user