Skip to content

Commit 8c2e95b

Browse files
committed
change bash codefence to console
Signed-off-by: Phill Kelley <[email protected]>
1 parent ee992f0 commit 8c2e95b

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

docs/Containers/Mosquitto.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ When you select Mosquitto in the IOTstack menu, the *template service definition
7777

7878
On a first install of IOTstack, you run the menu, choose Mosquitto as one of your containers, and are told to do this:
7979

80-
```bash
80+
```console
8181
$ cd ~/IOTstack
8282
$ docker-compose up -d
8383
```
@@ -145,7 +145,7 @@ The *local image* is instantiated to become your running container.
145145

146146
When you run the `docker images` command after Mosquitto has been built, you *may* see two rows for Mosquitto:
147147

148-
```bash
148+
```console
149149
$ docker images
150150
REPOSITORY TAG IMAGE ID CREATED SIZE
151151
iotstack_mosquitto latest cf0bfe1a34d6 4 weeks ago 11.6MB
@@ -181,7 +181,7 @@ The default versions of each configuration file are the **same**. Only the **loc
181181

182182
However, if you did alter either or both configuration files, then you should compare the old and new versions and decide whether you wish to retain your old settings. For example:
183183

184-
```bash
184+
```console
185185
$ cd ~/IOTstack
186186
$ diff ./services/mosquitto/mosquitto.conf ./volumes/mosquitto/config/mosquitto.conf
187187
```
@@ -192,7 +192,7 @@ Using `mosquitto.conf` as the example, assume you wish to use your existing file
192192

193193
1. To move your existing file into the new location:
194194

195-
```bash
195+
```console
196196
$ cd ~/IOTstack
197197
$ sudo mv ./services/mosquitto/mosquitto.conf ./volumes/mosquitto/config/mosquitto.conf
198198
```
@@ -201,19 +201,19 @@ Using `mosquitto.conf` as the example, assume you wish to use your existing file
201201

202202
2. Mosquitto will always enforce correct ownership (1883:1883) on any restart but it will not overwrite permissions. If in doubt, use mode 644 as your default for permissions:
203203

204-
```bash
204+
```console
205205
$ sudo chmod 644 ./services/mosquitto/mosquitto.conf
206206
```
207207

208208
3. Restart Mosquitto:
209209

210-
```bash
210+
```console
211211
$ docker-compose restart mosquitto
212212
```
213213

214214
4. Check your work:
215215

216-
```bash
216+
```console
217217
$ ls -l ./volumes/mosquitto/config/mosquitto.conf
218218
-rw-r--r-- 1 1883 1883 ssss mmm dd hh:mm ./volumes/mosquitto/config/mosquitto.conf
219219
```
@@ -232,7 +232,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
232232

233233
When `log_dest` is set to `stdout`, you inspect Mosquitto's logs like this:
234234

235-
```bash
235+
```console
236236
$ docker logs mosquitto
237237
```
238238

@@ -248,14 +248,14 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
248248

249249
and then restart Mosquitto:
250250

251-
```bash
251+
```console
252252
$ cd ~/IOTstack
253253
$ docker-compose restart mosquitto
254254
```
255255

256256
The path `/mosquitto/log/mosquitto.log` is an **internal** path. When this style of logging is active, you inspect Mosquitto's logs using the **external** path like this:
257257

258-
```bash
258+
```console
259259
$ sudo tail ~/IOTstack/volumes/mosquitto/log/mosquitto.log
260260
```
261261

@@ -306,13 +306,13 @@ The Mosquitto container performs self-repair each time the container is brought
306306

307307
To create a username and password, use the following as a template.
308308

309-
```bash
309+
```console
310310
$ docker exec mosquitto mosquitto_passwd -b /mosquitto/pwfile/pwfile «username» «password»
311311
```
312312

313313
Replace «username» and «password» with appropriate values, then execute the command. For example, to create the username "hello" with password "world":
314314

315-
```bash
315+
```console
316316
$ docker exec mosquitto mosquitto_passwd -b /mosquitto/pwfile/pwfile hello world
317317
```
318318

@@ -326,15 +326,15 @@ There are two ways to verify that the password file exists and has the expected
326326

327327
1. View the file using its **external** path:
328328

329-
```bash
329+
```console
330330
$ sudo cat ~/IOTstack/volumes/mosquitto/pwfile/pwfile
331331
```
332332

333333
> `sudo` is needed because the file is neither owned nor readable by `pi`.
334334

335335
2. View the file using its **internal** path:
336336

337-
```bash
337+
```console
338338
$ docker exec mosquitto cat /mosquitto/pwfile/pwfile
339339
```
340340

@@ -348,7 +348,7 @@ hello:$7$101$ZFOHHVJLp2bcgX+h$MdHsc4rfOAhmGG+65NpIEJkxY0beNeFUyfjNAGx1ILDmI498o4
348348

349349
To remove an entry from the password file:
350350

351-
```bash
351+
```console
352352
$ docker exec mosquitto mosquitto_passwd -D /mosquitto/pwfile/pwfile «username»
353353
```
354354

@@ -358,7 +358,7 @@ There are several ways to reset the password file. Your options are:
358358

359359
1. Remove the password file and restart Mosquitto:
360360

361-
```bash
361+
```console
362362
$ cd ~/IOTstack
363363
$ sudo rm ./volumes/mosquitto/pwfile/pwfile
364364
$ docker-compose restart mosquitto
@@ -368,15 +368,15 @@ There are several ways to reset the password file. Your options are:
368368

369369
2. Clear all existing passwords while adding a new password:
370370

371-
```bash
371+
```console
372372
$ docker exec mosquitto mosquitto_passwd -c -b /mosquitto/pwfile/pwfile «username» «password»
373373
```
374374

375375
The result is a password file with a single entry.
376376

377377
3. Clear all existing passwords in favour of a single dummy password which is then removed:
378378

379-
```bash
379+
```console
380380
$ docker exec mosquitto mosquitto_passwd -c -b /mosquitto/pwfile/pwfile dummy dummy
381381
$ docker exec mosquitto mosquitto_passwd -D /mosquitto/pwfile/pwfile dummy
382382
```
@@ -421,7 +421,7 @@ There are several ways to reset the password file. Your options are:
421421

422422
4. Save the modified configuration file and restart Mosquitto:
423423

424-
```bash
424+
```console
425425
$ cd ~/IOTstack
426426
$ docker-compose restart mosquitto
427427
```
@@ -438,15 +438,15 @@ There are several ways to reset the password file. Your options are:
438438

439439
If you do not have the Mosquitto clients installed on your Raspberry Pi (ie `$ which mosquitto_pub` does not return a path), install them using:
440440

441-
```bash
441+
```console
442442
$ sudo apt install -y mosquitto-clients
443443
```
444444

445445
#### test: *anonymous access is prohibited*
446446

447447
Test **without** providing credentials:
448448

449-
```bash
449+
```console
450450
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "/password/test" -m "up up and away"
451451
Connection Refused: not authorised.
452452
Error: The connection was refused.
@@ -460,7 +460,7 @@ Note:
460460

461461
Test with credentials
462462

463-
```bash
463+
```console
464464
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "/password/test" -m "up up and away" -u hello -P world
465465
$
466466
```
@@ -473,14 +473,14 @@ Note:
473473

474474
Prove round-trip connectivity will succeed when credentials are provided. First, set up a subscriber as a background process. This mimics the role of a process like Node-Red:
475475

476-
```bash
476+
```console
477477
$ mosquitto_sub -v -h 127.0.0.1 -p 1883 -t "/password/test" -F "%I %t %p" -u hello -P world &
478478
[1] 25996
479479
```
480480

481481
Repeat the earlier test:
482482

483-
```bash
483+
```console
484484
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "/password/test" -m "up up and away" -u hello -P world
485485
2021-02-16T14:40:51+1100 /password/test up up and away
486486
```
@@ -491,7 +491,7 @@ Note:
491491

492492
When you have finished testing you can kill the background process (press return twice after you enter the `kill` command):
493493

494-
```bash
494+
```console
495495
$ kill %1
496496
$
497497
[1]+ Terminated mosquitto_sub -v -h 127.0.0.1 -p 1883 -t "/password/test" -F "%I %t %p" -u hello -P world
@@ -520,7 +520,7 @@ Portainer's *Containers* display contains a *Status* column which shows health-c
520520

521521
You can also use the `docker ps` command to monitor health-check results. The following command narrows the focus to mosquitto:
522522

523-
```bash
523+
```console
524524
$ docker ps --format "table {{.Names}}\t{{.Status}}" --filter name=mosquitto
525525
```
526526

@@ -549,7 +549,7 @@ Possible reply patterns are:
549549

550550
You can also subscribe to the same topic that the health-check agent is using to view the retained messages as they are published:
551551

552-
```bash
552+
```console
553553
$ mosquitto_sub -v -h localhost -p 1883 -t "iotstack/mosquitto/healthcheck" -F "%I %t %p"
554554
```
555555

@@ -613,7 +613,7 @@ You can customise the operation of the health-check agent by editing the `mosqui
613613

614614
You can update most containers like this:
615615

616-
```bash
616+
```console
617617
$ cd ~/IOTstack
618618
$ docker-compose pull
619619
$ docker-compose up -d
@@ -632,7 +632,7 @@ The only way to know when an update to Mosquitto is available is to check the [e
632632

633633
Once a new version appears on *DockerHub*, you can upgrade Mosquitto like this:
634634

635-
```bash
635+
```console
636636
$ cd ~/IOTstack
637637
$ docker-compose build --no-cache --pull mosquitto
638638
$ docker-compose up -d mosquitto
@@ -689,7 +689,7 @@ If an update to Mosquitto introduces a breaking change, you can revert to an ear
689689

690690
4. Save the file and tell `docker-compose` to rebuild the local image:
691691

692-
```bash
692+
```console
693693
$ cd ~/IOTstack
694694
$ docker-compose build --no-cache --pull mosquitto
695695
$ docker-compose up -d mosquitto
@@ -700,15 +700,15 @@ If an update to Mosquitto introduces a breaking change, you can revert to an ear
700700

701701
5. Images built in this way will always be tagged with "latest", as in:
702702

703-
```bash
703+
```console
704704
$ docker images iotstack_mosquitto
705705
REPOSITORY TAG IMAGE ID CREATED SIZE
706706
iotstack_mosquitto latest 8c0543149b9b About a minute ago 16.2MB
707707
```
708708

709709
You may find it useful to assign an explicit tag to help you remember the version number used for the build. For example:
710710

711-
```bash
711+
```console
712712
$ docker tag iotstack_mosquitto:latest iotstack_mosquitto:2.0.13
713713
$ docker images iotstack_mosquitto
714714
REPOSITORY TAG IMAGE ID CREATED SIZE
@@ -718,7 +718,7 @@ If an update to Mosquitto introduces a breaking change, you can revert to an ear
718718

719719
You can also query the image metadata to discover version information:
720720

721-
```bash
721+
```console
722722
$ docker image inspect iotstack_mosquitto:latest | jq .[0].Config.Labels
723723
{
724724
"com.github.SensorsIot.IOTstack.Dockerfile.based-on": "https://github.com/eclipse/mosquitto",
@@ -764,7 +764,7 @@ If you have a use-case that needs port 9001, you can re-enable support by:
764764

765765
3. Restarting the container:
766766

767-
```bash
767+
```console
768768
$ cd ~/IOTstack
769769
$ docker-compose restart mosquitto
770770
```

0 commit comments

Comments
 (0)