@@ -52,6 +52,8 @@ ARG_SHORT_TIMEOUT='m'
5252ARG_LONG_TIMEOUT=' download-timeout'
5353ARG_SHORT_TIMEZONE=' z'
5454ARG_LONG_TIMEZONE=' timezone'
55+ ARG_SHORT_CLOBBER=' C'
56+ ARG_LONG_CLOBBER=' clobber'
5557ARG_SHORT_PACKAGE_PATH=' P'
5658ARG_LONG_PACKAGE_PATH=' package-path'
5759
@@ -68,6 +70,7 @@ readonly ARG_SHORT_REMOTELY_MANAGED ARG_LONG_REMOTELY_MANAGED
6870readonly ARG_SHORT_EPHEMERAL ARG_LONG_EPHEMERAL
6971readonly ARG_SHORT_TIMEOUT ARG_LONG_TIMEOUT
7072readonly ARG_SHORT_TIMEZONE ARG_LONG_TIMEZONE
73+ readonly ARG_SHORT_CLOBBER ARG_LONG_CLOBBER
7174readonly ARG_SHORT_PACKAGE_PATH ARG_LONG_PACKAGE_PATH
7275readonly DEPRECATED_ARG_LONG_TOKEN DEPRECATED_ENV_TOKEN DEPRECATED_ARG_LONG_SKIP_TOKEN
7376
@@ -102,6 +105,7 @@ INSTALL_HOSTMETRICS=false
102105REMOTELY_MANAGED=false
103106EPHEMERAL=false
104107TIMEZONE=" "
108+ CLOBBER=false
105109
106110LAUNCHD_CONFIG=" "
107111LAUNCHD_ENV_KEY=" "
@@ -166,6 +170,7 @@ Supported arguments:
166170 -${ARG_SHORT_EPHEMERAL} , --${ARG_LONG_EPHEMERAL} Delete the collector from Sumo Logic after 12 hours of inactivity.
167171 -${ARG_SHORT_TIMEOUT} , --${ARG_LONG_TIMEOUT} <timeout> Timeout in seconds after which download will fail. Default is ${CURL_MAX_TIME} .
168172 -${ARG_SHORT_TIMEZONE} , --${ARG_LONG_TIMEZONE} TIMEZONE for the collector.
173+ -${ARG_SHORT_CLOBBER} , --${ARG_LONG_CLOBBER} Overwrite existing installation without asking for confirmation.
169174 -${ARG_SHORT_PACKAGE_PATH} , --${ARG_LONG_PACKAGE_PATH} <path> Install package from file path instead of fetching it.
170175 -${ARG_SHORT_YES} , --${ARG_LONG_YES} Disable confirmation asks.
171176
@@ -185,6 +190,7 @@ function set_defaults() {
185190 TOKEN_ENV_FILE=" ${USER_ENV_DIRECTORY} /token.env"
186191 TIMEZONE=" UTC"
187192 PACKAGE_PATH=" "
193+ CLOBBER=" false"
188194
189195 LAUNCHD_CONFIG=" /Library/LaunchDaemons/com.sumologic.otelcol-sumo.plist"
190196 LAUNCHD_ENV_KEY=" EnvironmentVariables"
@@ -263,7 +269,7 @@ function parse_options() {
263269 " --${ARG_LONG_TIMEOUT} " )
264270 set -- " $@ " " -${ARG_SHORT_TIMEOUT} "
265271 ;;
266- " -${ARG_SHORT_TOKEN} " |" -${ARG_SHORT_HELP} " |" -${ARG_SHORT_API} " |" -${ARG_SHORT_OPAMP_API} " |" -${ARG_SHORT_TAG} " |" -${ARG_SHORT_VERSION} " |" -${ARG_SHORT_FIPS} " |" -${ARG_SHORT_YES} " |" -${ARG_SHORT_UNINSTALL} " |" -${ARG_SHORT_UPGRADE} " |" -${ARG_SHORT_PURGE} " |" -${ARG_SHORT_SKIP_TOKEN} " |" -${ARG_SHORT_DOWNLOAD} " |" -${ARG_SHORT_CONFIG_BRANCH} " |" -${ARG_SHORT_BINARY_BRANCH} " |" -${ARG_SHORT_BRANCH} " |" -${ARG_SHORT_KEEP_DOWNLOADS} " |" -${ARG_SHORT_TIMEOUT} " |" -${ARG_SHORT_INSTALL_HOSTMETRICS} " |" -${ARG_SHORT_REMOTELY_MANAGED} " |" -${ARG_SHORT_EPHEMERAL} " |" -${ARG_SHORT_TIMEZONE} " |" -${ARG_SHORT_PACKAGE_PATH} " )
272+ " -${ARG_SHORT_TOKEN} " |" -${ARG_SHORT_HELP} " |" -${ARG_SHORT_API} " |" -${ARG_SHORT_OPAMP_API} " |" -${ARG_SHORT_TAG} " |" -${ARG_SHORT_VERSION} " |" -${ARG_SHORT_FIPS} " |" -${ARG_SHORT_YES} " |" -${ARG_SHORT_UNINSTALL} " |" -${ARG_SHORT_UPGRADE} " |" -${ARG_SHORT_PURGE} " |" -${ARG_SHORT_SKIP_TOKEN} " |" -${ARG_SHORT_DOWNLOAD} " |" -${ARG_SHORT_CONFIG_BRANCH} " |" -${ARG_SHORT_BINARY_BRANCH} " |" -${ARG_SHORT_BRANCH} " |" -${ARG_SHORT_KEEP_DOWNLOADS} " |" -${ARG_SHORT_TIMEOUT} " |" -${ARG_SHORT_INSTALL_HOSTMETRICS} " |" -${ARG_SHORT_REMOTELY_MANAGED} " |" -${ARG_SHORT_EPHEMERAL} " |" -${ARG_SHORT_TIMEZONE} " |" -${ARG_SHORT_CLOBBER} " | " - ${ ARG_SHORT_PACKAGE_PATH}" )
267273 set -- " $@ " " ${arg} "
268274 ;;
269275 " --${ARG_LONG_INSTALL_HOSTMETRICS} " )
@@ -278,6 +284,9 @@ function parse_options() {
278284 " --${ARG_LONG_TIMEZONE} " )
279285 set -- " $@ " " -${ARG_SHORT_TIMEZONE} "
280286 ;;
287+ " --${ARG_LONG_CLOBBER} " )
288+ set -- " $@ " " -${ARG_SHORT_CLOBBER} "
289+ ;;
281290 " --${ARG_LONG_PACKAGE_PATH} " )
282291 set -- " $@ " " -${ARG_SHORT_PACKAGE_PATH} "
283292 ;;
@@ -293,7 +302,7 @@ function parse_options() {
293302
294303 while true ; do
295304 set +e
296- getopts " ${ARG_SHORT_HELP}${ARG_SHORT_TOKEN} :${ARG_SHORT_API} :${ARG_SHORT_OPAMP_API} :${ARG_SHORT_TAG} :${ARG_SHORT_VERSION} :${ARG_SHORT_FIPS}${ARG_SHORT_YES}${ARG_SHORT_UPGRADE}${ARG_SHORT_UNINSTALL}${ARG_SHORT_PURGE}${ARG_SHORT_SKIP_TOKEN}${ARG_SHORT_DOWNLOAD}${ARG_SHORT_KEEP_DOWNLOADS}${ARG_SHORT_CONFIG_BRANCH} :${ARG_SHORT_BINARY_BRANCH} :${ARG_SHORT_BRANCH} :${ARG_SHORT_EPHEMERAL}${ARG_SHORT_TIMEZONE} :${ARG_SHORT_REMOTELY_MANAGED}${ARG_SHORT_INSTALL_HOSTMETRICS}${ARG_SHORT_TIMEOUT} :${ARG_SHORT_PACKAGE_PATH} :" opt
305+ getopts " ${ARG_SHORT_HELP}${ARG_SHORT_TOKEN} :${ARG_SHORT_API} :${ARG_SHORT_OPAMP_API} :${ARG_SHORT_TAG} :${ARG_SHORT_VERSION} :${ARG_SHORT_FIPS}${ARG_SHORT_YES}${ARG_SHORT_UPGRADE}${ARG_SHORT_UNINSTALL}${ARG_SHORT_PURGE}${ARG_SHORT_SKIP_TOKEN}${ARG_SHORT_DOWNLOAD}${ARG_SHORT_KEEP_DOWNLOADS}${ARG_SHORT_CONFIG_BRANCH} :${ARG_SHORT_BINARY_BRANCH} :${ARG_SHORT_BRANCH} :${ARG_SHORT_EPHEMERAL}${ARG_SHORT_TIMEZONE} :${ARG_SHORT_CLOBBER}${ ARG_SHORT_REMOTELY_MANAGED}${ARG_SHORT_INSTALL_HOSTMETRICS}${ARG_SHORT_TIMEOUT} :${ARG_SHORT_PACKAGE_PATH} :" opt
297306 set -e
298307
299308 # Invalid argument catched, print and exit
@@ -329,6 +338,7 @@ function parse_options() {
329338 " ${ARG_SHORT_REMOTELY_MANAGED} " ) REMOTELY_MANAGED=true ;;
330339 " ${ARG_SHORT_EPHEMERAL} " ) EPHEMERAL=true ;;
331340 " ${ARG_SHORT_TIMEZONE} " ) TIMEZONE=" ${OPTARG} " ;;
341+ " ${ARG_SHORT_CLOBBER} " ) CLOBBER=true ;;
332342 " ${ARG_SHORT_KEEP_DOWNLOADS} " ) KEEP_DOWNLOADS=true ;;
333343 " ${ARG_SHORT_TIMEOUT} " ) CURL_MAX_TIME=" ${OPTARG} " ;;
334344 " ${ARG_SHORT_TAG} " ) FIELDS+=(" ${OPTARG} " ) ;;
@@ -499,6 +509,10 @@ function setup_config() {
499509 write_timezone " ${TIMEZONE} "
500510 fi
501511
512+ if [[ " ${CLOBBER} " == " true" ]]; then
513+ write_clobber_true
514+ fi
515+
502516 # Return/stop function execution early as remaining logic only applies
503517 # to locally-managed installations
504518 return
@@ -532,6 +546,11 @@ function setup_config() {
532546 if [[ -n " ${TIMEZONE} " ]]; then
533547 write_timezone " ${TIMEZONE} "
534548 fi
549+
550+ if [[ " ${CLOBBER} " == " true" ]]; then
551+ write_clobber_true
552+ fi
553+
535554 fi
536555}
537556
@@ -555,6 +574,10 @@ function setup_config_darwin() {
555574 write_timezone " ${TIMEZONE} "
556575 fi
557576
577+ if [[ " ${CLOBBER} " == " true" ]]; then
578+ write_clobber_true
579+ fi
580+
558581 if [[ -n " ${API_BASE_URL} " ]]; then
559582 write_api_url " ${API_BASE_URL} "
560583 elif [[ -n " ${USER_API_URL} " ]]; then
@@ -781,6 +804,10 @@ function write_timezone() {
781804 " ${SUMO_CONFIG_BINARY_PATH} " --set-timezone " $timezone "
782805}
783806
807+ function write_clobber_true() {
808+ " ${SUMO_CONFIG_BINARY_PATH} " --enable-clobber
809+ }
810+
784811# write api_url to user configuration file
785812function write_api_url() {
786813 local api_url
0 commit comments