You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/splunkconf-prepare-es-from-s3.sh
+32-8Lines changed: 32 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -27,44 +27,55 @@
27
27
# 20240914 fix message output
28
28
# 20241003 update output message to ease copy/paste for next steps
29
29
# 20241020 improve messages
30
+
# 20241203 improve messages
30
31
31
-
VERSION="20241020a"
32
+
VERSION="20241203a"
32
33
33
34
ESAPP="splunk-enterprise-security_732.spl"
34
35
ESCU="splunk-es-content-update_4330.tgz"
35
36
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"
40
39
41
40
# check that we are not launched
42
41
if [[ $EUID-eq 0 ]];then
43
42
echo"KO: Exiting ! This script $0 need to be run as splunk !"
44
43
exit 1
45
44
fi
46
45
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
+
47
53
NBARG=$#
48
54
ARG1=$1
49
55
ARG2=$2
50
56
57
+
ESINSTALL="./installes.sh"
51
58
if [ $NBARG-eq 0 ];then
52
59
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"
53
62
elif [ $NBARG-eq 1 ];then
54
63
ESAPP=$ARG1
64
+
ESINSTALL="./installes.sh $ESAPP"
65
+
echo"This version default to ESCU=$ESCU"
55
66
elif [ $NBARG-eq 2 ];then
56
67
ESAPP=$ARG1
57
68
ESCU=$ARG2
69
+
ESINSTALL="./installes.sh $ESAPP$ESCU"
58
70
else
59
71
#elif [ $NBARG -gt 1 ]; then
60
72
echo"ERROR: Your command line contains too many ($#) arguments. Ignoring the extra data"
61
73
ESAPP=$ARG1
62
74
ESCU=$ARG2
75
+
ESINSTALL="./installes.sh $ESAPP$ESCU"
63
76
fi
64
77
echo"INFO: running $0 version=$VERSION with ESAPP=$ESAPP and ESCU=$ESCU (ESCU is optional)"
65
78
66
-
67
-
68
79
# setting up token (IMDSv2)
69
80
TOKEN=`curl --silent --show-error -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 900"`
70
81
# lets get the splunks3splunkinstall from instance tags
@@ -80,6 +91,7 @@ mkdir -p $localappsinstalldir
80
91
81
92
if [ -z"$splunks3installbucket" ];then
82
93
echo"KO: ATTENTION TAGS NOT SET in instance tags, please correct and relaunch"
94
+
((FAIL++))
83
95
exit 1
84
96
else
85
97
echo"OK: Good ! Tags present and set : splunks3installbucket=$splunks3installbucket"
@@ -95,6 +107,7 @@ if [ -e "$localinstalldir/installes.sh" ]; then
95
107
echo"OK: installes.sh present $VERINSTES"
96
108
else
97
109
echo"KO: installes.sh is NOT present in s3 install at $remoteinstalldir: Please upload scripts to s3 install"
110
+
((FAIL++))
98
111
fi
99
112
100
113
@@ -103,6 +116,7 @@ if [ -e "$localappsinstalldir/$ESAPP" ]; then
103
116
echo"OK: ES install file $ESAPP present at $remoteappsdir and downloaded to $localappsinstalldir for installes.sh later use"
104
117
else
105
118
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++))
106
120
fi
107
121
108
122
@@ -111,7 +125,17 @@ if [ -e "$localappsinstalldir/$ESCU" ]; then
111
125
echo"OK: ES Content update install file $ESCU present at $remoteappsdir and downloaded to $localappsinstalldir for installes.sh later use"
112
126
else
113
127
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++))
114
130
fi
115
131
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"
0 commit comments