@@ -14,6 +14,37 @@ stop_service=${PT_stop_service:-'false'}
1414# shellcheck source=files/common.sh
1515source " ${PT__installdir} /openvox_bootstrap/files/common.sh"
1616
17+ # This function will cause the script to exit if one of the conditions is met
18+ #
19+ # If the requested $version is
20+ # 1. latest and there is already an agent installed
21+ # 2. not latest, but $version matches the agent's version number
22+ skip_if_installed () {
23+ # This logic only applies to the agent package because it enables
24+ # OpenBolt's apply_prep logic to work properly
25+ if [ " $package " == ' openvox-agent' ]; then
26+ # Find agent version, if any
27+ if [ -f /opt/puppetlabs/puppet/VERSION ]; then
28+ installed_version=$( cat /opt/puppetlabs/puppet/VERSION)
29+ elif command -v puppet > /dev/null 2>&1 ; then
30+ installed_version=$( puppet --version)
31+ else
32+ installed_version=none
33+ fi
34+
35+ if [ " $installed_version " != ' none' ]; then
36+ if [ " $version " = ' latest' ]; then
37+ info ' Specific agent version not requested and the agent was detected. Skipping install.'
38+ exit 0
39+ elif [ " $version " = " $installed_version " ]; then
40+ # installed agent version matched specific version requested
41+ info " Requested agent version $version . Found agent version $installed_version . Skipping install."
42+ exit 0
43+ fi
44+ fi
45+ fi
46+ }
47+
1748# Based on platform family set:
1849# repository - the package repository to download from
1950set_repository () {
@@ -65,6 +96,8 @@ install_release_package() {
6596 refresh_package_cache
6697}
6798
99+ # quit early if nothing to do
100+ skip_if_installed
68101# Get platform information
69102set_platform_globals
70103# Set collection release package url based on platform
0 commit comments