Added sysdweb
This commit is contained in:
69
scripts/create-raspian-image/create-raspian-image.sh
Normal file
69
scripts/create-raspian-image/create-raspian-image.sh
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e # exit on error
|
||||
|
||||
TARGET_FOLDER="./rpi_image"
|
||||
VERSION="2020-02-13"
|
||||
|
||||
echo "This script downloads raspian lite, and modifies the image to enable SSH and set hostname"
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n Hostname of new pi
|
||||
read -p "Hostname of new pi [newrpi]: " RPI_HOSTNAME
|
||||
RPI_HOSTNAME=${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
|
||||
|
||||
|
||||
echo "Checksum verification"
|
||||
sha256sum -c ${IMG_FILE_BASENAME}.zip.sha256
|
||||
|
||||
|
||||
echo "Unpack image"
|
||||
unzip ${IMG_FILE_BASENAME}.zip
|
||||
rm ${IMG_FILE_BASENAME}.zip
|
||||
|
||||
|
||||
echo "Mounting image"
|
||||
mkdir mounted_image
|
||||
mkdir mounted_image/boot
|
||||
mkdir mounted_image/system
|
||||
losetup -P /dev/loop42 ${IMG_FILE_BASENAME}.img
|
||||
mount /dev/loop42p1 mounted_image/boot
|
||||
mount /dev/loop42p2 mounted_image/system
|
||||
|
||||
|
||||
echo "Enabling SSH and writing hostname"
|
||||
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
|
||||
chmod 700 mounted_image/system/root/.ssh
|
||||
chmod 600 mounted_image/system/root/.ssh/authorized_keys
|
||||
|
||||
echo "Unmounting image"
|
||||
umount /dev/loop42p1
|
||||
umount /dev/loop42p2
|
||||
losetup -d /dev/loop42
|
||||
rmdir mounted_image/boot
|
||||
rmdir mounted_image/system
|
||||
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "The image is ready in folder ${TARGET_FOLDER}"
|
||||
echo "copy to SD card with"
|
||||
echo " dd bs=4M status=progress if=the_image of=/dev/your/sdcard"
|
||||
echo " use e.g. /dev/sdb not /dev/sdb1"
|
||||
2
scripts/create-raspian-image/sshkey.pub
Normal file
2
scripts/create-raspian-image/sshkey.pub
Normal file
@@ -0,0 +1,2 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu66CgHoF+v1z5ydpu0SJzPuAa0eARLLggMAJY4vWcLfLTTlFjwPpO9kjkr4acUL5uLHZkAFqXQZC91io80bIfyBiM1i1yBq290x8sETgoNHrNzvcCQUBAeCxhcogi68F14BbpwBbejDTPKKybpuuAnVPj9YiHVFEDbqjLwoEY+HH7SkCsrK8qTyp9rHzwPGk0xPBwTnCPXqzvUCr/4H+m/5lamVIOW6XYoqnvAp5jP0mbadrmB0PwvK8cfgwPJWQeLJcqwl87mwHjjlrCinkpQbd2D8mR798bGmW/iTZ7GLCkyBNE34qKg24CzE0scWjqyWICXOrTYUXLORDt99/F martin@Laptop
|
||||
|
||||
0
scripts/hassio_rpi4 installation.md
Normal file
0
scripts/hassio_rpi4 installation.md
Normal file
Reference in New Issue
Block a user