source: trunk/server/common/oursrc/accountadm/mbashrc @ 2740

Last change on this file since 2740 was 1565, checked in by geofft, 13 years ago
mbashrc: Replace su/sudo with shell functions giving nice errors (Trac: #115)
File size: 2.4 KB
Line 
1# System-wide .bashrc file for interactive bash(1) shells.
2
3. /etc/bashrc
4
5shopt -s checkwinsize
6
7# enable bash completion in interactive shells
8
9#if [ "$PS1" -a -f /etc/bash_completion ]; then
10#    . /etc/bash_completion
11#fi
12# ~/.bashrc: executed by bash(1) for non-login shells.
13
14export PS1='[\u@\h]:\w\$ '
15umask 022
16
17__scripts_print_root_message ()
18{
19    echo "ERROR: scripts.mit.edu is a shared server, and as such" >&2
20    echo "you do not have root access." >&2
21    echo " * If you want a package installed or a setting configured," >&2
22    echo "   contact us at scripts@mit.edu." >&2
23    echo " * If you're having trouble editing a file without 'sudo'," >&2
24    echo "   try logging out and making your change from Athena." >&2
25}
26
27__scripts_print_install_message ()
28{
29    echo "ERROR: scripts.mit.edu is a shared server, and as such" >&2
30    echo "you do not have root access. We are happy to install most" >&2
31    echo "packages upon request -- please contact us at scripts@mit.edu." >&2
32}
33
34__scripts_print_edit_message ()
35{
36    echo "ERROR: scripts.mit.edu is a shared server, and as such you" >&2
37    echo "do not have root access. You can make most changes to your" >&2
38    echo "account without root access; you may need to log out of scripts," >&2
39    echo "and use your Athena account to get full permissions in your locker." >&2
40    echo "If you're having trouble, contact us at scripts@mit.edu for help." >&2
41}
42
43
44su ()
45{
46    while [[ "$1" == -* ]]; do shift; done
47    if [ $# -eq 0 ] || [ "$1" = "root" ]; then
48        __scripts_print_root_message
49    else
50        echo "su is no longer supported on scripts.mit.edu. To access your" >&2
51        echo "group locker, run ssh $1@scripts.mit.edu from Athena." >&2
52    fi
53    return 1
54}
55
56sudo ()
57{
58    case "$1" in
59        apt-get|aptitude|yum|easy_install|gem|make|./setup.py)
60            __scripts_print_install_message ;;
61        emacs|vi|vim|nano|chown|rm|fs)
62            __scripts_print_edit_message ;;
63        *)
64            __scripts_print_root_message
65    esac
66    return 1
67}
68
69# You may uncomment the following lines if you want `ls' to be colorized:
70# export LS_OPTIONS='--color=auto'
71# eval `dircolors`
72# alias ls='ls $LS_OPTIONS'
73# alias ll='ls $LS_OPTIONS -l'
74# alias l='ls $LS_OPTIONS -lA'
75#
76# Some more alias to avoid making mistakes:
77# alias rm='rm -i'
78# alias cp='cp -i'
79# alias mv='mv -i'
80
81if [ -f ~/.bashrc.scripts ]; then
82        . ~/.bashrc.scripts
83fi
84
85if [ -d ~/web_scripts ]; then
86        cd ~/web_scripts
87fi
Note: See TracBrowser for help on using the repository browser.