Add a new script to prep sdcards containing raspian-lite. This will add the flags and config to the /boot mount that allows the raspberry pi to be accessed via SSH on boot, and allows it to be used as an ethernet device over USB.

This commit is contained in:
mmcwilliams 2019-03-26 14:43:20 -04:00
parent 6557b48acc
commit 6720fbcacb
1 changed files with 37 additions and 0 deletions

37
scripts/sdcard.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
if ! [ -d "${1}" ]; then
echo "No path defined"
echo "Syntax: sh sdcard.sh /path/to/sdcard/boot/"
exit 1
fi
CARD_PATH=${1}
START_PATH=$(pwd)
CONFIG_FILE="./config.txt"
CMD_FILE="./cmdline.txt"
TMP_FILE=$(mktemp)
echo $TMP_FILE
echo "Preparing card for raspberry pi @ $CARD_PATH"
cd $CARD_PATH
echo "Enabling ssh on first boot"
touch ssh
if ! grep "dtoverlay=dwc2" $CONFIG_FILE; then
echo "Adding line dtoverlay=dwc2 to $CONFIG_FILE"
echo "dtoverlay=dwc2" >> $CONFIG_FILE
else
echo "$CONFIG_FILE already correct"
fi
if ! grep "modules-load=dwc2,g_ether" $CMD_FILE; then
echo "Adding modiles-load=dwc2,g_ether"
sed 's:rootwait :rootwait modules-load=dwc2,g_ether :g' $CMD_FILE >> $TMP_FILE
mv $TMP_FILE $CMD_FILE
else
echo "$CMD_FILE already correct"
fi
cd $START_PATH