Skip to content

Commit a227720

Browse files
committed
20220708 Node-RED - old-menu branch - PR 2 of 2 - part 2
Fixes `nodered_list_installed_nodes.sh`. Now relies on `npm` running inside the container to discover what's installed where. Signed-off-by: Phill Kelley <[email protected]>
1 parent 08c2930 commit a227720

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed
Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
#!/usr/bin/env bash
22

3-
INTERNAL="/usr/src/node-red/node_modules"
4-
EXTERNAL="$HOME/IOTstack/volumes/nodered/data/node_modules"
5-
6-
echo -e "\nNodes installed by Dockerfile INSIDE the container at $INTERNAL"
7-
8-
CANDIDATES=$(docker exec nodered bash -c "ls -1d $INTERNAL/node-red-*")
9-
10-
for C in $CANDIDATES; do
11-
12-
NODE=$(basename "$C")
13-
14-
# is a node of the same name also present externally
15-
if [ -d "$EXTERNAL/$NODE" ] ; then
16-
17-
# yes! the internal node is blocked by the external node
18-
echo " BLOCKED: $NODE"
19-
20-
else
21-
22-
# no! so that means it's active
23-
echo " ACTIVE: $NODE"
24-
3+
# where Dockerfile installs components INSIDE the container
4+
DOCKERFILE="/usr/src/node-red"
5+
6+
# paths to the persistent store
7+
PERSISTENT_INTERNAL="/data"
8+
PERSISTENT_EXTERNAL="$HOME/IOTstack/volumes/nodered/data"
9+
10+
# the folder in each case containing node modules
11+
MODULES="node_modules"
12+
13+
# fetch what npm knows about components that form part of the image
14+
echo -e "\nFetching list of candidates installed via Dockerfile"
15+
CANDIDATES=$(docker exec nodered bash -c "cd \"$DOCKERFILE\" ; npm list --depth=0 --parseable")
16+
17+
# report
18+
echo -e "\nComponents built into the image (via Dockerfile)"
19+
PARENT=$(basename "$DOCKERFILE")
20+
for CANDIDATE in $CANDIDATES; do
21+
COMPONENT=$(basename "$CANDIDATE")
22+
if [ "$COMPONENT" != "$PARENT" ] ; then
23+
if [ -d "$PERSISTENT_EXTERNAL/$MODULES/$COMPONENT" ] ; then
24+
# yes! the internal node is blocked by the external node
25+
echo " BLOCKED: $COMPONENT"
26+
else
27+
# no! so that means it's active
28+
echo " ACTIVE: $COMPONENT"
29+
fi
2530
fi
26-
2731
done
2832

29-
echo -e "\nNodes installed by Manage Palette OUTSIDE the container at $EXTERNAL"
30-
31-
CANDIDATES=$(ls -1d "$EXTERNAL/node-red-"*)
32-
33-
for C in $CANDIDATES; do
34-
35-
NODE=$(basename "$C")
36-
37-
echo " $NODE"
38-
33+
# fetch what npm knows about components that are in the persistent store
34+
echo -e "\nFetching list of candidates installed via Manage Palette or npm"
35+
CANDIDATES=$(docker exec nodered bash -c "cd \"$PERSISTENT_INTERNAL\" ; npm list --depth=0 --parseable")
36+
37+
# report
38+
echo -e "\nComponents in persistent store at\n $PERSISTENT_EXTERNAL/$MODULES"
39+
PARENT=$(basename "$PERSISTENT_INTERNAL")
40+
for CANDIDATE in $CANDIDATES; do
41+
COMPONENT=$(basename "$CANDIDATE")
42+
if [ "$COMPONENT" != "$PARENT" ] ; then
43+
echo " $COMPONENT"
44+
fi
3945
done
4046

4147
echo ""

0 commit comments

Comments
 (0)