common.sh 843 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. set -e
  3. CYAN='\E[1;36m'
  4. BLUE='\E[1;34m'
  5. YELLOW='\E[1;33m'
  6. RED='\E[1;31m'
  7. RESET='\E[0m'
  8. export CYAN BLUE YELLOW RED RESET
  9. PUID=${PUID:-0}
  10. PGID=${PGID:-0}
  11. if [[ "$PUID" -ne '0' ]] && [ "$PGID" = '0' ]; then
  12. # set group id to same as user id,
  13. # the user probably forgot to specify the group id and
  14. # it would be rediculous to intentionally use the root group
  15. # for a non-root user
  16. PGID=$PUID
  17. fi
  18. export PUID PGID
  19. log_info () {
  20. echo -e "${BLUE}❯ ${CYAN}$1${RESET}"
  21. }
  22. log_error () {
  23. echo -e "${RED}❯ $1${RESET}"
  24. }
  25. # The `run` file will only execute 1 line so this helps keep things
  26. # logically separated
  27. log_fatal () {
  28. echo -e "${RED}--------------------------------------${RESET}"
  29. echo -e "${RED}ERROR: $1${RESET}"
  30. echo -e "${RED}--------------------------------------${RESET}"
  31. /run/s6/basedir/bin/halt
  32. exit 1
  33. }