Skip to content

Commit

Permalink
Merge pull request #1025 from telefonicaid/task/add_config_container_…
Browse files Browse the repository at this point in the history
…flag

update configmap and entrypoint
  • Loading branch information
AlvaroVega authored Apr 29, 2021
2 parents 6748fc9 + 1e64805 commit f333af3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
12 changes: 3 additions & 9 deletions docker/Mosquitto/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ FROM centos:7.9.2009
COPY aclfile /root/
COPY startMosquitto.sh /bin

ENV CONGIF_FROM_ENV true

RUN yum update -y && yum install -y wget \
&& yum install -y epel-release \
&& yum update -y epel-release \
&& yum install -y mosquitto \
&& chmod 755 /bin/startMosquitto.sh \
&& mkdir /var/log/mosquitto \
&& chown mosquitto:mosquitto /var/log/mosquitto \
&& touch /etc/mosquitto/pwfile \
&& sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf \
&& echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf \
&& echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf \
&& echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf \
&& echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf \
&& echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf \
&& echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf \
&& mv /root/aclfile /etc/mosquitto/aclfile \
&& yum clean all


EXPOSE 1883
EXPOSE 9001

Expand Down
14 changes: 13 additions & 1 deletion docker/Mosquitto/startMosquitto.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/usr/bin/env bash

mosquitto_passwd -b /etc/mosquitto/pwfile iota ${IOTA_PASS}
if [ "${CONGIF_FROM_ENV}" = true ] ; then
touch /etc/mosquitto/pwfile
sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf
echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf
echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf
echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf
echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf
echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf
echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf
mv /root/aclfile /etc/mosquitto/aclfile
mosquitto_passwd -b /etc/mosquitto/pwfile iota ${IOTA_PASS}
fi

/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

0 comments on commit f333af3

Please sign in to comment.