Skip to content

Commit 86d1d01

Browse files
authored
chore(operations): Add sudo when installing via dpkg or rpm (#999)
Signed-off-by: Ben Johnson <[email protected]>
1 parent 5a4d50b commit 86d1d01

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

distribution/install.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ install_from_deb() {
233233
printf " ✓\n"
234234

235235
printf "$_prompt Installing Vector via dpkg..."
236-
ensure dpkg -i $_file
236+
ensure_with_sudo dpkg -i $_file
237237

238238
printf "$_prompt Install succeeded! 🚀\n"
239239
printf "$_prompt To start Vector:\n"
@@ -273,7 +273,7 @@ install_from_rpm() {
273273
printf " ✓\n"
274274

275275
printf "$_prompt Installing Vector via rpm..."
276-
ensure rpm -i $_file
276+
ensure_with_sudo rpm -i $_file
277277

278278
printf "$_prompt Install succeeded! 🚀\n"
279279
printf "$_prompt To start Vector:\n"
@@ -521,6 +521,14 @@ ensure() {
521521
fi
522522
}
523523

524+
ensure_with_sudo() {
525+
if ! [ -x "$(command -v sudo)" ]; then
526+
ensure $@
527+
else
528+
ensure sudo $@
529+
fi
530+
}
531+
524532
# This is just for indicating that commands' results are being
525533
# intentionally ignored. Usually, because it's being executed
526534
# as part of error handling.

0 commit comments

Comments
 (0)