From 550eca8782625f832ed0ba7b9f58c6c47eb9c3c6 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Mon, 18 Dec 2023 09:03:41 +0000 Subject: [PATCH 1/2] Set owner of config file during install --- .gitignore | 4 +++- cmd/install | 4 ++++ make/DEBIAN/postinst | 36 ------------------------------------ 3 files changed, 7 insertions(+), 37 deletions(-) delete mode 100755 make/DEBIAN/postinst diff --git a/.gitignore b/.gitignore index 3f944ba34..bf3d0c7d1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ pylint.out __pycache__/ build/ testing/unit_test/temp/ -*.deb \ No newline at end of file +*.deb + +make/DEBIAN/postinst \ No newline at end of file diff --git a/cmd/install b/cmd/install index 0b6ac92de..027558b19 100755 --- a/cmd/install +++ b/cmd/install @@ -28,6 +28,10 @@ pip3 install -r framework/requirements.txt # Copy the default configuration cp -n local/system.json.example local/system.json +# Set file permissions +USER_NAME=$(logname) +sudo chown "$USER_NAME" local/system.json + deactivate # Build docker images diff --git a/make/DEBIAN/postinst b/make/DEBIAN/postinst deleted file mode 100755 index 0b6ac92de..000000000 --- a/make/DEBIAN/postinst +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -e - -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo Installing application dependencies - -TESTRUN_DIR=/usr/local/testrun -cd $TESTRUN_DIR - -python3 -m venv venv - -source venv/bin/activate - -pip3 install -r framework/requirements.txt - -# Copy the default configuration -cp -n local/system.json.example local/system.json - -deactivate - -# Build docker images -sudo cmd/build - -echo Finished installing Testrun From b687b819ebd25f72550c56c43a5de9d03ca3f570 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Tue, 2 Jan 2024 14:18:12 +0000 Subject: [PATCH 2/2] Check if logname works --- cmd/install | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/install b/cmd/install index 027558b19..c4f53b905 100755 --- a/cmd/install +++ b/cmd/install @@ -29,8 +29,11 @@ pip3 install -r framework/requirements.txt cp -n local/system.json.example local/system.json # Set file permissions -USER_NAME=$(logname) -sudo chown "$USER_NAME" local/system.json +# This does not work on GitHub actions +if logname ; then + USER_NAME=$(logname) + sudo chown "$USER_NAME" local/system.json +fi deactivate