Skip to content

Commit

Permalink
[NEXMANAGE-872] Fix provision-tc issue in TiberOS
Browse files Browse the repository at this point in the history
The provision-tc cannot run sed command to edit
/etc/dispatcher.environment due to RO filesystem. It also cannot add the
pmsuser group. This PR fixes both issue.

Signed-off-by: yengliong <[email protected]>
  • Loading branch information
yengliong93 committed Oct 15, 2024
1 parent 97a92d2 commit 30d56f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion inbm/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## NEXT - MMMM-DD-YY

### Fixed
- (NEXMANAGE-872) Fix provision-tc issue in TiberOS - cannot overwrite /etc/dispatcher.environment

## 4.2.6 - 2024-10-04
### Added
Expand Down
18 changes: 16 additions & 2 deletions inbm/fpm/mqtt/template/usr/bin/mqtt-provision-start
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#!/bin/bash
set -euxo pipefail

# Retrieve OS Release ID
if [ -f /etc/os-release ]; then
. /etc/os-release
else
echo "/etc/os-release not found. Exiting."
exit 1
fi

# Ensure mqtt-broker has required permissions
getent group pmsuser || groupadd pmsuser
if [ "$ID" != "tiber" ]; then
getent group pmsuser || groupadd pmsuser
else
echo "Skipping adding pmsuser group on 'tiber' OS."
fi
chgrp mqtt-broker /var/persistent-log/mosquitto
chmod g+rwx /var/persistent-log/mosquitto
chmod -R g+rw /var/persistent-log/mosquitto
Expand Down Expand Up @@ -37,7 +50,8 @@ sed -i -e "s/listener .* 127.0.0.1/listener $LOCAL_MQTT_PORT 127.0.0.1/g" /etc/i

# If dispatcher.environment exists, patch its port
if [ -f /etc/dispatcher.environment ]; then
sed -i -e "s/MQTT_PORT=.*/MQTT_PORT=$LOCAL_MQTT_PORT/g" /etc/dispatcher.environment
temp_file=$(mktemp)
sed "s/MQTT_PORT=.*/MQTT_PORT=$LOCAL_MQTT_PORT/g" /etc/dispatcher.environment > "$temp_file" && cat "$temp_file" > /etc/dispatcher.environment
fi


Expand Down

0 comments on commit 30d56f4

Please sign in to comment.