Made sed command portable, added checks to not dupe file edits.

This commit is contained in:
Richard Goodwin
2018-10-19 01:39:24 -05:00
parent 475af79d48
commit 258051039d

View File

@@ -51,12 +51,22 @@ verify_wifi_variables
CMDLINE_TXT_PATH="$BOOT_DIR/cmdline.txt" CMDLINE_TXT_PATH="$BOOT_DIR/cmdline.txt"
CONFIG_TXT_PATH="$BOOT_DIR/config.txt" CONFIG_TXT_PATH="$BOOT_DIR/config.txt"
echo "Updating $CONFIG_TXT_PATH ..." if ! grep -q "dtoverlay=dwc2" $CONFIG_TXT_PATH
echo "" >> "$CONFIG_TXT_PATH" then
echo "dtoverlay=dwc2" >> "$CONFIG_TXT_PATH" echo "Updating $CONFIG_TXT_PATH ..."
echo "" >> "$CONFIG_TXT_PATH"
echo "dtoverlay=dwc2" >> "$CONFIG_TXT_PATH"
else
echo "$CONFIG_TXT_PATH already contains the required dwc2 module"
fi
echo "Updating $CMDLINE_TXT_PATH ..." if ! grep -q "dwc2,g_ether" $CMDLINE_TXT_PATH
sed -i -e "s/rootwait/rootwait modules-load=dwc2,g_ether/" -e "s@ init=/usr/lib/raspi-config/init_resize.sh@@" "$CMDLINE_TXT_PATH" then
echo "Updating $CMDLINE_TXT_PATH ..."
sed -i'.bak' -e "s/rootwait/rootwait modules-load=dwc2,g_ether/" -e "s@ init=/usr/lib/raspi-config/init_resize.sh@@" "$CMDLINE_TXT_PATH"
else
echo "$CMDLINE_TXT_PATH already updated with modules and removed initial resize script."
fi
echo "Enabling SSH ..." echo "Enabling SSH ..."
touch "$BOOT_DIR/ssh" touch "$BOOT_DIR/ssh"