hacks/fix-raspian-defaults/install-to-boot.sh

61 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2019-10-04 12:26:33 +00:00
#!/bin/bash
2019-10-04 13:41:13 +00:00
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2019-10-04 12:26:33 +00:00
function die {
echo "$1" > /dev/stderr
exit 1
}
function info {
echo "$1" > /dev/stderr
}
2019-10-04 13:41:13 +00:00
if [ "$#" -ne 1 ]; then
die "usage: $0 <newhostname>"
fi
NEWHOSTNAME="$1"
2019-10-04 12:26:33 +00:00
function doinstall {
2019-10-04 13:41:13 +00:00
2019-10-04 12:26:33 +00:00
# assumes osx
[[ "$(uname -s)" != "Darwin" ]] && die "need osx"
2019-10-04 13:41:13 +00:00
2019-10-04 12:26:33 +00:00
TARGET="/Volumes/boot"
if [[ ! -e "$TARGET/LICENCE.broadcom" ]]; then
die "cant find rpi boot dir"
else
info "rpi boot dir found at $TARGET"
fi
2019-10-04 13:41:13 +00:00
# copy root overlay into FAT /boot partition
2019-10-04 13:46:23 +00:00
rsync -avP "$THISDIR/root.overlay/" "$TARGET/root.overlay/"
2019-10-04 13:41:13 +00:00
# set hostname in overlay:
2019-10-04 13:46:23 +00:00
mkdir -p $TARGET/root.overlay/etc
echo "$NEWHOSTNAME" > "$TARGET/root.overlay/etc/hostname"
cat >> $TARGET/root.overlay/etc/hosts <<EOF
2019-10-04 13:41:13 +00:00
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 $NEWHOSTNAME
EOF
rsync -avP "$THISDIR/rc.local.txt" "$TARGET/rc.local.txt"
2019-10-04 12:26:33 +00:00
2019-10-04 13:41:13 +00:00
# fixed in my image
# 2019-09-26-raspbian-buster-lite-patched-rclocal-noresizeroot.zip
#info "disabling partition resize"
#sed -i '' -e 's/init=[^[:space:]]*//' "$TARGET/cmdline.txt"
2019-10-04 12:26:33 +00:00
2019-10-04 13:41:13 +00:00
sync
diskutil eject $TARGET
2019-10-04 12:26:33 +00:00
}
doinstall