Skip to content

Commit

Permalink
Merge pull request #14 from benhylau/postboot-dpkg
Browse files Browse the repository at this point in the history
Postboot dpkg
  • Loading branch information
benhylau authored Dec 17, 2018
2 parents a4c396c + 2e0d962 commit 0c66ea1
Show file tree
Hide file tree
Showing 133 changed files with 161 additions and 32 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@ _You may optionally use a Raspberry Pi 2 instead of a Raspberry Pi 3. In that ca
Software
--------

1. From [**Releases**](https://github.com/benhylau/mesh-workshop/releases), download `raspberrypi3-<version>_mesh-workshop.img`, then flash the image onto an SD card with a tool like [Etcher](https://etcher.io).
1. Download the [latest mesh-orange release](https://github.com/benhylau/mesh-router-builder/releases/latest) of `raspberrypi3-<version>_default.img`, then flash the image onto an SD card with a tool like [Etcher](https://etcher.io).

>This image is a custom flavour of [mesh-orange](https://github.com/tomeshnet/mesh-orange) built using [mesh-router-builder](https://github.com/benhylau/mesh-router-builder) with the `mesh-workshop` profile, where the [cjdns](https://github.com/cjdelisle/cjdns) and [yggdrasil](https://github.com/Arceliar/yggdrasil-go/) mesh routers are pre-installed along with other tools required for this workshop.
2. Download the [latest mesh-workshop release](https://github.com/benhylau/mesh-workshop/releases/latest) and unpack it. Mount the FAT partition of the SD card you flashed in the previous step, then use the tool `mesh-workshop` to install workshop files on each node:

2. From the same [**Releases**](https://github.com/benhylau/mesh-workshop/releases) page, download one of `confd-<version>.tar.gz` and `confd-<version>.zip`, which are archives containing the 40 unique host configurations. Mount the FAT partition of the SD card you flashed in the previous step, then copy from `output/conf.d/<hostname>/*` to the `conf.d/` on the SD card root.
$ ./mesh-workshop
Usage: mesh-workshop confpath nodename
Example: mesh-workshop /Volumes/BOOT/conf.d/ bloor

For example, on Mac OS:

$ cp -r output/conf.d/bloor/* /Volumes/BOOT/conf.d/

Now you have configured the node with hostname `bloor`.

>If you wish to build these per-node host configurations yourself, clone this repository and run `./build` to generate 40 unique host configurations under `output/`.
The example shows a path to your SD card on Mac OS, your local path may differ. The command installs node profile and workshop files to the SD card `conf.d` for the node with hostname `bloor`.


What does it do?
Expand Down
21 changes: 11 additions & 10 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ hostno=0
for hostname in "${HOSTNAMES[@]}"; do
((hostno++))

mkdir -p output/conf.d/$hostname/home output/etc/$hostname
mkdir -p output/custom/conf.d/$hostname output/custom/etc/$hostname

# Create 30-mesh-workshop.tar.gz that will be extracted into /etc
cp -r src/etc/* output/etc/$hostname/
find output/etc/$hostname -type f -exec awk -i inplace "{ gsub(/__HOSTNAME__/, \"$hostname\") }; { print }" {} +
find output/etc/$hostname -type f -exec awk -i inplace "{ gsub(/__HOSTNO__/, \"$hostno\") }; { print }" {} +
tar --create --gzip -f output/conf.d/$hostname/30-mesh-workshop.tar.gz -C output/etc/$hostname .
cp -r src/custom/etc/* output/custom/etc/$hostname/
find output/custom/etc/$hostname -type f -exec awk -i inplace "{ gsub(/__HOSTNAME__/, \"$hostname\") }; { print }" {} +
find output/custom/etc/$hostname -type f -exec awk -i inplace "{ gsub(/__HOSTNO__/, \"$hostno\") }; { print }" {} +
tar --create --gzip -f output/custom/conf.d/$hostname/30-mesh-workshop.tar.gz -C output/custom/etc/$hostname .
done

# Copy sh scripts
cp src/sh/* output/conf.d/$hostname/
# Copy shared files for all nodes
mkdir -p output/shared/conf.d
cp -r src/shared/* output/shared/conf.d/

# Copy home directory
cp -r src/home/* output/conf.d/$hostname/home/
done
# Copy node installer tool
cp src/mesh-workshop output/
6 changes: 3 additions & 3 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Package assets for release
#

RELEASE_VERSION=0.3
RELEASE_VERSION=0.4

./build

Expand All @@ -12,5 +12,5 @@ rm -rf publish
mkdir publish

# Package assets in tar.gz and zip formats
tar --create --gzip -f "publish/confd-${RELEASE_VERSION}.tar.gz" -C output conf.d
cd output; zip --recurse-paths "../publish/confd-${RELEASE_VERSION}.zip" conf.d; cd ..
tar --create --gzip -f "publish/mesh-workshop-${RELEASE_VERSION}.tar.gz" -C output .
cd output; zip --recurse-paths "../publish/mesh-workshop-${RELEASE_VERSION}.zip" .; cd ..
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions src/custom/etc/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh -e

# Install local debian packages
sh /root/scripts/install-packages.sh

# Start system services
sh /root/scripts/start-services.sh

exit 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions src/mesh-workshop
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Tool to configure mesh-workshop node
#

set -e

confpath=$1
nodename=$2

HOSTNAMES=(bathurst bayview bloor broadview chester christie college coxwell davisville donlands dufferin dundas dupont eglinton ellesmere finch greenwood islington jane keele kennedy king kipling lawrence leslie midland museum osgoode ossington pape queen rosedale runnymede spadina summerhill union warden wilson woodbine yorkdale)

# Check required inputs
if [ "$confpath" == '' ] || [ "$nodename" == '' ]; then
echo 'Usage: mesh-workshop confpath nodename'
echo 'Example: mesh-workshop /Volumes/BOOT/conf.d/ bloor'
exit 1
fi

# Make sure the path to conf.d contains conf.d
echo "$confpath" | grep -E 'conf.d/?$' 1>/dev/null
ret=$?
if [ $ret != 0 ]; then
echo 'The path to conf.d must end with conf.d'
exit 1
fi

# Make sure the node name is valid
ret=1
for hostname in "${HOSTNAMES[@]}"; do
if [ "$hostname" == "$nodename" ]; then
ret=0
break
fi
done
if [ $ret != 0 ]; then
echo "Node name must match one of:"
echo "${HOSTNAMES[@]}"
exit 1
fi

# Install files on node
cp -r shared/conf.d/* "$confpath"
cp -r custom/conf.d/$nodename/*.tar.gz "$confpath"
echo "Installed node profile $nodename to $confpath"
2 changes: 0 additions & 2 deletions src/sh/25-tools.sh

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Create file system node from mmcblk0 device
grep -w 'mmcblk0' /proc/partitions | while read major minor size name; do
mknod /dev/$name b $major $minor >>/var/log/30-swap-filesystem.log 2>&1
mknod /dev/$name b $major $minor >>/var/log/10-swap-filesystem.log 2>&1
done

# Create an additional 6G partition on the sdcard
Expand All @@ -14,19 +14,19 @@ done

echo /dev/mmcblk0p1 : start= 2048, size= 2048000, type=6, bootable
echo /dev/mmcblk0p2 : start= 2050048, size= 12288000, type=83
} | sfdisk --no-reread /dev/mmcblk0 >>/var/log/30-swap-filesystem.log 2>&1
} | sfdisk --no-reread /dev/mmcblk0 >>/var/log/10-swap-filesystem.log 2>&1

# Tell kernel the sdcard partitions have been updated
partx --update /dev/mmcblk0 >>/var/log/30-swap-filesystem.log 2>&1
partx --update /dev/mmcblk0 >>/var/log/10-swap-filesystem.log 2>&1

# Create file system node from mmcblk0p2 partition
grep -w 'mmcblk0p2' /proc/partitions | while read major minor size name; do
mknod /dev/$name b $major $minor >>/var/log/30-swap-filesystem.log 2>&1
mknod /dev/$name b $major $minor >>/var/log/10-swap-filesystem.log 2>&1
done

# Use mmcblk0p2 partition as swap memory
mkswap /dev/mmcblk0p2 >>/var/log/30-swap-filesystem.log 2>&1
swapon /dev/mmcblk0p2 >>/var/log/30-swap-filesystem.log 2>&1
mkswap /dev/mmcblk0p2 >>/var/log/10-swap-filesystem.log 2>&1
swapon /dev/mmcblk0p2 >>/var/log/10-swap-filesystem.log 2>&1

# Use the swap memory to back the ramdisk file system
mount -o remount,size=6000000k,nr_inodes=2000000 / >>/var/log/30-swap-filesystem.log 2>&1
mount -o remount,size=6000000k,nr_inodes=2000000 / >>/var/log/10-swap-filesystem.log 2>&1
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions src/shared/deb/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# To generate this list of .deb packages, these commands need to be run in an
# Internet-connected workshop node with an empty local deb directory

# TODO: This process should be moved to CI, but the commands currently need
# to be run from armhf architecture and in the mesh-orange environment, the
# same is true for docker containers, final artifacts should be in release
# artifacts and not committed to git

# Make directory to keep the downloaded .deb packages
mkdir ~/deb

# Download general packages needed for workshop
apt update
apt clean
apt install --allow-unauthenticated --download-only --yes \
avahi-daemon \
bwm-ng \
ca-certificates \
curl \
iperf3 \
iputils-ping \
libnss-mdns \
nano-tiny \
netcat
cp /var/cache/apt/archives/*.deb deb/

# Download packages that will become installed in the next step, but we need
# their .deb packages, so we download them first
apt clean
apt install --allow-unauthenticated --download-only --yes \
libcurl3-gnutls \
libltdl7
cp /var/cache/apt/archives/*.deb deb/

# Download docker from its own debian source
apt install --allow-unauthenticated --yes \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
echo "deb [arch=armhf] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | \
tee /etc/apt/sources.list.d/docker.list
apt update
apt clean
apt install --allow-unauthenticated --download-only --yes docker-ce
cp /var/cache/apt/archives/*.deb deb/

# Download mesh router packages
(cd deb && curl --location --remote-name https://github.com/benhylau/mesh-router-builder/releases/download/v0.10/cjdns_20.2-0.10_armhf.deb)
(cd deb && curl --location --remote-name https://github.com/benhylau/mesh-router-builder/releases/download/v0.10/yggdrasil-go_0.3.0-0.10_armhf.deb)

# If packages are missing dependencies this command could be helpful
#apt install --download-only --fix-broken --yes
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/avahi-daemon_0.6.32-2_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/binutils_2.28-5_armhf.deb
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file added src/shared/deb/cgroupfs-mount_1.3_all.deb
Binary file not shown.
Binary file added src/shared/deb/cjdns_20.2-0.10_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/containerd.io_1.2.0-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/cpp_4%3a6.3.0-4_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/curl_7.52.1-5+deb9u8_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/dbus_1.10.26-0+deb9u1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/dkms_2.3-2_all.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/fakeroot_1.21-3.1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/gcc-6_6.3.0-18+deb9u1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/gcc_4%3a6.3.0-4_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/geoip-database_20170512-1_all.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/git_1%3a2.11.0-3+deb9u4_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/iperf3_3.1.3-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/less_481-2.1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libcc1-0_6.3.0-18+deb9u1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libdaemon0_0.14-6_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/liberror-perl_0.17024-1_all.deb
Binary file not shown.
Binary file added src/shared/deb/libexpat1_2.2.0-2+deb9u1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libfakeroot_1.21-3.1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libffi6_3.2.1-6_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libgdbm3_1.8.3-14_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libgeoip1_1.6.9-4_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libgomp1_6.3.0-18+deb9u1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libhogweed4_3.3-1+b2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libicu57_57.1-6+deb9u2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libidn2-0_0.16-1+deb9u1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libiperf0_3.1.3-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libisl15_0.18-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libltdl7_2.4.6-2_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libmpc3_1.0.3-1+b2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libmpfr4_3.1.5-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libnfnetlink0_1.0.1-3_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libnghttp2-14_1.18.1-1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libnss-mdns_0.10-8_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libp11-kit0_0.23.3-2_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libpopt0_1.16-10+b2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libpsl5_0.17.0-3_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/libslang2_2.3.1-5_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/libssh2-1_1.7.0-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/linux-libc-dev_4.9.130-2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/make_4.1-9.1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/manpages-dev_4.10-2_all.deb
Binary file not shown.
Binary file added src/shared/deb/manpages_4.10-2_all.deb
Binary file not shown.
Binary file added src/shared/deb/nano-tiny_2.7.4-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/netcat_1.10-41_all.deb
Binary file not shown.
Binary file added src/shared/deb/openssl_1.1.0f-3+deb9u2_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/patch_2.7.5-1+deb9u1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/perl_5.24.1-3+deb9u4_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/pigz_2.3.4-1_armhf.deb
Binary file not shown.
Binary file not shown.
Binary file added src/shared/deb/rename_0.20-4_all.deb
Binary file not shown.
Binary file added src/shared/deb/rsync_3.1.2-1+deb9u1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/sgml-base_1.29_all.deb
Binary file not shown.
Binary file added src/shared/deb/sudo_1.8.19p1-2.1_armhf.deb
Binary file not shown.
Binary file added src/shared/deb/xml-core_0.17_all.deb
Binary file not shown.
Binary file added src/shared/deb/yggdrasil-go_0.3.0-0.10_armhf.deb
Binary file not shown.
Binary file added src/shared/docker/tomeshnet-ipfs-0.1.tar
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/shared/home/scripts/install-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mount /dev/mmcblk0p1 /mnt

# Install local debian packages
dpkg --install /mnt/conf.d/deb/*.deb

umount /mnt
9 changes: 9 additions & 0 deletions src/shared/home/scripts/start-ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mount /dev/mmcblk0p1 /mnt

# Load ipfs docker archive
docker load --input /mnt/conf.d/docker/tomeshnet-ipfs-0.1.tar

# Start ipfs docker container
docker run --name ipfs --network host --detach tomeshnet/ipfs:0.1

umount /mnt
9 changes: 9 additions & 0 deletions src/shared/home/scripts/start-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reload systemd manager configuration
systemctl daemon-reload

# Start mesh services
systemctl start cjdns
systemctl start yggdrasil

# Start mdns service
systemctl start avahi-daemon
File renamed without changes.
File renamed without changes.

0 comments on commit 0c66ea1

Please sign in to comment.