-
Notifications
You must be signed in to change notification settings - Fork 11
/
om-repo-builder
94 lines (81 loc) · 3.28 KB
/
om-repo-builder
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
#!/usr/bin/sh
# Program: Dell OpenManage Repository Builder
# Author: Matty < matty91 at gmail dot com >
# Current Version: 1.0
# Date: 07-24-2017
# License:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
ADMINS="root"
DELL_OM_DIR="/var/www/repos/dell-openmanage"
RHEL_RELEASES="6 7"
UPGRADING="NO"
VERSION=""
# DSU_VERSION format: DSU_17.06.00
if [ $# -eq 1 ]; then
DSU_VERSION=$1
else
VERSION=`wget -qO- https://linux.dell.com/repo/hardware/latest/ |/usr/bin/awk -F '[) ]+' '/Version/{print $10}'`
if [ $? -ne 0 ]; then
echo "ERROR: Unable to retrieve the OM repo from Dell"
exit 1
fi
if [ "${VERSION}" != "" ]; then
DSU_VERSION="DSU_${VERSION}"
else
echo "ERROR: Unable to retrieve a version number from Dell"
exit 1
fi
fi
if [ ! -d ${DELL_OM_DIR}/${DSU_VERSION} ]; then
UPGRADING="YES"
else
echo "INFO: DSU version ${DSU_VERSION} is already installed"
exit 0
fi
echo "Sucking down OpenManage release ${DSU_VERSION} from Dell"
echo "The new version will be installed in ${DELL_OM_DIR}"
if [ ! -d ${DELL_OM_DIR} ]; then
echo "Creating a Dell OpenManage directory named ${DELL_OM_DIR}"
mkdir ${DELL_OM_DIR}
fi
for release in ${RHEL_RELEASES}; do
echo "Retrieving OM for Enterprise Linux ${release}"
DELL_OM_URL="https://linux.dell.com/repo/hardware/${DSU_VERSION}/os_dependent/RHEL${release}_64/"
wget -q --progress=dot --no-parent -P ${DELL_OM_DIR} -r -l2 -nH --cut-dirs=2 ${DELL_OM_URL}
if [ $? -ne 0 ]; then
echo "ERROR: Unable to retrieve the OM repo from Dell"
exit 1
fi
SRC_DIR="${DELL_OM_DIR}/${DSU_VERSION}/os_dependent/RHEL${release}_64"
DEST_DIR="${DELL_OM_DIR}/${DSU_VERSION}/os_dependent"
if [ -d ${SRC_DIR} ] && [ ! -d ${DEST_DIR}/${release} ]; then
# Rename the directories to overcome a limitation with the
# the yum $releasever variable inside a URL string.
echo "Renaming OM directory ${SRC_DIR} to ${DEST_DIR}"
mv ${SRC_DIR} ${DEST_DIR}/${release}
# Creating a symbolic link for OEL since $releasver is unique
ln -s ${DEST_DIR}/${release} ${DEST_DIR}/${release}Server
else
echo "ERROR: Cannot rename directory"
echo "ERROR: Check to make sure that ${SRC_DIR} exists"
echo "ERROR: and ${DEST_DIR}/{release} does not."
fi
done
if [ "${UPGRADING}" == "YES" ]; then
echo " A new version of Dell OpenManage is available on ${HOSTNAME}
New Version number: ${DSU_VERSION}
To activate this version please point the latest link to the new
version once it has been thoroughly vetted on non-production hardware.
Example:
$ rm -f ${DELL_OM_DIR}/omlatest
$ ln -s ${DELL_OM_DIR}/${DSU_VERSION} ${DELL_OM_DIR}/omlatest" | mail -s "A new version of the Dell Openmanage Linux repo is available on ${HOSTNAME}" ${ADMINS}
fi
(domain-check)