From 20e1d72160f5289cc6d62f21578595da4ebc917e Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Mon, 2 Nov 2020 12:00:10 +0200 Subject: [PATCH] Fixed build sudo priviliges --- .gitignore | 3 ++- README.md | 4 +++- build.sh | 6 ++---- img-config.sh | 9 ++++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 03e40ae..166edd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /build/ parameters.env -*.img \ No newline at end of file +*.img +*.img.* diff --git a/README.md b/README.md index 3f4998c..2a8e953 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,10 @@ tar -xzvf build/rpi-cloud-init.tgz -C /mnt/rpi-boot Place a decompressed Ubuntu Server `*.img` file in the project directory and use `img-config.sh` to both build the project and dope the boot partition of `*.img` file directly +**Note**: Must be run from an account with `sudo` permissions + ```bash -sudo ./img-config.sh ubuntu-20.04.1-preinstalled-server-arm64+raspi.img +./img-config.sh ubuntu-20.04.1-preinstalled-server-arm64+raspi.img ``` ## Roadmap diff --git a/build.sh b/build.sh index 52e4263..7162b8f 100755 --- a/build.sh +++ b/build.sh @@ -16,9 +16,7 @@ $(cat src/user-data) ~" > build/cloud-init/user-data cp src/meta-data build/cloud-init/ -cp src/initial-setup.sh build/cloud-init/ -cp src/install-torch.sh build/cloud-init/ -cp src/torch-agent_0.0.4-1_all.deb build/cloud-init/ +cp src/*.sh build/cloud-init/ mkdir build/cloud-init/torch-config cp -r $TORCH_CONFIG_DIR/* build/cloud-init/torch-config/ @@ -26,4 +24,4 @@ cp -r $TORCH_CONFIG_DIR/* build/cloud-init/torch-config/ tar -C build -czvf build/rpi-cloud-init.tgz cmdline.txt cloud-init rm -rf build/cloud-init -rm build/cmdline.txt \ No newline at end of file +rm build/cmdline.txt diff --git a/img-config.sh b/img-config.sh index 8fcbfa5..b6ccdf0 100755 --- a/img-config.sh +++ b/img-config.sh @@ -1,12 +1,15 @@ #!/bin/bash +[ $# -eq 0 ] && { echo "Usage: $0 IMG_FILE"; exit 1; } + SECTOR_BYTES=512 SECTOR_START=2048 OFFSET=$(($SECTOR_BYTES*$SECTOR_START)) ./build.sh mkdir -p boot-part -mount -o rw,loop,offset=$OFFSET $1 ./boot-part +sudo mount -o rw,loop,offset=$OFFSET $1 ./boot-part tar -xzvf build/rpi-cloud-init.tgz -C boot-part -umount ./boot-part -rmdir ./boot-part \ No newline at end of file +sudo umount ./boot-part +rmdir ./boot-part +rm -rf ./build