# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).# If not running interactively, don't do anything[-z"$PS1"]&&return# don't put duplicate lines in the history. See bash(1) for more optionsexportHISTCONTROL=ignoredups
# check the window size after each command and, if necessary,# update the values of LINES and COLUMNS.shopt-scheckwinsize
# make less more friendly for non-text input files, see lesspipe(1)[-x/usr/bin/lesspipe]&&eval"$(lesspipe)"# Comment in the above and uncomment this below for a color promptPS1='\[\033[01;37m\][\[\033[01;32m\]`date +%D` \[\033[01;35m\]\t\[\033[01;37m\]] - \[\033[01;33m\][\w]\n\[\033[01;34m\]\u\[\033[01;31m\]@\[\033[01;34m\]\h\[\033[00m\] \[\033[01;31m\]\$\[\033[00;37m\] '######################################## Default Variables and Environnement ######################################### Uname systemexportMYSYSTEM=`uname`# Define PathPATH="/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin"FULLPATH=$PATH# Linuxif[$MYSYSTEM="Linux"];thenCORE_NUMBER=`grepprocessor/proc/cpuinfo|wc|awk'{ print $1 }'`RAM_INFO=`free-m|grep"Mem:"|awk'{ print $2 "Mo / Free :", $3"Mo" }'`fi# Solarisif[[$MYSYSTEM="SunOS"&&-d/usr/openwin/bin/]];thenPATH="$PATH:/usr/openwin/bin/:/usr/X11/bin:/opt/csw/bin"FULLPATH=$FULLPATH:$PATHCORE_NUMBER=`psrinfo|wc|awk'{ print $1 }'`RAM_MO=`echo"`vmstat | grep -v [a-z] | awk '{ print $5 }'`/1024"|bc`RAM_INFO=`echo`prtconf|grep"Memory size"|awk'{ print $3 }'`"Mo / Free : "$RAM_MOMo`fi# Cygwinif[$MYSYSTEM="CYGWIN*"];thenexportTERM=cygwin
elseexportTERM=xterm-color
fiexportPATH
usernames=($(cut-d:-f1/etc/passwd))groups=($(cut-d:-f1/etc/group))case"$TERM"inxterm*|rxvt|linux|cygwin);;*)nocolor=yes
;;esac# Set localesif[$MYSYSTEM="SunOS"];thenexportLANGUAGE=fr_FR.ISO8859-15
exportLC_ALL=fr_FR.ISO8859-15
exportLANG=fr_FR.ISO8859-15
elseexportLANGUAGE=fr_FR@euro
exportLC_ALL=fr_FR@euro
exportLANG=fr_FR@euro
fiexportLESSCHARSET=latin9
exportMINICOM="-c on"exportLESS="-S -g"GCHECK=60WATCHFMT="%n has %a %l from %M"# CVSexportCVS_RSH=/usr/bin/ssh
exportCVSROOT=:ext:user@host:/var/lib/cvs
# HistoryexportHISTSIZE=5000exportHISTFILE=$HOME/.bash_history
exportSAVEHIST=1# Defaut editorexportEDITOR=vim
exportLISTMAX=0# Use most if possibleif[[-x/usr/bin/most||-x/opt/local/bin/most]];thenexportPAGER=most
elseexportPAGER=more
fi################## Environnement ################### Usefull aliasaliasutar="tar -xvzf"alias..='cd ..'alias...='cd ../..'aliasuu='source /etc/profile &> /dev/null'# lsif[$MYSYSTEM="Linux"];thenaliasls='ls --color=auto'aliasl='ls --color=auto -lg'aliasll='ls --color=auto -lag | $PAGER'fi# Graphical User Informationsecho""echo" You're connected has $USER on $HOSTNAME machine."echo" Connected users : `who -q | grep "=" | awk -F'=' '{ print $2 }'`"echo" Host OS : $MYSYSTEM - `uname -m`"echo""echo" Host CPU Core(s) : $CORE_NUMBER"echo" Host RAM : Total : $RAM_INFO"# Personals mycompany users environnementsif[-d~/mycompany_bash];then# Generate a correct file in /tmp dirforpersonal_envin`ls~/mycompany_bash/`;do/etc/mycompany_skel/mycompany_alias_env.pl$personal_envdone# Load the environnement./tmp/$USER"_genprofil"||echo"Error while trying to load your personnal environnement"rm-f/tmp/$USER"_genprofil"else# Create the environnement for the new usercp-Rf/etc/skel/mycompany_bash~/mycompany_bash
chown-Rf$USER:Team~/mycompany_bash
fiif[$JAVA_HOME];thenexportPATH=$PATH_PERSO:$JAVA_HOME:$FULLPATHelseexportPATH=$PATH_PERSO:$FULLPATHfi# enable programmable completion features (you don't need to enable# this, if it's already enabled in /etc/bash.bashrc and /etc/profile# sources /etc/bash.bashrc).if[-f/etc/bash_completion];then./etc/bash_completion
fiumask022### Easier env, alias and path ScriptWiththisscript,userscouldhaveafoldercalledmycompany_bashwiththeirownaliases,envorpath.Theyonlyhavetoaddafileinthisfolderwhichshouldcontain:
-alias:foranaliasesfile
-env:foranenvironmentfile
-path:thepathfile
Thesyntaxonallthosefilesshouldbelike:
This will automatically create the correct path to JVM.
Now you need the following script for this syntax to be effective. Place it in `/etc/global_skel/global_alias_env.pl`:
```perl
#!/usr/bin/perl -w
# Made by Pierre Mavro
# Environnement charger for global users
use strict;
use Term::ANSIColor qw(:constants);
# Vars
my $file_to_analyse=$ARGV[0];
my $method;
my $mypath="";
my $counter=0;
# Function to check which type of file does it have to be treated
sub get_enval {
open FILER, "<$ENV{HOME}/mycompany_bash/$file_to_analyse" or die "Couln't open file : $!\n";
open FILEW, ">>/tmp/$ENV{USER}_genprofil" or die "Cannot create file on /tmp : $!";
while (<FILER>) {
if ($_ =~ /^(\w*)(\ |)\=(\ |)(.*)/) {
# Keep contents
my $first_arg=$1;
my $second_arg=$4;
# Alias
if ($method eq "alias") {
# Save alias in file
print FILEW "alias $1='$4'\n";
} elsif ($method eq "environnement") {
# Env + AutoPATH the JVM for export
if ($first_arg =~ /(jvm|jdk)/i) {
if ($second_arg =~ /(\d\.\d)\.(\d+)/) {
# Convert to the good format and save
printf FILEW "export JAVA_HOME='/test/jdk$1.0_%#02s'\n", $2;
} else {
die "Your JDK PATH is in a bad format, please contact ITs";
}
} else {
# Convert first arg to uppercase and save
print FILEW "export \U$first_arg\E=$second_arg\n";
}
} else {
# If not reconnized die
die "Problem on charging $method : $_\n";
}
} elsif ($method eq "path") {
chomp $_;
unless ($_ =~ /^#/) {
$mypath="$mypath:$_";
}
}
}
if ($method eq "path") {
print FILEW "PATH=$ENV{PATH}$mypath\n";
print FILEW "PATH_PERSO=$mypath\n";
}
close FILEW;
close FILER;
}
sub check_problems {
if ($file_to_analyse =~ /env/i) {
$counter++;
}
if ($file_to_analyse =~ /alias/i) {
$counter++;
}
if ($file_to_analyse =~ /path/i) {
$counter++;
}
# If more than one path/env/alias... don't analyse this file
if ($counter ne 1) {
print CLEAR, RED, "\nWARNING : there is a problem with your $file_to_analyse file. Can't reconize what kind of file it is. Please rename this file correctly.\n", RESET;
}
}
# Check for problems before starting
&check_problems;
# Alias
if ($file_to_analyse =~ /env/i) {
$method="environnement";
&get_enval;
# Environnement
} elsif ($file_to_analyse =~ /alias/i) {
$method="alias";
&get_enval;
# Path
} elsif ($file_to_analyse =~ /path/i) {
$method="path";
&get_enval;
}
## Personal Mycompany Aliases ##
#
# Purpose:
# This file contains your custom aliases,
# these little shorcuts that ease your life.
#
# Instructions:
# - If you want to put comments, add #
# - If you need to create aliases follow this example:
# myalias = command
# - Your first argument should only be written in lowercase !
#
# Your alias file can be updated with the "uu" command or relog yourself.
#
# If you need other aliases files, simply create in your ~/mycompany_bash directory
# a new file containing "alias" in its name.
#
# Examples :
# javav = java -version
# ll = ls -lah
#
## Personal Mycompany Environnement ##
#
# Purpose:
# This file contains your custom environment variables
# that can be used in your scripts or aliases
#
# One usefull behavior is to specify some predefined tokens like:
# JDK = 1.5.0_14
# that will automatically modify your path to add this JDK version and create JAVA_HOME variable.
#
# Instructions:
# - If you want to put comments, add #
# - If you need to create environment variables follow this example:
# NAME_OF_THE_VARIABLE = value
# - Your first argument (NAME_OF_THE_VARIABLE here) sould only be written in uppercase !
#
# Your environment file can be updated with the "uu" command or relog yourself.
#
# If you need other environment files, simply create in your ~/mycompany_bash directory,
# a new file containing "env" in its name.
#
# Examples :
# MY_ENV_TEST = test
# MY_ENV_TEST2 = $MY_ENV_TEST/test2
# DEV_DIR = ~/dev
# JDK = 1.5.0_14
#
## Personal Mycompany Path ##
#
# Purpose:
# This file contains your custom amendment to your PATH environment variable.
# It is used to add some directories in which binaries can be used everywhere
# without referencing the full path.
#
# Instructions :
# - If you want to put comments, add #
# - If you need to add directories to your path, just simply put them one by one (only one per line).
#
# Your path file can be updated with the "uu" command or relog yourself.
#
# If you need other path files, simply create in your ~/mycompany_bash directory
# a new file containing "path" in its name.
#
# Examples :
# /usr/bin
# /usr/sbin
#
For LDAP: If you want to run a solution on FreeBSD, you can look at pam_quota. Unfortunately, the developer didn't have time to create it for Linux. So we must find another way and look at session scripts: Pam-script Documentation.
LDAP
If you have an LDAP, we must take all users and create a home directory for each one of them and add quotas. That's why we will use PAM-script to do it automatically.
Once pam-script has been set up, please add these lines to the /etc/security/onsessionopen file:
#!/bin/sh# Made by Pierre Mavrosoft_limit=90M
hard_limit=100M
quota_folder=/home
userid=$1service=$2if[$userid!="root"];thenif[-x/usr/sbin/quotatool];then/usr/sbin/quotatool-u$userid-bq$soft_limit-l$hard_limit$quota_folderelseecho"/usr/sbin/quotatool doesn't exist. Can't set user quota"exit1fifi
You just need to set the 3 variables as you wish and it will automatically be applied at the next user connection.
PAM
If you have PAM and create your own users, just edit adduser.conf and configure this line:
#!/bin/sh# Set quotas for every users# Made by Pierre Mavro# Set soft limit (in Mo)soft_limit="90M"# Set hard limit (in Mo)hard_limit="100M"# Quota directoy (where users are located)home_users="/home"# Quotatool binaryquotatool_bin="/usr/sbin/quotatool"if[-x$quotatool_bin];thenforusernamein`ls$home_users|grep-vaquota.user`;doquotatool-u$username-bq$soft_limit-l$hard_limit$home_usersdoneelseecho"Sorry but couldn't locate or can't execute $quotatool_bin"exit1fi
Adapt this as you wish and add permissions to make it executable:
Edit the /etc/security/pam_mount.conf file and configure what you need. Here we would like users to have NFS home share mounted from the server at logon. Add this line at the end of the file: