Skip to content

Commit bb6e278

Browse files
authored
Changing etc backup directory so its not tied to SPLUNK_HOME (#410)
* Changing etc backup directory so its not tied to SPLUNK_HOME * Applying fix for uf as well
1 parent ab38cb7 commit bb6e278

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

splunk/common-files/updateetc.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright 2018 Splunk
3+
# Copyright 2018-2020 Splunk
44

55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -15,15 +15,17 @@
1515
# limitations under the License.
1616
#
1717

18-
if [[ -f "${SPLUNK_HOME}-etc/splunk.version" ]]; then
19-
IMAGE_VERSION_SHA=`cat ${SPLUNK_HOME}-etc/splunk.version | sha512sum`
18+
SPLUNK_ETC_BAK="${SPLUNK_ETC_BAK:-/opt/splunk-etc}"
19+
20+
if [[ -f "${SPLUNK_ETC_BAK}/splunk.version" ]]; then
21+
IMAGE_VERSION_SHA=`cat ${SPLUNK_ETC_BAK}/splunk.version | sha512sum`
2022

2123
if [[ -f "${SPLUNK_HOME}/etc/splunk.version" ]]; then
2224
ETC_VERSION_SHA=`cat ${SPLUNK_HOME}/etc/splunk.version | sha512sum`
2325
fi
2426

2527
if [[ "x${IMAGE_VERSION_SHA}" != "x${ETC_VERSION_SHA}" ]]; then
2628
echo Updating ${SPLUNK_HOME}/etc
27-
(cd ${SPLUNK_HOME}-etc; tar cf - *) | (cd ${SPLUNK_HOME}/etc; tar xf -)
29+
(cd ${SPLUNK_ETC_BAK}; tar cf - *) | (cd ${SPLUNK_HOME}/etc; tar xf -)
2830
fi
2931
fi

uf/common-files/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ENV SPLUNK_HOME=/opt/splunkforwarder \
4747
SPLUNK_USER=splunk
4848

4949
# Simple script used to populate/upgrade splunk/etc directory
50-
COPY [ "splunk/common-files/updateetc.sh", "/sbin/"]
50+
COPY [ "uf/common-files/updateetc.sh", "/sbin/"]
5151

5252
# Setup users and groups
5353
RUN groupadd -r -g ${GID} ${SPLUNK_GROUP} \

uf/common-files/updateetc.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018-2020 Splunk
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
SPLUNK_ETC_BAK="${SPLUNK_ETC_BAK:-/opt/splunkforwarder-etc}"
19+
20+
if [[ -f "${SPLUNK_ETC_BAK}/splunk.version" ]]; then
21+
IMAGE_VERSION_SHA=`cat ${SPLUNK_ETC_BAK}/splunk.version | sha512sum`
22+
23+
if [[ -f "${SPLUNK_HOME}/etc/splunk.version" ]]; then
24+
ETC_VERSION_SHA=`cat ${SPLUNK_HOME}/etc/splunk.version | sha512sum`
25+
fi
26+
27+
if [[ "x${IMAGE_VERSION_SHA}" != "x${ETC_VERSION_SHA}" ]]; then
28+
echo Updating ${SPLUNK_HOME}/etc
29+
(cd ${SPLUNK_ETC_BAK}; tar cf - *) | (cd ${SPLUNK_HOME}/etc; tar xf -)
30+
fi
31+
fi

0 commit comments

Comments
 (0)