-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharraynetworks-l3vpn-rpmbuild.sh
executable file
·74 lines (60 loc) · 2.42 KB
/
arraynetworks-l3vpn-rpmbuild.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
#!/bin/bash
CURUSER=$(/usr/bin/whoami);
RHELVER=$(/usr/bin/lsb_release -sr);
RHELVER=${RHELVER%.*};
if [ "${CURUSER}" == "root" ] && [ "$1" != "--download" ]; then
/bin/echo "ERROR: RPM's must not be built as the root user for security purposes. Please run the build as a regular user.";
exit 1;
elif [ "$1" == "--download" ] && [ "${CURUSER}" != "root" ]; then
/bin/echo "ERROR: VPN tool download and prep must be run as root...";
exit 1;
fi
if [ "$1" != "--download" ]; then
if [ ${RHELVER} -eq 5 ]; then
/bin/rpm -q buildsys-macros > /dev/null;
if [ $? -ne 0 ]; then
/bin/echo "ERROR: RPM dependency buildsys-macros is not installed. Please install before continuing...";
exit 1;
fi
fi
/bin/rpm -q rpm-build > /dev/null;
if [ $? -ne 0 ]; then
/bin/echo "ERROR: RPM dependency rpm-build is not installed. Please install before continuing...";
exit 1;
fi
if [ -f ~/.rpmmacros ]; then
/bin/rm -f ~/.rpmmacros;
fi
if [ ${RHELVER} -eq 5 ]; then
/bin/echo "%_topdir ${HOME}/rpmbuild" > ~/.rpmmacros;
fi
arraynetworks_l3vpn_version=$(/usr/bin/strings bin/array_vpnc | /bin/grep -e '^VPNC_[[:digit:]]' | /bin/sed 's/^VPNC_//' | /bin/sed 's/_/./g');
if [ -z "${arraynetworks_l3vpn_version}" ]; then
/bin/echo "ERROR: Failed to determine Array Networks L3VPN version..." 1>&2;
exit 1;
fi
/bin/mkdir -p ~/rpmbuild/{BUILD,RPMS,S{OURCES,PECS,RPMS}};
/bin/cp -f *.spec ~/rpmbuild/SPECS/;
/bin/cp -af bin ~/rpmbuild/SOURCES/;
/bin/cp -af man ~/rpmbuild/SOURCES/;
/usr/bin/rpmbuild -ba --define "_arraynetworks_l3vpn_version ${arraynetworks_l3vpn_version}" ~/rpmbuild/SPECS/arraynetworks-l3vpn.spec;
else
if [ ! -d bin ]; then
/bin/mkdir bin;
/bin/chmod 755 bin;
fi
#If this download fails, go to the SoftLayer VPN login page, select the Help link and find the updated download link..."
/usr/bin/wget -q 'https://vpn.dal01.softlayer.com/prx/000/http/speedtest.dal05.networklayer.com/array/ArrayNetworksL3VPN_LINUX.zip' -O ArrayNetworksL3VPN_LINUX.bin;
if [ $? -ne 0 ]; then
/bin/echo "ERROR: Failed to download Array Networks L3VPN..." 1>&2;
exit 1;
fi
/bin/chmod 755 ArrayNetworksL3VPN_LINUX.bin;
./ArrayNetworksL3VPN_LINUX.bin;
/bin/rm -f ArrayNetworksL3VPN_LINUX.bin;
/bin/rm -f test.tar.gz;
/bin/chown root:root array_*;
/bin/chmod 644 array_*;
/bin/rm -f bin/*;
/bin/mv array_* bin/;
fi