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
95TARGET_FILE=" /etc/avahi/services/arduino.service"
106MARKER_LINE=" </service>"
@@ -13,30 +9,29 @@ SERIAL_NUMBER_PATH="/sys/devices/soc0/serial_number"
139echo " Configuring Avahi with serial number for network discovery..."
1410
1511if [ ! -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
1814fi
1915
2016
2117if [ ! -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
2420fi
2521
2622SERIAL_NUMBER=$( cat " $SERIAL_NUMBER_PATH " )
2723
2824if [ -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
3127fi
3228
3329if grep -q " serial_number=${SERIAL_NUMBER} " " $TARGET_FILE " ; then
3430 echo " Serial number ($SERIAL_NUMBER ) already configured. Skipping."
3531 exit 0
3632fi
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
4136echo " Adding serial number to $TARGET_FILE ..."
4237
0 commit comments