almost working
This commit is contained in:
parent
bad920ab58
commit
0c72b2c372
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
echo "usage: $0 <hostname>"
|
echo "usage: $0 <newhostname>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ tar -c ./root | $SS ssh $SSH_OPTIONS pi@raspberrypi.local "
|
|||||||
sudo chmod ugoa+rx /tmp/setup &&
|
sudo chmod ugoa+rx /tmp/setup &&
|
||||||
cd /tmp/setup &&
|
cd /tmp/setup &&
|
||||||
sudo tar xvf - &&
|
sudo tar xvf - &&
|
||||||
sudo rsync -avP /tmp/setup/root/ / ;
|
sudo rsync -avP /tmp/setup/root/ / &&
|
||||||
nohup sudo bash /etc/rc.local &
|
reboot ;
|
||||||
tail -f /var/log/messages
|
|
||||||
"
|
"
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
function die {
|
function die {
|
||||||
echo "$1" > /dev/stderr
|
echo "$1" > /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
@ -9,10 +11,18 @@ function info {
|
|||||||
echo "$1" > /dev/stderr
|
echo "$1" > /dev/stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
die "usage: $0 <newhostname>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEWHOSTNAME="$1"
|
||||||
|
|
||||||
function doinstall {
|
function doinstall {
|
||||||
|
|
||||||
# assumes osx
|
# assumes osx
|
||||||
[[ "$(uname -s)" != "Darwin" ]] && die "need osx"
|
[[ "$(uname -s)" != "Darwin" ]] && die "need osx"
|
||||||
|
|
||||||
|
|
||||||
TARGET="/Volumes/boot"
|
TARGET="/Volumes/boot"
|
||||||
|
|
||||||
if [[ ! -e "$TARGET/LICENCE.broadcom" ]]; then
|
if [[ ! -e "$TARGET/LICENCE.broadcom" ]]; then
|
||||||
@ -21,11 +31,30 @@ function doinstall {
|
|||||||
info "rpi boot dir found at $TARGET"
|
info "rpi boot dir found at $TARGET"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "disabling partition resize"
|
# copy root overlay into FAT /boot partition
|
||||||
sed -i '' -e 's/init=[^[:space:]]*//' "$TARGET/cmdline.txt"
|
rsync -avP "$THISDIR/root" "$TARGET/root"
|
||||||
|
|
||||||
info "copying setup files to disk"
|
# 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"
|
||||||
|
|
||||||
|
# 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
|
doinstall
|
||||||
|
10
fix-raspian-defaults/rc.local.txt
Normal file
10
fix-raspian-defaults/rc.local.txt
Normal file
@ -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
|
@ -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
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
whoami
|
|
||||||
uptime
|
|
||||||
cat /etc/rc.local
|
|
@ -1,7 +1,8 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Run user provided scripts on boot
|
Description=Run user provided scripts on boot
|
||||||
ConditionPathExists=/usr/lib/raspi-ini/run-parts.sh
|
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]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
# Run every per-once script
|
# 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
|
# Rename every per-once script
|
||||||
for f in /boot/per-once.d/*.sh; do
|
for f in /boot/per-once.d/*.sh; do
|
||||||
|
Loading…
Reference in New Issue
Block a user