Skip to content

Commit 3ddd945

Browse files
feat: add optional version arg to install scripts (#155)
### Description OB-40308 add optional version arg to install scripts. This will allow our old Host Quickstart app installation instructions to be pinned to an older version as we update the agent. Example usage: ``` PS C:\Users\Administrator\Downloads> .\install.ps1 -version 1.4.0 PS C:\Users\Administrator\Downloads> & 'C:\Program Files\Observe\observe-agent\observe-agent.exe' version Using config file: C:\Program Files\Observe\observe-agent\observe-agent.yaml observe-agent version: 1.4.0 ``` ``` $ bash ./scripts/install_mac.sh --version 1.5.0 Downloading version 1.5.0 from GitHub... # ... $ observe-agent version observe-agent version: 1.5.0 observe-agent config file: /usr/local/observe-agent/observe-agent.yaml ``` ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] Extended the README / documentation, if necessary
1 parent d485009 commit 3ddd945

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

scripts/install.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
param (
22
[Parameter()]
3-
$observe_collection_endpoint,
3+
[String]$version,
44
[Parameter()]
5-
$observe_token
5+
[String]$observe_collection_endpoint,
6+
[Parameter()]
7+
[String]$observe_token
68
)
79

810
$installer_url="https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Windows_x86_64.zip"
11+
if ($PSBoundParameters.ContainsKey('version')){
12+
$installer_url="https://github.com/observeinc/observe-agent/releases/download/v$version/observe-agent_Windows_x86_64.zip"
13+
}
914
$local_installer="C:\temp\observe-agent_Windows_x86_64.zip"
1015
$program_data_filestorage="C:\ProgramData\Observe\observe-agent\filestorage"
1116
$observeagent_install_dir="$env:ProgramFiles\Observe\observe-agent"
@@ -59,7 +64,7 @@ if(-not (Get-Service ObserveAgent -ErrorAction SilentlyContinue)){
5964
StartupType = "Automatic"
6065
Description = "Observe Agent based on OpenTelemetry collector"
6166
}
62-
67+
6368
New-Service @params
6469
Start-Service ObserveAgent
6570
}

scripts/install_linux.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ while [ $# -gt 0 ]; do
3131
--metrics_enabled)
3232
METRICS_ENABLED="$arg"
3333
;;
34+
--version)
35+
AGENT_VERSION="$arg"
36+
;;
37+
--zip_dir)
38+
ZIP_DIR="$arg"
39+
;;
3440
*)
3541
echo "Unknown option: $opt"
3642
exit 1
@@ -54,10 +60,19 @@ fi
5460

5561
# If the zip file is not provided, download the latest release from GitHub.
5662
if [ -z "$ZIP_DIR" ]; then
57-
echo "Downloading latest release from GitHub..."
58-
curl -s -L -o /tmp/observe-agent.tar.gz https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Linux_$(arch).tar.gz
63+
if [ -n "$AGENT_VERSION" ]; then
64+
echo "Downloading version $AGENT_VERSION from GitHub..."
65+
curl -s -L -o /tmp/observe-agent.tar.gz https://github.com/observeinc/observe-agent/releases/download/v$AGENT_VERSION/observe-agent_Linux_$(arch).tar.gz
66+
else
67+
echo "Downloading latest release from GitHub..."
68+
curl -s -L -o /tmp/observe-agent.tar.gz https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Linux_$(arch).tar.gz
69+
fi
5970
ZIP_DIR="/tmp/observe-agent.tar.gz"
6071
else
72+
if [ -n "$AGENT_VERSION" ]; then
73+
echo "Cannot specify both ZIP_DIR ($ZIP_DIR) and AGENT_VERSION ($AGENT_VERSION)"
74+
exit 1
75+
fi
6176
echo "Installing from provided zip file: $ZIP_DIR"
6277
fi
6378

scripts/install_mac.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ while [ $# -gt 0 ]; do
3434
--setup_launch_daemon)
3535
SETUP_LAUNCH_DAEMON="$arg"
3636
;;
37+
--version)
38+
AGENT_VERSION="$arg"
39+
;;
40+
--zip_dir)
41+
ZIP_DIR="$arg"
42+
;;
3743
*)
3844
echo "Unknown option: $opt"
3945
exit 1
@@ -57,10 +63,19 @@ fi
5763

5864
# If the zip file is not provided, download the latest release from GitHub.
5965
if [ -z "$ZIP_DIR" ]; then
60-
echo "Downloading latest release from GitHub..."
61-
curl -s -L -o /tmp/observe-agent.zip https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Darwin_$(arch).zip
66+
if [ -n "$AGENT_VERSION" ]; then
67+
echo "Downloading version $AGENT_VERSION from GitHub..."
68+
curl -s -L -o /tmp/observe-agent.zip https://github.com/observeinc/observe-agent/releases/download/v$AGENT_VERSION/observe-agent_Darwin_$(arch).zip
69+
else
70+
echo "Downloading latest release from GitHub..."
71+
curl -s -L -o /tmp/observe-agent.zip https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Darwin_$(arch).zip
72+
fi
6273
ZIP_DIR="/tmp/observe-agent.zip"
6374
else
75+
if [ -n "$AGENT_VERSION" ]; then
76+
echo "Cannot specify both ZIP_DIR ($ZIP_DIR) and AGENT_VERSION ($AGENT_VERSION)"
77+
exit 1
78+
fi
6479
echo "Installing from provided zip file: $ZIP_DIR"
6580
fi
6681

0 commit comments

Comments
 (0)