working on rpi borging

This commit is contained in:
Jeffrey Paul 2019-10-04 05:26:33 -07:00
parent f467f89c85
commit 45b3eb8ad5
15 changed files with 237 additions and 0 deletions

31
pisetup/01-install-to-boot.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
function die {
echo "$1" > /dev/stderr
exit 1
}
function info {
echo "$1" > /dev/stderr
}
function doinstall {
# assumes osx
[[ "$(uname -s)" != "Darwin" ]] && die "need osx"
TARGET="/Volumes/boot"
if [[ ! -e "$TARGET/LICENCE.broadcom" ]]; then
die "cant find rpi boot dir"
else
info "rpi boot dir found at $TARGET"
fi
info "disabling partition resize"
sed -i '' -e 's/init=[^[:space:]]*//' "$TARGET/cmdline.txt"
info "copying setup files to disk"
}
doinstall

37
pisetup/02-borg-via-ssh.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "usage: $0 <hostname>"
exit 1
fi
HOSTNAME="$1"
SS="$(brew --prefix)/opt/util-linux/bin/setsid"
if [[ ! -e $SS ]]; then
brew install util-linux
fi
SSH_OPTIONS="-oLogLevel=error"
SSH_OPTIONS="${SSH_OPTIONS} -oStrictHostKeyChecking=no"
SSH_OPTIONS="${SSH_OPTIONS} -oUserKnownHostsFile=/dev/null"
echo 'echo raspberry' > /tmp/defaultpw.sh
chmod 777 /tmp/defaultpw.sh
export SSH_ASKPASS="/tmp/defaultpw.sh"
export DISPLAY=nope
tar -c ./root | $SS ssh $SSH_OPTIONS pi@raspberrypi.local "
DEBIAN_FRONTEND=noninteractive
sudo hostname $HOSTNAME &&
echo $HOSTNAME | sudo tee /etc/hostname &&
sudo apt update &&
sudo apt install -y rsync bash &&
sudo mkdir -p /tmp/setup &&
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
"

View File

@ -0,0 +1,30 @@
#!/bin/bash
PKGS="
bash-completion
build-essential
byobu
command-not-found
cryptsetup-bin
daemontools
golang-go
iptables-persistent
iptraf-ng
jq
less
lsof
mosh
ntp
pbzip2
pv
runit
runit-systemd
socat
vim
wget
"
export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt install -y $PKGS

View File

@ -0,0 +1,21 @@
#!/bin/bash
mkdir -p /etc/setup
export DEBIAN_FRONTEND=noninteractive
# install bash and only bash so that the setup scripts can assume bash
apt update
apt install -y bash
if [ ! -e /etc/setup/setup-done ]; then
/bin/bash << 'EOF'
for FILE in /boot/setup-scripts/*.sh; do
echo "running '$FILE'" | logger -s -t setup-scripts
/bin/bash $FILE 2>&1 | logger -s -t setup-scripts
done
EOF
echo "system init complete" | logger -s -t setup-scripts
touch /etc/setup/setup-done
fi

View File

@ -0,0 +1,4 @@
export DEBIAN_FRONTEND=noninteractive
apt update
apt -y install ntpdate
ntpdate time.apple.com

View File

@ -0,0 +1,36 @@
PKGS="
apt-transport-https
byobu
ca-certificates
cryptsetup-bin
curl
dirmngr
dnsutils
gnupg-agent
gnupg2
haveged
inetutils-ping
jq
lsof
man-db
mosh
nmap
opensc
pcscd
pinentry-curses
pv
rsync
runit
runit-systemd
scdaemon
screen
software-properties-common
usbmount
vim
wget
"
export DEBIAN_FRONTEND=noninteractive
apt update
apt upgrade -y
apt install -y $PKGS

View File

@ -0,0 +1,5 @@
export DEBIAN_FRONTEND=noninteractive
apt update
apt -y install command-not-found
apt-file update
update-command-not-found

View File

@ -0,0 +1,20 @@
export DEBIAN_FRONTEND=noninteractive
apt update
apt install -y git
export HOME=/root
git clone https://github.com/creationix/nvm.git /root/.nvm
cat >> /root/.bashrc <<'EOF'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
EOF
source /root/.bashrc
nvm install 10
nvm use 10
npm install -g npm@latest
npm install -g yarn

View File

@ -0,0 +1,12 @@
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
nvm use 8
# @next as of 14 nov 2018
VERSION="5cd9d6be4f05831f76a12cc833e1fbd5b6e143cd"
unzip -d /var/lib/signoffline /boot/signoffline.zip
cd /var/lib/signoffline
git checkout $VERSION
yarn install

View File

@ -0,0 +1,5 @@
/sbin/dphys-swapfile swapoff
/sbin/dphys-swapfile uninstall
apt purge -y dphys-swapfile
swapoff -a
rm /var/swap

View File

View File

@ -0,0 +1 @@
LANG=en_US.UTF-8

24
pisetup/root/etc/rc.local Normal file
View File

@ -0,0 +1,24 @@
#!/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

View File

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

6
pisetup/setup-keys.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
KEY_URL="https://sneak.cloud/authorized_keys"
curl -fLo /root/.ssh/authorized_keys --create-dirs $KEY_URL
curl -fLo /home/pi/.ssh/authorized_keys --create-dirs $KEY_URL