This repository contains all scripts needed to create your very own BeeSlack. See https://hackaday.io/project/10145-backend-library-for-the-iot-bee-hive-monitor for a little more information...

MakeSdCardImage.sh 3.2KB

    #/bin/bash # BeeStalker (c) by Johann Wilhelm <johann.wilhelm@9mal6.de> # # BeeStalker is licensed under a # Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. # # You should have received a copy of the license along with this # work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>. # DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #Make a 512MB Image of our SD Card dd if=/dev/zero of=Card.img bs=1048576 count=1024 #do the partitioning... the comments are stripped sed -r -e 's/^\s+([\+0-9a-zA-Z]*)\s*#.*$/\1/' << EOF | fdisk Card.img o # clear the in memory partition table n # new partition p # primary partition 1 # partition number 1 # default - start at beginning of disk +128M # 128 MB boot partition n # new partition p # primary partition 2 # partion number 2 # default - start at beginning of disk +128M # 128 MB logging partition n # new partition p # primary partition 3 # partion number 2 # default, start immediately after preceding partition # default, extend partition to end of disk t # change the partition type 1 # bootable partition is partition 1 -- /dev/sda1 c # type is 0c => windows p # print the in-memory partition table w # write the partition table q # and we're done EOF #detach all loopback devices losetup -D losetup --show -f -P Card.img read -p " Last line should be /dev/loop0! Continue??? (ctrl-c to exit)" y #create the filesystems mkdosfs -F 16 -n BOOT /dev/loop0p1 mkfs.xfs -L Data /dev/loop0p2 mkfs.ext4 -L Root /dev/loop0p3 sudo tune2fs -c -1 -i 0 /dev/loop0p3 if [ -e FsRoot ]; then rm -R FsRoot fi mkdir FsRoot mount /dev/loop0p3 FsRoot #prepare the fs... #mkdir FsRoot/bin mkdir FsRoot/boot mount /dev/loop0p1 FsRoot/boot #mkdir FsRoot/dev #mkdir FsRoot/etc mkdir FsRoot/home #mkdir FsRoot/lib #mkdir FsRoot/media #mkdir FsRoot/mnt mkdir FsRoot/opt mkdir FsRoot/opt/BeeStalker #mkdir FsRoot/proc #mkdir FsRoot/root #mkdir FsRoot/run #mkdir FsRoot/sbin #mkdir FsRoot/srv #mkdir FsRoot/sys #mkdir FsRoot/tmp #mkdir FsRoot/usr mkdir FsRoot/var mkdir FsRoot/var/BeeStalkerData mount /dev/loop0p2 FsRoot/var/BeeStalkerData mkdir FsRoot/var/BeeStalkerData/Log cd FsRoot #install Slackware mini root fs... (see https://arm.slackware.com/installation/) tar -xapf ../slack-current-miniroot_28Mar16.tar.xz #install the RPi stuff... you find these packages at http://rpi.fatdog.eu/ #some of these have install-script which should run and others we do not actually want to run... tar -xap --exclude=install/* -f ../raspi-boot-fw-arm-1_30Mar15_fd.tgz installpkg --root $(pwd) ../kernel-modules-raspi-3.18.10-arm-1_30Mar15_fd.tgz tar -xap --exclude=install/* -f ../kernel_raspi-3.18.10-arm-1_30Mar15_fd.tgz installpkg --root $(pwd) ../raspi-hacks-2.0-arm-1_30Mar15_fd.tgz installpkg --root $(pwd) ../i2c-tools-3.1.0-arm-1_SBo_fd.tgz #change the user-stuff useradd -m -R "$(pwd)" beestalker chpasswd -R "$(pwd)" <../passwords.txt #install additional scripts cp -R ../Scripts/* . cd .. umount /dev/loop0p1 umount /dev/loop0p2 umount /dev/loop0p3 losetup -D # tar -cJf BeeStalkerSdCardImage$(date -I).tar.xz Card.img read -p " Copy to /dev/mmcblk0.... Continue??? (ctrl-c to exit)" y dd bs=1M if=Card.img of=/dev/mmcblk0