Files
start-os/build/write-image.sh
Aiden McClelland e6fb74a800 Feature/cloud backups (#889)
* cifs for cloud backups on lan

* password spelling fix

* fix spelling and fix rpc method

* fix other methods

* remove old code and rename method

* add support for cifs backup targets

wip

cifs api

simplify idiom

add doc comment

wip

wip

should work™

* add password hash to server info

* fix type

* fix types for cifs

* minor fixes for cifs feature

* fix rpc structure

* fix copy, address some TODOs

* add subcommand

* backup path and navigation

* wizard edits

* rebased success page

* wiz conflicts resolved

* current change actually

* only unsub if done

* no fileter if necessary

* fix copy for cifs old password

* setup complete (#913)

* setup complete

* minor fixes

* setup.complete

* complete bool

* setup-wizard: complete boolean

Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com>
Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
2022-01-21 20:35:52 -07:00

72 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
set -e
# Write contents of LOOPDEV (Ubuntu image) to sd card and make filesystems, then detach the loop device
echo USING $LOOPDEV TO IMAGE $OUTPUT_DEVICE
sudo dd if=${LOOPDEV}p1 of=${OUTPUT_DEVICE}p1 bs=4096 conv=fsync status=progress
sudo mkfs.vfat -F 32 ${OUTPUT_DEVICE}p2
sudo dd if=${LOOPDEV}p2 of=${OUTPUT_DEVICE}p3 bs=4096 conv=fsync status=progress
sudo mkfs.ext4 ${OUTPUT_DEVICE}p4
sudo losetup -d $LOOPDEV
# Label the filesystems
sudo fatlabel ${OUTPUT_DEVICE}p1 system-boot
sudo fatlabel ${OUTPUT_DEVICE}p2 EMBASSY
sudo e2label ${OUTPUT_DEVICE}p3 green
sudo e2label ${OUTPUT_DEVICE}p4 blue
# Mount the boot partition and config
mkdir -p /tmp/eos-mnt
sudo mount ${OUTPUT_DEVICE}p1 /tmp/eos-mnt
sudo sed -i 's/LABEL=writable/LABEL=green/g' /tmp/eos-mnt/cmdline.txt
# create a copy of the cmdline *without* the quirk string, so that it can be easily amended
sudo cp /tmp/eos-mnt/cmdline.txt /tmp/eos-mnt/cmdline.txt.orig
sudo sed -i 's/^/usb-storage.quirks=152d:0562:u /g' /tmp/eos-mnt/cmdline.txt
cat /tmp/eos-mnt/config.txt | grep -v "dtoverlay=" | sudo tee /tmp/eos-mnt/config.txt.tmp
echo "dtoverlay=pwm-2chan" | sudo tee -a /tmp/eos-mnt/config.txt.tmp
sudo mv /tmp/eos-mnt/config.txt.tmp /tmp/eos-mnt/config.txt
# Unmount the boot partition and mount embassy partition
sudo umount /tmp/eos-mnt
sudo mount ${OUTPUT_DEVICE}p2 /tmp/eos-mnt
sudo cp product_key.txt /tmp/eos-mnt
sudo umount /tmp/eos-mnt
sudo mount ${OUTPUT_DEVICE}p3 /tmp/eos-mnt
sudo mkdir /tmp/eos-mnt/media/boot-rw
sudo mkdir /tmp/eos-mnt/embassy-os
sudo cp build/fstab /tmp/eos-mnt/etc/fstab
# Enter the appmgr directory, copy over the built EmbassyOS binaries and systemd services, edit the nginx config, then create the .ssh directory
cd appmgr/
sudo cp target/aarch64-unknown-linux-gnu/release/embassy-init /tmp/eos-mnt/usr/local/bin
sudo cp target/aarch64-unknown-linux-gnu/release/embassyd /tmp/eos-mnt/usr/local/bin
sudo cp target/aarch64-unknown-linux-gnu/release/embassy-cli /tmp/eos-mnt/usr/local/bin
sudo cp *.service /tmp/eos-mnt/etc/systemd/system/
cd ..
# Copy system images
sudo mkdir -p /tmp/eos-mnt/var/lib/embassy/system-images
sudo cp system-images/**/*.tar /tmp/eos-mnt/var/lib/embassy/system-images
# after performing npm run build
sudo mkdir -p /tmp/eos-mnt/var/www/html
sudo cp -R ui/www /tmp/eos-mnt/var/www/html/main
sudo cp -R setup-wizard/www /tmp/eos-mnt/var/www/html/setup
sudo cp -R diagnostic-ui/www /tmp/eos-mnt/var/www/html/diagnostic
# Make the .ssh directory
sudo mkdir -p /tmp/eos-mnt/root/.ssh
sudo cp ./build/initialization.sh /tmp/eos-mnt/usr/local/bin
sudo cp ./build/initialization.service /tmp/eos-mnt/etc/systemd/system/initialization.service
sudo ln -s /etc/systemd/system/initialization.service /tmp/eos-mnt/etc/systemd/system/multi-user.target.wants/initialization.service
sudo umount /tmp/eos-mnt