forked from sensorgnome-org/sensorgnome-support
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit-pi.sh
More file actions
executable file
·42 lines (35 loc) · 1.57 KB
/
init-pi.sh
File metadata and controls
executable file
·42 lines (35 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/bash -e
# Initialize a development rPi with "my" stuff.
# This is not a way to make sensorgnome releases (use the sensorgnome-build repo for this).
# The intent of this script is to be able to flash an SDcard with the official rPi lite OS image,
# initialize the image with some SSH creds and some additional tweaks so it can be used to test and
# dev the debian services in this repo. I.e., to make the "doit" scripts found in each subdir work.
SSH_KEY=tve-2016.pub # name of the ssh public key file in $HOME/.ssh to put on the pi
SG_NAME=sg-eth.voneicken.com # host name (or IP address) of the pi on the local network
rootfs=$(findmnt -A -l -n -t ext4,vfat | egrep '/rootfs\s' | cut -f1 -d " ")
if [[ -z "$rootfs" ]]; then
echo "Cannot locate rootfs"
exit 1
fi
if [[ ! -d $rootfs/home/gnome ]]; then
echo "Rootfs at $rootfs doesn't seem to be rPi image"
exit 1
fi
echo "Rootfs at $rootfs"
bootfs=$(sed -e "s/rootfs/boot/" <<<$rootfs)
if [[ ! -f $bootfs/config.txt ]]; then
echo "Bootfs at $bootfs doesn't seem to be rPi image"
exit 1
fi
echo "Bootfs at $bootfs"
# enable ssh daemon
touch $bootfs/ssh
# copy ssh key
mkdir -p $rootfs/home/gnome/.ssh
chmod 700 $rootfs/home/gnome/.ssh
cp $HOME/.ssh/$SSH_KEY $rootfs/home/gnome/.ssh/authorized_keys
sudo chown -R 1000 $rootfs/home/gnome/.ssh || echo "Oops, can't give .ssh the correct owner"
# cause root partition to be sized to 4GB so there's room left for a data partition
# note that the size is in 512-byte sectors
sudo sed -i -e 's/\(\s*TARGET_END=\).*/\18388608/' $rootfs/usr/lib/raspi-config/init_resize.sh
echo "Ready!"