forked from sensorgnome-org/sensorgnome-build
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit-sdcard.sh
More file actions
executable file
·35 lines (29 loc) · 925 Bytes
/
init-sdcard.sh
File metadata and controls
executable file
·35 lines (29 loc) · 925 Bytes
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
#! /bin/bash -e
MNT=/run/media/$USER
BOOT=$(echo -n $MNT/boot*)
echo BOOT=$BOOT
if [[ ! -d $BOOT ]]; then
echo "Did not find $MNT/boot*, trying to mound sdcard"
dev=$(lsblk -d -o NAME,MODEL,SIZE | grep -E '(uSD|USB DISK).*[0-9][0-9]\.[0-9]G' | cut -d" " -f1)
if [[ -z $dev ]]; then echo "No device found"; exit 1; fi
udisksctl mount -b /dev/${dev}1
udisksctl mount -b /dev/${dev}2
sleep 2
ls $MNT
fi
if [[ ! -d $BOOT ]]; then
echo "Cannot find SD card at $MNT/boot*"
echo "Did you perhaps forget to remove and re-insert the SD card after flashing?"
exit 1
fi
if [[ ! -d $MNT/rootfs/home/gnome ]]; then
mkdir -p $MNT/rootfs
sudo mount /dev/sdc2 $MNT/rootfs
fi
PI=$MNT/rootfs/home/gnome
cp ~/.tmux.* $PI || true
mkdir -p $PI/.ssh
chmod 700 $PI/.ssh
cp ~/.ssh/tve-2022.pub $PI/.ssh/authorized_keys
sudo sed -i -e '/^%sudo/s/ALL$/NOPASSWD: ALL/' $MNT/rootfs/etc/sudoers
sync