Browse Source

almost working

master
Jeffrey Paul 3 years ago
parent
commit
0c72b2c372
  1. 7
      attic/02-borg-via-ssh.sh
  2. 35
      fix-raspian-defaults/01-install-to-boot.sh
  3. 10
      fix-raspian-defaults/rc.local.txt
  4. 24
      fix-raspian-defaults/root/etc/rc.local
  5. 5
      fix-raspian-defaults/root/etc/setup/configure-pi.sh
  6. 3
      fix-raspian-defaults/root/etc/systemd/raspberrypi-initial-setup.service
  7. 2
      fix-raspian-defaults/root/usr/lib/raspi-ini/run-parts.sh

7
fix-raspian-defaults/02-borg-via-ssh.sh → attic/02-borg-via-ssh.sh

@ -1,7 +1,7 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "usage: $0 <hostname>"
echo "usage: $0 <newhostname>"
exit 1
fi
@ -31,7 +31,6 @@ tar -c ./root | $SS ssh $SSH_OPTIONS pi@raspberrypi.local "
sudo chmod ugoa+rx /tmp/setup &&
cd /tmp/setup &&
sudo tar xvf - &&
sudo rsync -avP /tmp/setup/root/ / ;
nohup sudo bash /etc/rc.local &
tail -f /var/log/messages
sudo rsync -avP /tmp/setup/root/ / &&
reboot ;
"

35
fix-raspian-defaults/01-install-to-boot.sh

@ -1,5 +1,7 @@
#!/bin/bash
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function die {
echo "$1" > /dev/stderr
exit 1
@ -9,10 +11,18 @@ function info {
echo "$1" > /dev/stderr
}
if [ "$#" -ne 1 ]; then
die "usage: $0 <newhostname>"
fi
NEWHOSTNAME="$1"
function doinstall {
# assumes osx
[[ "$(uname -s)" != "Darwin" ]] && die "need osx"
TARGET="/Volumes/boot"
if [[ ! -e "$TARGET/LICENCE.broadcom" ]]; then
@ -21,11 +31,30 @@ function doinstall {
info "rpi boot dir found at $TARGET"
fi
info "disabling partition resize"
sed -i '' -e 's/init=[^[:space:]]*//' "$TARGET/cmdline.txt"
# copy root overlay into FAT /boot partition
rsync -avP "$THISDIR/root" "$TARGET/root"
# set hostname in overlay:
mkdir -p $TARGET/root/etc
echo "$NEWHOSTNAME" > "$TARGET/root/etc/hostname"
cat >> $TARGET/root/etc/hosts <<EOF
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"
info "copying setup files to disk"
# 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"
sync
diskutil eject $TARGET
}
doinstall

10
fix-raspian-defaults/rc.local.txt

@ -0,0 +1,10 @@
#!/bin/sh # can't assume bash yet
if [ ! -d /boot/root ]; then
logger -s -t rc.local.txt cant find root overlay in /boot
else
rsync -avP /boot/root/ / && \
rm -rf /boot/root /boot/rc.local.txt # we only need to run once
fi
reboot

24
fix-raspian-defaults/root/etc/rc.local

@ -1,24 +0,0 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
if [ -e /boot/rc.local.txt ]; then
. /boot/rc.local.txt
fi
exit 0

5
fix-raspian-defaults/root/etc/setup/configure-pi.sh

@ -1,5 +0,0 @@
#!/bin/bash
whoami
uptime
cat /etc/rc.local

3
fix-raspian-defaults/root/etc/systemd/raspberrypi-initial-setup.service

@ -1,7 +1,8 @@
[Unit]
Description=Run user provided scripts on boot
ConditionPathExists=/usr/lib/raspi-ini/run-parts.sh
After=dhcpcd.service # Need to put more thought into when
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot

2
fix-raspian-defaults/root/usr/lib/raspi-ini/run-parts.sh

@ -4,7 +4,7 @@
shopt -s nullglob
# Run every per-once script
run-parts --regex '.*\.sh$' /boot/per-once.d
run-parts --regex '.*\.sh$' /boot/per-once.d |
# Rename every per-once script
for f in /boot/per-once.d/*.sh; do

Loading…
Cancel
Save