working on rpi borging
This commit is contained in:
parent
f467f89c85
commit
45b3eb8ad5
31
pisetup/01-install-to-boot.sh
Executable file
31
pisetup/01-install-to-boot.sh
Executable 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
37
pisetup/02-borg-via-ssh.sh
Executable 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
|
||||
"
|
30
pisetup/install-packages.sh
Normal file
30
pisetup/install-packages.sh
Normal 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
|
21
pisetup/root/boot/rc.local.txt
Normal file
21
pisetup/root/boot/rc.local.txt
Normal 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
|
||||
|
4
pisetup/root/boot/setup-scripts/01-set-time.sh
Normal file
4
pisetup/root/boot/setup-scripts/01-set-time.sh
Normal file
@ -0,0 +1,4 @@
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt update
|
||||
apt -y install ntpdate
|
||||
ntpdate time.apple.com
|
36
pisetup/root/boot/setup-scripts/05-packages.sh
Normal file
36
pisetup/root/boot/setup-scripts/05-packages.sh
Normal 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
|
@ -0,0 +1,5 @@
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt update
|
||||
apt -y install command-not-found
|
||||
apt-file update
|
||||
update-command-not-found
|
20
pisetup/root/boot/setup-scripts/20-install-nvm-and-node.sh
Normal file
20
pisetup/root/boot/setup-scripts/20-install-nvm-and-node.sh
Normal 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
|
12
pisetup/root/boot/setup-scripts/30-install-signoffline.sh
Normal file
12
pisetup/root/boot/setup-scripts/30-install-signoffline.sh
Normal 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
|
5
pisetup/root/boot/setup-scripts/99-disable-swap.sh
Normal file
5
pisetup/root/boot/setup-scripts/99-disable-swap.sh
Normal file
@ -0,0 +1,5 @@
|
||||
/sbin/dphys-swapfile swapoff
|
||||
/sbin/dphys-swapfile uninstall
|
||||
apt purge -y dphys-swapfile
|
||||
swapoff -a
|
||||
rm /var/swap
|
0
pisetup/root/etc/default/keyboard
Normal file
0
pisetup/root/etc/default/keyboard
Normal file
1
pisetup/root/etc/default/locale
Normal file
1
pisetup/root/etc/default/locale
Normal file
@ -0,0 +1 @@
|
||||
LANG=en_US.UTF-8
|
24
pisetup/root/etc/rc.local
Normal file
24
pisetup/root/etc/rc.local
Normal 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
|
5
pisetup/root/etc/setup/configure-pi.sh
Normal file
5
pisetup/root/etc/setup/configure-pi.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
whoami
|
||||
uptime
|
||||
cat /etc/rc.local
|
6
pisetup/setup-keys.sh
Normal file
6
pisetup/setup-keys.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user