From d8787ee10e5f7500eddca05391142f3d8c7023ca Mon Sep 17 00:00:00 2001 From: Nathan Mutin <32647745+nathanmutin@users.noreply.github.com> Date: Mon, 29 Jul 2019 17:55:54 +0200 Subject: [PATCH] Add stage3 - Install libnss-mdns package - Sudo without password - Add and enable vision service --- scripts/common | 2 +- stage3/00-install-packages/00-packages | 1 + stage3/01-sudo-without-passwd/00-run.sh | 4 ++++ stage3/02-add-vision-service/00-run.sh | 12 ++++++++++++ stage3/02-add-vision-service/files/vision.service | 11 +++++++++++ stage3/prerun.sh | 5 +++++ 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 stage3/00-install-packages/00-packages create mode 100644 stage3/01-sudo-without-passwd/00-run.sh create mode 100644 stage3/02-add-vision-service/00-run.sh create mode 100644 stage3/02-add-vision-service/files/vision.service create mode 100644 stage3/prerun.sh diff --git a/scripts/common b/scripts/common index f264755..96f657e 100644 --- a/scripts/common +++ b/scripts/common @@ -96,7 +96,7 @@ export -f on_chroot update_issue() { local GIT_HASH GIT_HASH=$(git rev-parse HEAD) - echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" + echo -e "${IMG_NAME} built on ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" } export -f update_issue diff --git a/stage3/00-install-packages/00-packages b/stage3/00-install-packages/00-packages new file mode 100644 index 0000000..475e6e3 --- /dev/null +++ b/stage3/00-install-packages/00-packages @@ -0,0 +1 @@ +libnss-mdns \ No newline at end of file diff --git a/stage3/01-sudo-without-passwd/00-run.sh b/stage3/01-sudo-without-passwd/00-run.sh new file mode 100644 index 0000000..3560871 --- /dev/null +++ b/stage3/01-sudo-without-passwd/00-run.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +# Enable password-less sudo for everyone +echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> "${ROOTFS_DIR}/etc/sudoers" \ No newline at end of file diff --git a/stage3/02-add-vision-service/00-run.sh b/stage3/02-add-vision-service/00-run.sh new file mode 100644 index 0000000..6e3dc7b --- /dev/null +++ b/stage3/02-add-vision-service/00-run.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e + +# Install the service so the system can run it +install -m 755 files/vision.service "${ROOTFS_DIR}/etc/systemd/system" + +on_chroot << EOF +# Reload the system services +sudo systemctl daemon-reload + +# Enable our vision service on startup +sudo systemctl enable vision +EOF diff --git a/stage3/02-add-vision-service/files/vision.service b/stage3/02-add-vision-service/files/vision.service new file mode 100644 index 0000000..dc892c5 --- /dev/null +++ b/stage3/02-add-vision-service/files/vision.service @@ -0,0 +1,11 @@ +[Unit] +Description=FRC Vision Service + +[Service] +Type=simple +Restart=always +ExecStart=/home/vision/visionProgram +WorkingDirectory=/home/vision + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/stage3/prerun.sh b/stage3/prerun.sh new file mode 100644 index 0000000..9acd13c --- /dev/null +++ b/stage3/prerun.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +if [ ! -d "${ROOTFS_DIR}" ]; then + copy_previous +fi