Skip to content

Commit 2644dac

Browse files
committed
improve messages
1 parent ba22c8a commit 2644dac

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

src/splunkconf-prepare-es-from-s3.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,55 @@
2727
# 20240914 fix message output
2828
# 20241003 update output message to ease copy/paste for next steps
2929
# 20241020 improve messages
30+
# 20241203 improve messages
3031

31-
VERSION="20241020a"
32+
VERSION="20241203a"
3233

3334
ESAPP="splunk-enterprise-security_732.spl"
3435
ESCU="splunk-es-content-update_4330.tgz"
3536

36-
echo "This $0 script update ES file from S3. It will try to update installes.sh script and download ES version and content update."
37-
echo "You are currently running with script version=$VERSION"
38-
echo "This version default to ES=$ESAPP and ESCU=$ESCU"
39-
echo "You may provide custom versions by launching either $0 ESAPP or $0 ESAPP ESCUAPP"
37+
echo "This $0 script download/update ES files from S3 in order to prepare for ES installation/upgrade. It will try to update installes.sh script and download ES version and content update."
38+
#echo "You are currently running with script $0 version=$VERSION"
4039

4140
# check that we are not launched
4241
if [[ $EUID -eq 0 ]]; then
4342
echo "KO: Exiting ! This script $0 need to be run as splunk !"
4443
exit 1
4544
fi
4645

46+
###### start
47+
48+
# %u is day of week , we may use this for custom purge
49+
TODAY=`date '+%Y%m%d-%H:%M_%u'`;
50+
ID=`date '+%s'`;
51+
FAIL=0;
52+
4753
NBARG=$#
4854
ARG1=$1
4955
ARG2=$2
5056

57+
ESINSTALL="./installes.sh"
5158
if [ $NBARG -eq 0 ]; then
5259
echo "no arg, using default"
60+
echo "This version default to ES=$ESAPP and ESCU=$ESCU"
61+
echo "You may provide custom versions by launching either $0 ESAPP or $0 ESAPP ESCUAPP"
5362
elif [ $NBARG -eq 1 ]; then
5463
ESAPP=$ARG1
64+
ESINSTALL="./installes.sh $ESAPP"
65+
echo "This version default to ESCU=$ESCU"
5566
elif [ $NBARG -eq 2 ]; then
5667
ESAPP=$ARG1
5768
ESCU=$ARG2
69+
ESINSTALL="./installes.sh $ESAPP $ESCU"
5870
else
5971
#elif [ $NBARG -gt 1 ]; then
6072
echo "ERROR: Your command line contains too many ($#) arguments. Ignoring the extra data"
6173
ESAPP=$ARG1
6274
ESCU=$ARG2
75+
ESINSTALL="./installes.sh $ESAPP $ESCU"
6376
fi
6477
echo "INFO: running $0 version=$VERSION with ESAPP=$ESAPP and ESCU=$ESCU (ESCU is optional)"
6578

66-
67-
6879
# setting up token (IMDSv2)
6980
TOKEN=`curl --silent --show-error -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 900"`
7081
# lets get the splunks3splunkinstall from instance tags
@@ -80,6 +91,7 @@ mkdir -p $localappsinstalldir
8091

8192
if [ -z "$splunks3installbucket" ]; then
8293
echo "KO: ATTENTION TAGS NOT SET in instance tags, please correct and relaunch"
94+
((FAIL++))
8395
exit 1
8496
else
8597
echo "OK: Good ! Tags present and set : splunks3installbucket=$splunks3installbucket"
@@ -95,6 +107,7 @@ if [ -e "$localinstalldir/installes.sh" ]; then
95107
echo "OK: installes.sh present $VERINSTES"
96108
else
97109
echo "KO: installes.sh is NOT present in s3 install at $remoteinstalldir: Please upload scripts to s3 install"
110+
((FAIL++))
98111
fi
99112

100113

@@ -103,6 +116,7 @@ if [ -e "$localappsinstalldir/$ESAPP" ]; then
103116
echo "OK: ES install file $ESAPP present at $remoteappsdir and downloaded to $localappsinstalldir for installes.sh later use"
104117
else
105118
echo "KO: ES install file $ESAPP is NOT present in s3 install at $remoteappsdir: Please upload correct ES app version to s3 install or update this script is you want to use a different version"
119+
((FAIL++))
106120
fi
107121

108122

@@ -111,7 +125,17 @@ if [ -e "$localappsinstalldir/$ESCU" ]; then
111125
echo "OK: ES Content update install file $ESCU present at $remoteappsdir and downloaded to $localappsinstalldir for installes.sh later use"
112126
else
113127
echo "KO: ES Content update file $ESCU is NOT present in s3 install at $remoteappsdir : Please upload correct version to s3 install or update this script to a different version. You may ignore this is if you prefer to install/upgrade ES content update from Splunk"
128+
# not a real fail
129+
#((FAIL++))
114130
fi
115131

116-
echo "INFO: end of script, if everything is ok please run as user splunk ./installes.sh $ESAPP from /opt/splunk/scripts directory (sh only) or just ./installes.sh if using the default version from install script"
132+
if [ $FAIL -gt 0 ]; then
133+
echo "There were ${FAIL} fail condition(s) detected, please review messages, fix and rerun script before proceeding to installation step. If you are really sure, you may still continue with esinstall steps by running ${ESINSTALL} !"
134+
PROCEED="N"
135+
#exit 1
136+
else
137+
echo "OK: all looks good to continue to next step"
138+
PROCEED="Y"
139+
echo "INFO: please run as user splunk ${ESINSTALL} from /opt/splunk/scripts directory (sh only) to install/upgrade ES and run es setup"
140+
fi
117141

0 commit comments

Comments
 (0)