Ignore:
Timestamp:
May 27, 2010, 5:08:19 AM (15 years ago)
Author:
geofft
Message:
mbashrc: Replace su/sudo with shell functions giving nice errors (Trac: #115)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/accountadm/mbashrc

    r561 r1565  
    1515umask 022
    1616
    17 alias su='echo "Instead of running su USERNAME, ssh USERNAME@scripts.mit.edu from Athena" #'
     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}
    1868
    1969# You may uncomment the following lines if you want `ls' to be colorized:
Note: See TracChangeset for help on using the changeset viewer.