From 868d362328447adc175bea1b6bf1cb049e4e75e4 Mon Sep 17 00:00:00 2001 From: Steve Atwell Date: Sat, 13 Jul 2024 10:11:56 -0700 Subject: [PATCH] Add ~/.local/bin to PATH. Python's pip and pipx put executable for user-installed modules into ~/.local/bin. Also the XDG basedir specification recommends adding it to PATH, so this may help more than just Python. Normally on Ubuntu, this is handled by the ~/.profile that's copied from /etc/skel. But since we don't have normal shell initialization, we need to add it to the PATH set in /etc/environment. --- linux/ubuntu/scripts/act.sh | 4 ++++ linux/ubuntu/scripts/runner.sh | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/linux/ubuntu/scripts/act.sh b/linux/ubuntu/scripts/act.sh index 08d33f4..cf624a7 100755 --- a/linux/ubuntu/scripts/act.sh +++ b/linux/ubuntu/scripts/act.sh @@ -166,6 +166,10 @@ for SCRIPT in "${scripts[@]}"; do "/imagegeneration/installers/${SCRIPT}.sh" done +printf "\n\tšŸ‹ Creating ~/.local/bin and adding to PATH šŸ‹\t\n" +mkdir -m 0755 -p "${HOME}/.local/bin" +sed "s|^PATH=|PATH=${HOME}/.local/bin:|mg" -i /etc/environment + printf "\n\tšŸ‹ Cleaning image šŸ‹\t\n" apt-get clean rm -rf /var/cache/* /var/log/* /var/lib/apt/lists/* /tmp/* || echo 'Failed to delete directories' diff --git a/linux/ubuntu/scripts/runner.sh b/linux/ubuntu/scripts/runner.sh index 7aefb5f..e83ff7d 100755 --- a/linux/ubuntu/scripts/runner.sh +++ b/linux/ubuntu/scripts/runner.sh @@ -41,6 +41,11 @@ mkdir -m 0700 -p "/home/${RUNNER}/.ssh" chmod 644 "/home/${RUNNER}/.ssh/known_hosts" chown -R "${RUNNER}":"${RUNNER}" "/home/${RUNNER}/.ssh" +mkdir -m 0755 -p "/home/${RUNNER}/.local/bin" +chown -R "${RUNNER}":"${RUNNER}" "/home/${RUNNER}/.local" +sed '/^PATH=/s,\([=:]\)/root/.local/bin\(:\|$\),\1,g' -i /etc/environment +sed "s,^PATH=,PATH=/home/${RUNNER}/.local/bin:," -i /etc/environment + . /etc/environment # Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?shellcheck(SC2140)