Skip to content

Commit

Permalink
packaging: don't assume /var/lib/alloy exists when running chown (gra…
Browse files Browse the repository at this point in the history
…fana#724)

The /var/lib/alloy directory may not necessarily exist when installing
or upgrading Alloy, which would cause the chown/chmod of the directory
to fail.

Related to grafana/alloy#723, though I haven't been able to reproduce
the specific error that user was seeing.
  • Loading branch information
rfratto authored and hainenber committed May 1, 2024
1 parent 72ad7e4 commit 17a985b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Main (unreleased)
- The log level of `finished node evaluation` log lines has been decreased to
'debug'. (@tpaschalis)

- Update post-installation scripts for DEB/RPM packages to ensure
`/var/lib/alloy` exists before configuring its permissions and ownership.
(@rfratto)

v1.0.0 (2024-04-09)
-------------------

Expand Down
7 changes: 5 additions & 2 deletions packaging/deb/control/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ case "$1" in
usermod -a -G systemd-journal "$ALLOY_USER"
fi

chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy
chmod 770 /var/lib/alloy
if [ ! -d /var/lib/alloy ]; then
mkdir /var/lib/alloy
chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy
chmod 770 /var/lib/alloy
fi

if [ ! -d /var/lib/alloy/data ]; then
mkdir /var/lib/alloy/data
Expand Down
7 changes: 5 additions & 2 deletions packaging/rpm/control/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ if [ "$1" -eq 1 ] ; then

add_to_logging_groups

chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy
chmod 770 /var/lib/alloy
if [ ! -d /var/lib/alloy ]; then
mkdir /var/lib/alloy
chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy
chmod 770 /var/lib/alloy
fi

if [ ! -d /var/lib/alloy/data ]; then
mkdir /var/lib/alloy/data
Expand Down

0 comments on commit 17a985b

Please sign in to comment.