Working sound setup for raspis

This commit is contained in:
Martin Bauer
2020-05-10 15:25:38 +02:00
parent caf6232dfb
commit d8c9a491d1
40 changed files with 815 additions and 43 deletions

41
scripts/create-raspian-image/create-raspian-image.sh Normal file → Executable file
View File

@@ -4,6 +4,8 @@ set -e # exit on error
TARGET_FOLDER="./rpi_image"
VERSION="2020-02-13"
VERSION_DIR="2020-02-14" # :D
echo "This script downloads raspian lite, and modifies the image to enable SSH and set hostname"
@@ -14,16 +16,18 @@ fi
echo -n Hostname of new pi
read -p "Hostname of new pi [newrpi]: " RPI_HOSTNAME
RPI_HOSTNAME=${HOSTNAME:-newrpi}
read -p "WIFI password (leave empty for non-wifi setup) [] " WIFI_PASSWORD
RPI_HOSTNAME=${RPI_HOSTNAME:-newrpi}
SCRIPT_DIR=`pwd`
mkdir -p $TARGET_FOLDER
cd $TARGET_FOLDER
echo "Downloading image"
IMG_FILE_BASENAME=${VERSION}-raspbian-buster-lite.zip
wget http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-${VERSION}/${IMG_FILE_BASENAME}.zip
wget http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-${VERSION}/${IMG_FILE_BASENAME}.zip.sha256
IMG_FILE_BASENAME=${VERSION}-raspbian-buster-lite
wget http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-${VERSION_DIR}/${IMG_FILE_BASENAME}.zip
wget http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-${VERSION_DIR}/${IMG_FILE_BASENAME}.zip.sha256
echo "Checksum verification"
@@ -49,17 +53,40 @@ echo $RPI_HOSTNAME > mounted_image/system/etc/hostname
touch mounted_image/boot/ssh # startup ssh
sed -i "/^#PermitRootLogin/ cPermitRootLogin prohibit-password" mounted_image/system/etc/ssh/sshd_config
mkdir -p mounted_image/system/root/.ssh
cat $SCRIPT_DIR/public_keys/*.pub > mounted_image/system/root/.ssh/authorized_keys
cat $SCRIPT_DIR/*.pub > mounted_image/system/root/.ssh/authorized_keys
chmod 700 mounted_image/system/root/.ssh
chmod 600 mounted_image/system/root/.ssh/authorized_keys
echo "Unmounting image"
if [ -z "$WIFI_PASSWORD" ]
then
echo "Skipping WIFI setup"
else
echo "Setting up initial wifi config"
/bin/cat <<EOM >mounted_image/boot/wpa_supplicant.conf
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="WLAN"
psk="${WIFI_PASSWORD}"
}
EOM
fi
echo "Unmounting image and other cleanup"
sleep 3 # to prevent "device is busy"
umount /dev/loop42p1
umount /dev/loop42p2
losetup -d /dev/loop42
rmdir mounted_image/boot
rmdir mounted_image/system
rmdir mounted_image
rm ${IMG_FILE_BASENAME}.zip.sha256
chmod a+rw ${IMG_FILE_BASENAME}.img .
echo ""
echo ""