-
Notifications
You must be signed in to change notification settings - Fork 1
/
qt-install-epel
executable file
·119 lines (97 loc) · 2.89 KB
/
qt-install-epel
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Copyright (C) 2014 Eric Shubert <[email protected]>
#
# script to install/upgrade epel repository for a QMailToaster host
######################################################################
# Change Log
# 02/06/14 shubes - created (from qt-install-repoforge)
######################################################################
######################################################################
# Check to see which distro and arch to install
#
a1_check_whatami(){
. qt-whatami -s
rc=$?
if [ "$rc" != "0" ]; then
qt-whatami
echo "$me - your distro/version is not supported by QMailToaster, exiting."
exit 1
else
if [ "$DISTRO" != "CentOS" ]; then
qt-whatami
echo "$me - your distro is not supported by epel, exiting."
exit 1
fi
fi
}
######################################################################
# Figure out which version/release is the latest available
#
a2_determine_current_version(){
echo "$me $myver - getting version of the latest $PKGNAME ..."
epelurl=dl.fedoraproject.org/pub/epel/${OSVER%.*}/$(uname -i)
html_line=$(curl http://$epelurl/ 2>/dev/null | grep $PKGNAME)
if [ $? != "0" ]; then
echo "$me - $PKGNAME not found at $epelurl/."
exit 1
fi
pkgfile=${html_line#*\"}
pkgfile=${pkgfile%\"*}
tempname=${pkgfile%%.*}
release=${tempname##*-}
tempname=${tempname%-$release}
version=${tempname##*-}
}
######################################################################
# Install or update epel-release package
#
a5_install_update(){
if [ $rc == "0" ]; then
echo "$me - $installed_pkg is installed, upgrading to $version-$release"
yum -y update $PKGNAME
else
echo "$me - $PKGNAME not installed, installing ..."
b55_install_pkg
fi
epelfile=/etc/yum.repos.d/epel.repo
incl_clause="includepkgs=pdns-recursor"
grep -q ^$incl_clause $epelfile
if [ "$?" != "0" ]; then
sed -i "/enabled=1/a $incl_clause" $epelfile
fi
echo "$me - upgrade complete"
}
######################################################################
# Install the epel-release package 'manually'
#
b55_install_pkg(){
# we need to put the rpm in a tempfile in case of web redirection
curl http://$epelurl/$pkgfile 2>/dev/null >$tempfile
rpm -ivh $tempfile
rc=$?
if [ "$rc" != "0" ]; then
echo "$me - install failed, rc=$rc. Exiting."
exit 1
fi
}
######################################################################
# main routine begins here
#
me=${0##*/}
myver=v1.0
PKGNAME=epel-release
# set a temp file for the working scratch. $$ is the current shell ID.
tempfile=$(tempfile 2>/dev/null) || tempfile=/tmp/$me.$$
# make sure the tempfile is deleted when we're done
trap "rm -f $tempfile" 0 1 2 5 15
a1_check_whatami
a2_determine_current_version
installed_pkg=$(rpm -q $PKGNAME)
rc=$?
if [ $rc == "0" ] \
&& [ "${installed_pkg%.*}" == "$PKGNAME-$version-$release" ]; then
echo "$me - installed package $installed_pkg is the latest - nothing done."
else
a5_install_update
fi
exit 0