From 2af88f34a45ca71f5901face30236c74e77873b5 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Thu, 7 Aug 2008 13:40:32 +0200 Subject: [PATCH] Initial import into GIT repository. --- Makefile | 23 ++++++++ install.sh | 53 +++++++++++++++++ sys/bashrc | 113 ++++++++++++++++++++++++++++++++++++ sys/profile | 145 ++++++++++++++++++++++++++++++++++++++++++++++ user/bash_logout | 22 +++++++ user/bash_profile | 25 ++++++++ user/bashrc | 48 +++++++++++++++ 7 files changed, 429 insertions(+) create mode 100644 Makefile create mode 100755 install.sh create mode 100644 sys/bashrc create mode 100644 sys/profile create mode 100644 user/bash_logout create mode 100644 user/bash_profile create mode 100644 user/bashrc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e76ad87 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +# +# ConfigScripts - Makefile +# Written by Alexander Barton . Public Domain. +# + +NAME=ConfigScripts + +all: + +install: + sh ./install.sh + +clean: + +check: + +dist: clean + tar cvzf $(NAME).tar.gz \ + --exclude ".git" --exclude "*.tar.gz" --exclude "*.tgz" \ + --exclude "._*" --exclude "*~" --exclude "*.bak" \ + ../`basename $$PWD` + +# -eof- diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..62e695e --- /dev/null +++ b/install.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# ConfigScripts - install.sh +# Written by Alexander Barton . Public Domain. +# + +NAME=`basename "$0"` + +Abort() { + echo "- ERROR!" + exit 1 +} + +Copy_File() { + src="$1"; dst="$2"; own="$3"; perm="$4" + echo " $src -> $dst\c" + grep "alex@barton.de" "$dst" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo " (B)\c" + cp "$dst" "$dst.bak" + fi + echo " \c" + cp "$src" "$dst" || Abort + [ -n "$own" ] && chown "$own" "$dst" || Abort + [ -n "$perm" ] && chmod "$perm" "$dst" || Abort + echo "- OK." +} + +echo "Running $NAME ..." + +if [ "$UID" -eq 0 ]; then + echo "Starting system configuration:" + echo " - bash shell:" + if [ -e /etc/bash.bashrc ]; then + Copy_File sys/bashrc /etc/bash.bashrc root 644 + else + Copy_File sys/bashrc /etc/bashrc root 644 + fi + Copy_File sys/profile /etc/profile root 644 +else + echo "Not running with root privileges - system configuration SKIPPED." +fi + +user=`basename "$HOME"` +echo "Starting user configuration ($user in $HOME):" +echo " - bash shell:" +Copy_File user/bash_profile "$HOME/.bash_profile" "$user" 600 +Copy_File user/bashrc "$HOME/.bashrc" "$user" 600 +Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600 + +echo "$NAME: Done." + +# -eof- diff --git a/sys/bashrc b/sys/bashrc new file mode 100644 index 0000000..12f1941 --- /dev/null +++ b/sys/bashrc @@ -0,0 +1,113 @@ +# +# /etc/bash.bashrc: System-wide rc file for interactive bash(1) shells. +# +# 2008-08-07, alex@barton.de +# - ls: Detech BSD color support (-G). +# - Support /etc/chroot_name +# 2008-07-09, alex@barton.de +# - Added support for /usr/lib/command-not-found. +# 2008-06-06, alex@barton.de +# - Source /etc/[bash].bashrc.local as well, if readable. +# 2007-04-05, alex@barton.de +# - Define shell functions sshtmp() and sshnew(). +# 2006-01-04, alex@barton.de +# - Only call dircolors(1) and lesspipe(1) if they are available. +# - Check wether ls(1) knows something about "--color". +# 2005-12-29, alex@barton.de +# - Enabled bash completion +# 2004-09-13, alex@Arthur.Ath.CX +# - Made script more generic ... +# 2004-05-27, alex@Arthur.Ath.CX +# + +#echo "/etc/bash.bashrc ..." +BASHRCREAD="true" + +[ -z "$PROFILEREAD" -a -r /etc/profile ] && source /etc/profile + +# Interactive shell? +if [ ! "$PS1" ]; then + [ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc + return +fi + +# Shell options +shopt -s checkwinsize +shopt -s cdspell +shopt -s histappend +set mark-directories on +set mark-symlinked-directories on +HISTCONTROL=ignoredups + +# Shell functions +sshnew() { + ssh -o "StrictHostKeyChecking no" "$@" +} +sshtmp() { + ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" "$@" +} + +# Shell prompt +prefix="${chroot_name:+($chroot_name)}" +[ "$UID" -eq 0 ] \ + && PS1="${prefix}\h:\w \\\$ " \ + || PS1="${prefix}\u@\h:\w \\\$ " + +# Enable bash completion, if available +[ -r /etc/bash_completion ] && source /etc/bash_completion + +# If the command-not-found package is installed, use it +if [ -x /usr/lib/command-not-found ]; then + function command_not_found_handle { + # Check because c-n-f could've been removed in the meantime + if [ -x /usr/lib/command-not-found ]; then + /usr/bin/python /usr/lib/command-not-found -- $1 + return $? + else + return 127 + fi + } +fi + +# Common command aliases +alias ","="clear && logout" +alias ".."="cd .." +alias "ls"="ls -F" +alias "ll"="ls -l" +alias "l"="ll -a" +alias "lasth"="last | head -n \`expr \\\$LINES - 2\`" + +# less filter +type -p lesspipe >/dev/null 2>&1 && eval `lesspipe` + +# Enable color support of ls and also add handy aliases +if [ "$TERM" != "dumb" ]; then + type -p dircolors >/dev/null 2>&1 && eval `dircolors -b` + ls --color / >/dev/null 2>&1 + if [ $? -eq 0 ]; then + # "GNU style" + alias ls="ls --color=auto -F" + else + ls -G / >/dev/null 2>&1 + if [ $? -eq 0 ]; then + # "BSD style" + alias ls="ls -FG" + fi + fi +fi + +# If this is an xterm set the title to user@host:dir +case $TERM in +xterm*|rxvt|screen) + PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' + ;; +*) + ;; +esac + +# Source local files, if readable +[ -r "/etc/bashrc.local" ] && source /etc/bashrc.local +[ -r "/etc/bash.bashrc.local" ] && source /etc/bash.bashrc.local +[ -r "/var/lib/$ME/bash.bashrc" ] && source /var/lib/$ME/bash.bashrc + +# -eof- diff --git a/sys/profile b/sys/profile new file mode 100644 index 0000000..77b7c31 --- /dev/null +++ b/sys/profile @@ -0,0 +1,145 @@ +# +# /etc/profile: system-wide profile for the Bourne shell (sh(1)) and +# Bourne compatible shells (bash(1), ksh(1), ash(1), ...). +# +# 2008-08-07, alex@barton.de +# - Added support for /etc/profile.d +# - Added support for /etc/chroot_name +# - Restructure PATH and MANPATH detecttion. +# - Add ~/Applications to PATH. +# - Add generic chroot name check. +# - Check if debian_chroot is readable (insted of if it exists). +# - Fix quota check, don't use full path name +# 2007-10-28, alex@barton.de +# - Look for /usr/libexec/path_helper, used by Mac OS X 10.5 +# 2007-04-05, alex@barton.de +# - Check for and read /etc/bashrc as well, if /etc/bash.bashrc doesn't exist +# 2006-01-04, alex@barton.de +# - Use "hostname -s" (not "--short") for compatibility to [Net]BSD. +# - Added /usr/pkg/bin to optional PATH components. +# 2005-04-23, alex@Arthur.Ath.CX +# - Removed umask, we do use the system default now. +# 2005-02-19, alex@Arthur.Ath.CX +# - Removed export of CVS_RSH and MANWIDTH: use /etc/environment! +# 2005-02-04, alex@Arthur.Ath.CX +# - Added export of CVS_RSH. +# - Added export of MANWIDTH=80. +# 2005-01-23, alex@Arthur.Ath.CX +# - Added check for quotas +# 2004-09-13, alex@Arthur.Ath.CX +# - I made this script more generic, so that it is usabe for other systems +# than Arthur as well: read in local profile from /var/lib/$ME/profile +# after the initialization done in here. +# - Changed shell prompt to generic version using "<" and ">". +# - Make sure that $ME is set, even when not running interactive. +# 2004-08-11, alex@Arthur.Ath.CX +# - Make sure that $USER is set. +# - Always export $UID and $USER variables. +# 2004-07-30, alex@Arthur.Ath.CX +# - Make sure $UID is set. +# - Let ksh read in "/etc/ksh.kshrc". +# 2004-05-20, alex@Arthur.Ath.CX +# - Added support for "$debian_chroot" +# 2004-02-16, alex@Arthur.Ath.CX +# - Removed test for old home directory. +# 2004-02-02, alex@Arthur.Ath.CX +# - Added scan for optional PATH elements. +# 2003-12-18, alex@Arthur.Ath.CX +# - Initial version. +# + +#echo "/etc/profile ..." +PROFILEREAD="true" +export PROFILEREAD + +# Initialize PATH variable +export PATH MANPATH +if [ -x /usr/libexec/path_helper ]; then + PATH=""; MANPATH="" + eval `/usr/libexec/path_helper -s` +else + PATH="/usr/local/bin:/usr/bin:/bin" + [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH" +fi +# prepend optional directories to PATH ... +path="" +for d in /usr/pkg/bin /opt/*/bin; do + [ -d "$d" -o -h "$d" ] && path="$path$d:" +done +[ -n "$path" ] && PATH="$path$PATH" +if [ "$UID" -eq 0 ]; then + path="" + for d in /usr/pkg/sbin /opt/*/sbin; do + [ -d "$d" -o -h "$d" ] && path="$path$d:" + done + [ -n "$path" ] && PATH="$path$PATH" +fi +# append optional directories to PATH ... +for d in /usr/bin/X11 /usr/games; do + [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d" +done +# set PATH so it includes user's private executables +[ -d ~/Applications ] && PATH=~/Applications:"${PATH}" +[ -d ~/bin ] && PATH=~/bin:"${PATH}" +[ -d ~/sbin ] && PATH=~/sbin:"${PATH}" + +# set MANPATH so it includes user's private man files +if [ -n "$MANPATH" ]; then + path="" + for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do + [ -d "$d" -o -h "$d" ] && path="$path$d:" + done + [ -n "$path" ] && MANPATH="$path$MANPATH" +fi +[ -d ~/man ] && MANPATH=~/man:"${MANPATH}" +[ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}" + +# set variable identifying the chroot you work in +[ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot) +[ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name) + +# validate terminal definition +[ -z "$TERM" ] && eval `tset -s -Q` + +# make sure $UID and $USER is set +[ -z "$UID" ] && UID=`id -u` +[ -z "$USER" ] && USER=`id -un` +export UID USER + +# get my own hostname +ME=`hostname -s` +export ME + +# read profile additions +if [ -d /etc/profile.d ]; then + for f in /etc/profile.d/*; do + [ -r "$f" ] && . "$f" + done +fi + +# read local profile, if available +[ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile + +# interactive shell? +[ "$PS1" ] || return + +# generic shell prompt +[ "$UID" -eq 0 ] \ + && PS1="<$ME> # " \ + || PS1="<$ME> \$ " + +# bash-specific initialization +[ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \ + && source /etc/bash.bashrc +[ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \ + && source /etc/bashrc + +# ksh-specific initialization +[ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \ + && . /etc/ksh.kshrc + +# Check quotas +which quota >/dev/null 2>&1 +[ $? -eq 0 ] && quota -q + +# -eof- diff --git a/user/bash_logout b/user/bash_logout new file mode 100644 index 0000000..a9766fd --- /dev/null +++ b/user/bash_logout @@ -0,0 +1,22 @@ +# +# ~/.bash_logout +# +# 2008-08-07, alex@barton.de +# - Show message of "ssh-agent -k" +# - Clear screen if last shell on local console. +# 2003-07-13, alex@barton.de +# - Initial version. +# + +# clean up SSH agents +[ $SSH_AGENT_PID ] && eval `ssh-agent -k` + +case `tty` in +/dev/tty[0-9]*) + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console --quiet || clear + ;; +*) + echo "Bye, bye, $USER!"; echo +esac + +# -eof- diff --git a/user/bash_profile b/user/bash_profile new file mode 100644 index 0000000..78edb07 --- /dev/null +++ b/user/bash_profile @@ -0,0 +1,25 @@ +# +# ~/.bash_profile: executed by bash(1) for login shells. +# +# 2008-08-07, alex@barton.de +# - Code cleanup +# 2006-01-09, alex@barton.de +# - moved export's here. +# 2003-07-06, alex@Arthur.Ath.CX +# - initial version. +# + +export LANG="de_DE.ISO8859-1" +export LC_MESSAGES="C" +export EMAIL="alex@barton.de" +export WWW_HOME="http://barton.de/" +export NNTPSERVER="news.individual.de" +export CVS_RSH=ssh + +[ "$OSTYPE" != "Aux" ] && ulimit -c 2048 + +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# -eof- diff --git a/user/bashrc b/user/bashrc new file mode 100644 index 0000000..81638e6 --- /dev/null +++ b/user/bashrc @@ -0,0 +1,48 @@ +# +# ~/.bashrc: executed by bash(1) for non-login shells. +# +# 2008-08-07, alex@barton.de +# - Code cleanup, moved parts to /etc/[bash.]bashrc +# 2006-01-08, alex@barton.de +# - Initial version. +# + +[ -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] && source /etc/bash.bashrc +[ -z "$BASHRCREAD" -a -r /etc/bashrc ] && source /etc/bashrc + +# aptitude +type -p aptitude >/dev/null 2>&1 +[ $? -eq 0 ] && alias aptitude="LC_ALL=C sudo aptitude" + +# btdownload +type -p btdownloadcurses >/dev/null 2>&1 +[ $? -eq 0 ] && alias "btdownloadcurses"="btdownloadcurses --max_upload_rate 16" + +# ccache +[ -d "/usr/lib/ccache" ] && PATH="/usr/lib/ccache:$PATH" + +# dpkg-buildpackage +type -p dpkg-buildpackage >/dev/null 2>&1 +[ $? -eq 0 ] && alias dpkg-buildpackage="dpkg-buildpackage -kC24A0F637E364856" + +# gitk +type -p gitk >/dev/null 2>&1 +[ $? -eq 0 ] && alias gitk="gitk 2>/dev/null" + +# screen +type -p screen >/dev/null 2>&1 +if [ $? -eq 0 ]; then + alias "s"="screen" + alias "sr"="screen -dr" + alias "sx"="screen -x" + type -p irssi >/dev/null 2>&1 + [ $? -eq 0 ] && alias "si"="screen irssi" +fi + +# slrn +type -p cleanscore >/dev/null 2>&1 +[ $? -eq 0 ] && alias slrn="cleanscore -f ~/.slrnscore && slrn" + +alias pingblack="ssh gw1-0.fr.pingnet.de sudo blacklist" + +# -eof- -- 2.39.2