Last active
September 23, 2019 19:50
-
-
Save Tobiaqs/4d471f9510265503a4b31b4984650bdf to your computer and use it in GitHub Desktop.
Very basic bootstrap script for RPi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this script sets up a mint raspbian installation as follows: | |
# - all packages updated | |
# - nfs & ntfs-3g installed | |
# - mount point for hard drive on /dev/sda1 is created and ownership is granted to pi:pi | |
# - nfs share is created for this mount point and access is given to $WOOLBIRD_IP | |
# - my public ssh key is authorized | |
# - hostname of the installation set to $NEW_HOSTNAME | |
if [ "$EUID" -ne 0 ]; then | |
echo "Run as root pal" | |
exit | |
fi | |
NEW_HOSTNAME=sandman | |
WOOLBIRD_IP=192.168.178.227 | |
# install public ssh key | |
mkdir /home/pi/.ssh | |
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFObzc4AM01Qmz4ULOsqm7UCSqh6XInbjSakiva56Otox+0Hni8blwYh28NIUGUeb1SSeyvU3iX/SVjqBZlmrMrklgx/ITnEo1e+kJrL7jhqxDHG3lssw5p60iMss/qFEkScbkNisPS0xERC8tlhmo6aul+EQfyEZIEnd7Uf9Njfz56zuyntrEKl9MUZTdks2ZlylAqaalEB+VJmtpcs2mFUtpE/QDiIjl08hpLuZW9y6bae4YWW5U7n3XBDwBOb1Vax1X+pLr7kwrZAaquwThO6cde6USEm5YfTVokNS9W8k+37UL4LBeATkwAFwjyfIGqEyFnyTxnK/K8yGIHiXP me@LTT" > /home/pi/.ssh/authorized_keys | |
# set permissions | |
chown -R pi:pi /home/pi/.ssh | |
# get system up to date | |
apt-get -y update | |
apt-get -y upgrade | |
# install packages | |
apt-get -y install ntfs-3g nfs-kernel-server | |
# create mount point for the hdd | |
mkdir /hdd | |
chown pi:pi /hdd | |
# add the hdd to fstab | |
echo -e "/dev/sda1\t/hdd\tntfs-3g\trw,uid=1000,gid=1000\t0\t1" >> /etc/fstab | |
# mount the hdd | |
mount /hdd | |
# share the hdd over nfs | |
echo -e "/hdd\t$WOOLBIRD_IP(rw,sync,insecure,no_subtree_check,all_squash,anonuid=1000,anongid=1000)" > /etc/exports | |
# set hostname | |
echo $NEW_HOSTNAME > /etc/hostname | |
sed -i "s/127.0.1.1.*raspberrypi/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment