-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqt-install-repoforge
executable file
·110 lines (89 loc) · 3.05 KB
/
qt-install-repoforge
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
#!/bin/bash
# Copyright (C) 2009-2013 Eric Shubert <[email protected]>
#
# script to install/upgrade repoforge repository for a QMailToaster host
######################################################################
# Change Log
# 11/24/13 shubes - tailored for new QMailToaster scripts
# 9/23/13 shubes - modified for Centos 6, changed i386 to i686
# 4/02/12 shubes - modified for new repoforge.org changes
# 5/27/11 shubes - leave rpmforge repo enabled, since it's safe now
# 7/29/10 shubes - modified for changed url and spec format
# 8/28/08 written by Eric 'shubes' <[email protected]>
######################################################################
######################################################################
# Figure out which version/release is the latest available
#
a2_determine_current_version(){
echo "$me $myver - getting version of the latest $PKGNAME ..."
SPECFILE=https://raw.github.com/repoforge/rpms/master/specs/$PKGNAME/$PKGNAME.spec
wget -q -O $tempfile $SPECFILE
if [ $? != "0" ]; then
echo "$me - $SPECFILE not found, please try again later."
exit 1
fi
verstring=$(grep --max-count=1 "^Version: " $tempfile)
version=${verstring#Version: }
relstring=$(grep --max-count=1 "^Release: " $tempfile)
relstring=${relstring#Release: }
release=${relstring%\%\{?dist\}}
}
######################################################################
# Install the rpmforge-release package 'manually'
#
a5_install_repoforge(){
b54_check_whatami
# we need to put the rpm in a tempfile in case of web redirection
wget -O $tempfile "http://pkgs.repoforge.org/rpmforge-release/$PKGNAME-$version-$release.el${OSVER%.*}.rf.$QTARCH.rpm"
rpm -ivh $tempfile
rc=$?
if [ "$rc" != "0" ]; then
echo "$me - install failed, rc=$rc. Exiting."
exit 1
fi
echo "$me - installation complete"
}
######################################################################
# Check to see which distro and arch to install
#
b54_check_whatami(){
. qt-whatami -s
rc=$?
if [ "$rc" != "0" ]; then
echo "$me - your distro/version is not supported by QMailToaster, exiting."
qt-whatami
exit 1
else
if [ "$DISTRO" != "CentOS" ]; then
echo "$me - your distro/version is not supported by Repoforge, exiting."
qt-whatami
exit 1
fi
fi
}
######################################################################
# main routine begins here
#
me=${0##*/}
myver=v1.0
PKGNAME=rpmforge-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
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
if [ $rc == "0" ]; then
echo "$me - $installed_pkg is installed, upgrading to $version-$release"
yum -y update rpmforge-release
else
echo "$me - $PKGNAME not installed, installing ..."
a5_install_repoforge
fi
fi
exit 0