#!/bin/bash # # create_folder.sh — Detect the current Linux distro and dispatch to the # matching distro-specific folder-creation script. # Usage: su -c "./create_folder.sh " or sudo ./create_folder.sh # # The distro-specific scripts (_create_folder_fedora.sh, _create_folder_ubuntu.sh) # are prefixed with an underscore so they don't clutter tab-completion for # "create_folder". # set -euo pipefail RED='\033[0;31m' NC='\033[0m' # No Color SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [[ ! -r /etc/os-release ]]; then echo -e "${RED}ERROR: Cannot detect distro (/etc/os-release not found).${NC}" >&2 exit 1 fi # shellcheck disable=SC1091 source /etc/os-release DISTRO_ID="${ID:-}" DISTRO_ID_LIKE="${ID_LIKE:-}" case "$DISTRO_ID $DISTRO_ID_LIKE" in *fedora*|*rhel*) TARGET="$SCRIPT_DIR/_create_folder_fedora.sh" ;; *ubuntu*|*debian*) TARGET="$SCRIPT_DIR/_create_folder_ubuntu.sh" ;; *) echo -e "${RED}ERROR: Unsupported distro '$DISTRO_ID' (ID_LIKE='$DISTRO_ID_LIKE').${NC}" >&2 exit 1 ;; esac if [[ ! -x "$TARGET" ]]; then echo -e "${RED}ERROR: Expected script not found or not executable: $TARGET${NC}" >&2 exit 1 fi exec "$TARGET" "$@"