Files
MSYS2-packages/filesystem/profile

226 lines
7.5 KiB
Bash

# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# System-wide profile file
# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
# http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/
# Setup some default paths. Note that this order will allow user installed
# software to override 'system' software.
# Modifying these default path settings can be done in different ways.
# To learn more about startup files, refer to your shell's man page.
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man:${MANPATH}"
INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info:${INFOPATH}"
if [ -n "$MSYSTEM" ]
then
case "$MSYSTEM" in
MINGW32)
PATH="/mingw32/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="/mingw32/lib/pkgconfig"
MANPATH="/mingw32/share/man:${MANPATH}"
TERMINFO=/mingw32/share/terminfo:${TERMINFO}
;;
MINGW64)
PATH="/mingw64/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="/mingw64/lib/pkgconfig"
MANPATH="/mingw64/share/man:${MANPATH}"
TERMINFO=/mingw64/share/terminfo:${TERMINFO}
;;
MSYS)
PATH="${MSYS2_PATH}:/opt/bin:${PATH}"
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/lib/pkgconfig"
TERMINFO=/usr/share/terminfo
;;
*)
PATH="${MSYS2_PATH}:${PATH}"
;;
esac
else
PATH="${MSYS2_PATH}:${PATH}"
fi
MAYBE_FIRST_START=false
SYSCONFDIR="${SYSCONFDIR:=/etc}"
# TMP and TEMP as defined in the Windows environment must be kept
# for windows apps, even if started from msys2. However, leaving
# them set to the default Windows temporary directory or unset
# can have unexpected consequences for msys2 apps, so we define
# our own to match GNU/Linux behaviour.
ORIGINAL_TMP=$TMP
ORIGINAL_TEMP=$TEMP
unset TMP TEMP
tmp=$(cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
temp=$(cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
TMP="/tmp"
TEMP="/tmp"
# Define default printer
p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
read -r PRINTER < "${p}"
PRINTER=${PRINTER%%,*}
fi
unset p
print_flags ()
{
(( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
(( $1 & 0x0010 )) && echo -n ",exec"
(( $1 & 0x0040 )) && echo -n ",cygexec"
(( $1 & 0x0100 )) && echo -n ",notexec"
}
# Shell dependent settings
profile_d ()
{
local file=
for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
}
for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do
[ -e "${postinst}" ] && . "${postinst}"
done
if [ ! "x${BASH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
[ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
elif [ ! "x${KSH_VERSION}" = "x" ]; then
typeset -l HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d zsh
PS1='(%n@%m)[%h] %~ %% '
elif [ ! "x${POSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
PS1="$ "
else
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1="$ "
fi
export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP TERMINFO PRINTER HOSTNAME PS1 SHELL tmp temp
export TERM=xterm-256color
# Check to see if mkpasswd/mkgroup needs to be run try and cut down the emails
# about this on the lists!
#
# The following are the conditions under which the group name special cases
# will appear (where uid and gid are the effective user and group ids
# for the current user, and pgsid is the primary group associated with the
# SID for the current user):
# mkpasswd:
# gid is not in /etc/group
# uid is not in /etc/passwd
# passwd/group_GID_clash(<gid>/<pgsid>):
# gid is not in /etc/group
# uid is in /etc/passwd
# pgsid is in /etc/group (and does not match gid)
# mkgroup:
# gid is not in /etc/group
# uid is in /etc/passwd
# pgsid is not in /etc/group
#
# If this message keeps appearing and you are sure it's a mistake (ie, don't
# email about it!), comment out the test below.
case "$(id -ng)" in
mkpasswd )
echo "Your group is currently \"mkpasswd\". This indicates that your"
echo "gid is not in /etc/group and your uid is not in /etc/passwd."
echo
echo "The /etc/passwd (and possibly /etc/group) files should be rebuilt."
echo "See the man pages for mkpasswd and mkgroup then, for example, run"
echo
echo "mkpasswd -l [-d] > /etc/passwd"
echo "mkgroup -l [-d] > /etc/group"
echo
echo "Note that the -d switch is necessary for domain users."
;;
passwd/group_GID_clash* )
echo "Your group is currently \"passwd/group_GID_clash(gid/pgsid)\". This"
echo "indicates that your gid is not in /etc/group, but the pgsid (primary "
echo "group associated with your SID) is in /etc/group."
echo
echo "The /etc/passwd (and possibly /etc/group) files should be rebuilt."
echo "See the man pages for mkpasswd and mkgroup then, for example, run"
echo
echo "mkpasswd -l [-d] > /etc/passwd"
echo "mkgroup -l [-d] > /etc/group"
echo
echo "Note that the -d switch is necessary for domain users."
;;
mkgroup )
echo "Your group is currently \"mkgroup\". This indicates that neither"
echo "your gid nor your pgsid (primary group associated with your SID)"
echo "is in /etc/group."
echo
echo "The /etc/group (and possibly /etc/passwd) files should be rebuilt."
echo "See the man pages for mkpasswd and mkgroup then, for example, run"
echo
echo "mkpasswd -l [-d] > /etc/passwd"
echo "mkgroup -l [-d] > /etc/group"
echo
echo "Note that the -d switch is necessary for domain users."
;;
esac
if [ "$MAYBE_FIRST_START" = "true" ]; then
sh /usr/sbin/regen-info.sh
if [ -f "/usr/bin/update-ca-trust" ]
then
sh /usr/bin/update-ca-trust
fi
if [ -f "/usr/bin/xmlcatalog" ]
then
/usr/bin/mkdir -p /etc/xml
/usr/bin/xmlcatalog --noout --create /etc/xml/catalog
fi
if [ ! -d /etc/pacman.d/gnupg ]
then
/usr/bin/pacman-key --init
/usr/bin/pacman-key --populate msys2 || true
/usr/bin/pacman-key --refresh-keys || true
fi
clear
echo
echo
echo "###################################################################"
echo "# #"
echo "# #"
echo "# C A U T I O N #"
echo "# #"
echo "# This is first start of MSYS2. #"
echo "# You MUST restart shell to apply necessary actions. #"
echo "# #"
echo "# #"
echo "###################################################################"
echo
echo
fi
unset MAYBE_FIRST_START