This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpre-install.sh
executable file
·76 lines (61 loc) · 2.08 KB
/
pre-install.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
#!/bin/sh
# check that the actual installer can work, ie. all required perl modules present.
# if not, complain and offer to help.
# note: this assumes that the current dir is the unpacked directory! (true in the .run environment)
if type perl >/dev/null 2>&1; then
if perl -c ./install.pl 2>/dev/null; then
exec ./install.pl "$@";
fi
fi
cat >&2 <<EOF
Error: no Perl or Perl core modules installed!
NMIS (and this installer) require that Perl and the
core Perl modules are present on your system.
On CentOS/RedHat systems you need to install the packages
"perl-core" and "cpan" with:
sudo yum install perl-core cpan
on Debian/Ubuntu the package "perl" is required:
sudo apt-get install perl
Do you want the installer to install Perl for you?
EOF
# check for unattended -y mode
for i in "$@"; do
if [ "$i" = "-y" ]; then
UNATTENDED=1
break;
fi
done
# let's not even ask if -y mode is on
[ -n "$UNATTENDED" ] && DOIT=1 && EXTRA="-y" && DEBIAN_FRONTEND="noninteractive" && echo "Unattended Mode - default answer Y"
export DEBIAN_FRONTEND
# let's accept enter as yes
if [ -z "$UNATTENDED" ] && read -p "Enter y to continue, anything else to abort: " X && [ -z "$X" -o "$X" = 'y' -o "$X" = 'Y' ]; then
DOIT=1;
fi
if [ "$DOIT" = 1 ]; then
if type yum >/dev/null 2>&1; then
if type subscription-manager >/dev/null 2>&1 && egrep -q 'VERSION_ID="7' /etc/os-release 2>/dev/null; then
echo "Enabling RHEL 7 Repositories"
subscription-manager repos --enable rhel-7-server-optional-rpms \
--enable rhel-7-server-supplementary-rpms
fi
echo "Starting yum install"
yum $EXTRA install perl-core
elif type apt-get >/dev/null 2>&1; then
echo "Starting apt-get install"
apt-get $EXTRA install perl
fi
# time to try once more
if type perl >/dev/null 2>&1; then
if perl -c ./install.pl 2>/dev/null; then
exec ./install.pl "$@";
else
echo "Perl is present, but lacking some of the required modules! " >&2
perl -c ./install.pl
exit 1
fi
fi
exit 0
fi
echo "No Perl available, aborting installation." >&2
exit 1