Skip to content

Commit

Permalink
[BACKPORT 2.18][PLAT-12610] Fixing scripts for cron ubuntu
Browse files Browse the repository at this point in the history
Summary:
Original commit: c095598 / D37141
On ubuntu cronjobs it appears the $USER variable is not set so the scripts we execute like zip_purge_logs or clean_cores might not work. This diff adds sensible default of whoami output.

Test Plan: add patch to ubuntu cron, ensure $USER errors go away

Reviewers: svarshney, amalyshev

Reviewed By: svarshney

Subscribers: yugaware

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37224
  • Loading branch information
mchiddy committed Aug 16, 2024
1 parent 6a198b8 commit 13c5ca5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ while [[ $# -gt 0 ]]; do
shift
done

USER=${USER:-$(whoami)}
if [[ "$(id -u)" != "0" && "$USER" != "yugabyte" ]]; then
echo "This script must be run as root or yugabyte"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set -euo pipefail
collect_metrics_script=({{ yb_home_dir }}/bin/collect_metrics.sh)
filename=({{ yb_metrics_dir }}/node_metrics.prom)

USER=${USER:-$(whoami)}
if [[ "$(id -u)" != "0" && "$USER" != "yugabyte" ]]; then
echo "This script must be run as root or yugabyte"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ while [[ $# -gt 0 ]]; do
shift
done

USER=${USER:-$(whoami)}
if [[ "$(id -u)" != "0" && "$USER" != "yugabyte" ]]; then
echo "This script must be run as root or yugabyte" >&2
exit 1
Expand Down

0 comments on commit 13c5ca5

Please sign in to comment.