Skip to content

Commit 9723d4b

Browse files
committed
code review fix
1 parent da65948 commit 9723d4b

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

debian/arduino-app-cli/usr/sbin/arduino-avahi-serial.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/sh
2-
#
32
# Configure Avahi with the serial number.
4-
# This operation is non-blocking: if it fails,
5-
# the script will exit with success in order to
6-
# not to interrupt the post-install process.
7-
#
3+
84

95
TARGET_FILE="/etc/avahi/services/arduino.service"
106
MARKER_LINE="</service>"
@@ -13,30 +9,29 @@ SERIAL_NUMBER_PATH="/sys/devices/soc0/serial_number"
139
echo "Configuring Avahi with serial number for network discovery..."
1410

1511
if [ ! -f "$SERIAL_NUMBER_PATH" ]; then
16-
echo "Warning: Serial number path not found at $SERIAL_NUMBER_PATH. Skipping." >&2
17-
exit 0
12+
echo "Error: Serial number path not found at $SERIAL_NUMBER_PATH." >&2
13+
exit 1
1814
fi
1915

2016

2117
if [ ! -w "$TARGET_FILE" ]; then
22-
echo "Warning: Target file $TARGET_FILE not found or not writable. Skipping." >&2
23-
exit 0
18+
echo "Error: Target file $TARGET_FILE not found or not writable." >&2
19+
exit 1
2420
fi
2521

2622
SERIAL_NUMBER=$(cat "$SERIAL_NUMBER_PATH")
2723

2824
if [ -z "$SERIAL_NUMBER" ]; then
29-
echo "Warning: Serial number file is empty. Skipping." >&2
30-
exit 0
25+
echo "Error: Serial number file is empty." >&2
26+
exit 1
3127
fi
3228

3329
if grep -q "serial_number=${SERIAL_NUMBER}" "$TARGET_FILE"; then
3430
echo "Serial number ($SERIAL_NUMBER) already configured. Skipping."
3531
exit 0
3632
fi
3733

38-
SERIAL_NUMBER_ESCAPED=$(echo "$SERIAL_NUMBER" | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/\&/\\\&/g')
39-
NEW_LINE=" <txt-record>serial_number=${SERIAL_NUMBER_ESCAPED}</txt-record>"
34+
NEW_LINE=" <txt-record>serial_number=${SERIAL_NUMBER}</txt-record>"
4035

4136
echo "Adding serial number to $TARGET_FILE..."
4237

0 commit comments

Comments
 (0)