photoprism/scripts/dist/install-bashrc.sh
Michael Mayer c9362a6720 Docker: Refine smaller-skeleton bashrc setup for all images #5154 #5155
Follow-up to the contributor change that moves shell customization out of
per-user home directories:

- Migrate the resolute, trixie, and questing (+ slim) dev images to the
  shared install-bashrc.sh; the shared create-users.sh now hands users a
  minimal skeleton, so images still writing to /etc/skel/.bashrc would
  otherwise lose their aliases and prompt.
- Restore export PATH="$PATH:$HOME/.local/bin" (needed for claude/gh) in
  the full dev images by writing it to /etc/bash.bashrc; kept out of the
  slim and production images, which never had it.
- Guard the /etc/skel/.config copy in create-users.sh so production images
  without it don't emit a spurious error, and use rm -f /root/.bashrc.
- Fix the install-bashrc.sh header reference and silence an intentional
  SC2016 on the runtime-expanded PS1.
2026-07-10 00:56:15 +02:00

29 lines
923 B
Bash
Executable file

#!/usr/bin/env bash
# Adds shell aliases and a custom prompt to /etc/bash.bashrc:
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-bashrc.sh)
# Abort if not executed as root.
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
exit 1
fi
set -e
echo "Add ll alias and custom prompt in /etc/bash.bashrc"
echo 'alias ll="ls -alh"' >> /etc/bash.bashrc
# shellcheck disable=SC2016 # $DOCKER_TAG is expanded at shell runtime, not here.
echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/bash.bashrc
echo "Add alias of go to richgo if it's available"
# Source: https://stackoverflow.com/questions/592620/how-can-i-check-if-a-program-exists-from-a-bash-script/677212#677212
if command -v richgo >/dev/null 2>&1; then
echo 'alias go=richgo' >> /etc/bash.bashrc
fi
echo "Remove the unnecessary custom .bashrc for the root user"
rm -f /root/.bashrc