geek rescue kit Code
Brought to you by:
ctaf
#!/bin/sh
## ct-installconf for ctafconf in /home/ctaf/.ctafconf
##
## Made by GESTES Cedric
## Login <ctaf@epita.fr>
##
## Started on Sun Oct 2 23:04:47 2005 GESTES Cedric
## Last update Thu Oct 13 04:46:45 2005 GESTES Cedric
##
#
# CTAFCONF INSTALLATION
#
date=`date "+%H%M%S-%d%m%Y"`
readparam=""
echo test_bob | read -e testbob >/dev/null 2>/dev/null;
if [ x$? = x0 ]; then
readparam="-e"
fi
conread ()
{
echo -n $2
read $readparam var
if [ x$var = xyes ] || [ x$var = xy ] || [ x$var = xY ] ; then
return 0
fi
return 1
}
dial=conread
# if which gdialog >/dev/null 2>/dev/null ; then
# dial=gdialog
# else if which kdialog >/dev/null 2>/dev/null ; then
# dial=kdialog
# else if which dialog >/dev/null 2>/dev/null ; then
# dial=dialog
# fi
# fi
# fi
if [ x$1 != x ]; then
dial=$1
fi
cd ~/
cttestlink ()
{
local src=$1
local dst=$2
if ! which file >/dev/null 2>/dev/null || ! [ "x`file -b $dst`" = "xsymbolic link to \`$src'" ] ; then
return 1
else
return 0
fi
}
#create a link
#ctlink src dst
ctlink ()
{
local src=$1
local dst=$2
if [ x$ctafconf_install_setronly = xyes ]; then
if [ -x $src ]; then
chmod 500 $src
else
chmod 400 $src
fi
fi
if ! which file >/dev/null 2>/dev/null || ! [ "x`file -b $dst`" = "xsymbolic link to \`$src'" ] ; then
rm -rf "$dst"-previous 2>/dev/null
cp $dst "$dst"-previous 2>/dev/null
mv $dst "$dst"-prev-"$date" 2>/dev/null
# echo "create link : $dst -> $src"
ln -s $src $dst
fi
}
ctsudolink ()
{
local src=$1
local dst=$2
if [ x$ctafconf_install_setronly = xyes ]; then
if [ -x $src ]; then
chmod 555 $src
else
chmod 444 $src
fi
fi
if ! [ "x`file -b $dst`" = "xsymbolic link to \`$src'" ] ; then
$ctafconf_sudo rm -rf "$dst"-previous 2>/dev/null
$ctafconf_sudo cp $dst "$dst"-previous 2>/dev/null
$ctafconf_sudo mv $dst "$dst"-prev-"$date" 2>/dev/null
# echo "create link : $dst -> $src"
$ctafconf_sudo ln -s $src $dst
fi
}
ctfile ()
{
local src=$1
local template=$2
if ! [ -f $src ]; then
cp $template $src
fi
}
#create a dir
ctdir ()
{
local src=$1
if ! [ -d $src ]; then
# echo "create directory:$src"
mkdir $src 2>/dev/null
fi
# rm -rf "$dst"-previous 2>/dev/null
# cp -r $src "$dst"-previous 2>/dev/null
# mv $src "$src"-prev-"$date" 2>/dev/null
}
gnomesettings ()
{
#setting background for gnome
wallpp=~/.ctafconf/share/wallpaper/$ctafconf_wallpaper
echo "Setting wallpaper for gnome: $ctafconf_wallpaper"
if which gconftool-2 > /dev/null 2> /dev/null ; then
gconftool-2 --type=string -s /desktop/gnome/background/picture_filename "$wallpp"
gconftool-2 --type=string -s /desktop/gnome/background/picture_options "stretched"
#metacity workspace
echo "Setting metacity workspace shortcut:"
echo "<Alt>F1 Workspace 1 <Alt>F2 Workspace 2"
echo "<Alt>F3 Workspace 3 <Alt>F4 Workspace 4"
gconftool-2 --type string --set /apps/metacity/global_keybindings/switch_to_workspace_1 "<Alt>F1"
gconftool-2 --type string --set /apps/metacity/global_keybindings/switch_to_workspace_2 "<Alt>F2"
gconftool-2 --type string --set /apps/metacity/global_keybindings/switch_to_workspace_3 "<Alt>F3"
gconftool-2 --type string --set /apps/metacity/global_keybindings/switch_to_workspace_4 "<Alt>F4"
#metacity window
echo "Setting metacity window shortcut:"
echo "<Control><Alt>f fullscreen <Control><Alt>m maximized"
echo "<Control><Alt>w move <Control><Alt>x resize"
gconftool-2 --type string --set /apps/metacity/window_keybindings/toggle_fullscreen "<Control><Alt>f"
gconftool-2 --type string --set /apps/metacity/window_keybindings/toggle_maximized "<Control><Alt>m"
gconftool-2 --type string --set /apps/metacity/window_keybindings/begin_move "<Control><Alt>w"
gconftool-2 --type string --set /apps/metacity/window_keybindings/begin_resize "<Control><Alt>x"
fi
}
##START
if ! [ -d ~/.ctafconf/ ] ; then
echo "Can't find ~/.ctafconf directory"
echo "Aborting, verify that you have untar the archive into your home directory"
exit
fi
#launch ct-profile to configure one profile
~/.ctafconf/bin/ct-profile
if ! [ -f ~/.ctafconf/user-profile ] ; then
echo "Can't find ~/.ctafconf/user-profile directory"
echo "Aborting, execute ct-profile, or relauch install"
exit
fi
. ~/.ctafconf/user-profile
#include .mine configuration file
ctafconf_install_setronly=yes
ctafconf_install_perm="a-w"
ctafconf_install_zsh=ask
ctafconf_install_ksh=ask
ctafconf_install_tcsh=ask
ctafconf_install_bash=ask
ctafconf_install_fluxbox=ask
ctafconf_install_emacs=ask
ctafconf_install_nano=ask
ctafconf_install_xbindkeys=ask
ctafconf_install_torsmo=ask
ctafconf_install_top=ask
ctafconf_install_gnomesetting=ask
ctafconf_install_gdmkdm=ask
ctafconf_install_xsession=ask
ctafconf_install_xinitrc=ask
if [ -f ~/.ctafconf/user-profile.mine ] ; then
. ~/.ctafconf/user-profile.mine
fi
#zsh
if ! cttestlink ~/.ctafconf/etc/zsh/zshrc ~/.zshrc || ! cttestlink ~/.ctafconf/etc/zsh/zshenv ~/.zshenv ; then
if [ x$ctafconf_install_zsh = xyes ] || ( [ x$ctafconf_install_zsh != xno ] && $dial --yesno "Install configuration for zsh (.zshrc, .zshenv) [y/N]?" 0 0); then
ctlink ~/.ctafconf/etc/zsh/zshrc ~/.zshrc
ctfile ~/.zshrc.mine ~/.ctafconf/share/mine/zshrc.mine
ctlink ~/.ctafconf/etc/zsh/zshenv ~/.zshenv
ctfile ~/.zshenv.mine ~/.ctafconf/share/mine/zshenv.mine
echo "Installing ctafconf for: zsh"
fi
fi
#bash (dont support ctafenv... need work.)
if ! cttestlink ~/.ctafconf/etc/bash/bashrc ~/.bashrc ; then
if [ x$ctafconf_install_bash = xyes ] || ( [ x$ctafconf_install_bash != xno ] && $dial --yesno "Install configuration for bash (.bashrc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/bash/bashrc ~/.bashrc
ctfile .bashrc.mine ~/.ctafconf/share/mine/bashrc.mine
echo "Installing ctafconf for: bash"
fi
fi
#ksh
if ! cttestlink ~/.ctafconf/etc/ksh/kshrc ~/.kshrc ; then
if [ x$ctafconf_install_ksh = xyes ] || ( [ x$ctafconf_install_ksh != xno ] && $dial --yesno "Install configuration for ksh (.kshrc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/ksh/kshrc ~/.kshrc
ctfile .kshrc.mine ~/.ctafconf/share/mine/kshrc.mine
echo "Installing ctafconf for: ksh"
fi
fi
#tcsh
if ! cttestlink ~/.ctafconf/etc/tcsh/tcshrc ~/.tcshrc ; then
if [ x$ctafconf_install_tcsh = xyes ] || ( [ x$ctafconf_install_tcsh != xno ] && $dial --yesno "Install configuration for tcsh (.tcshrc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/tcsh/tcshrc ~/.tcshrc
ctfile .tcshrc.mine ~/.ctafconf/share/mine/tcshrc.mine
echo "Installing ctafconf for: tcsh"
fi
fi
#fluxbox
if ! cttestlink ~/.ctafconf/etc/fluxbox/init ~/.fluxbox/init || ! cttestlink ~/.ctafconf/etc/fluxbox/keys ~/.fluxbox/keys || ! cttestlink ~/.ctafconf/etc/fluxbox/menu ~/.fluxbox/menu ; then
if [ x$ctafconf_install_fluxbox = xyes ] || ( [ x$ctafconf_install_fluxbox != xno ] && $dial --yesno "Install configuration for fluxbox (.fluxbox)[y/N]?" 0 0) ; then
ctdir ~/.fluxbox
ctlink ~/.ctafconf/etc/fluxbox/init ~/.fluxbox/init #globalconf
ctlink ~/.ctafconf/etc/fluxbox/keys ~/.fluxbox/keys #hotkey
ctlink ~/.ctafconf/etc/fluxbox/menu ~/.fluxbox/menu #menu
echo "Installing ctafconf for: fluxbox"
fi
fi
#top
if ! cttestlink ~/.ctafconf/etc/toprc ~/.toprc ; then
if [ x$ctafconf_install_top = xyes ] || ( [ x$ctafconf_install_top != xno ] && $dial --yesno "Install configuration for top (.toprc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/toprc ~/.toprc
echo "Installing ctafconf for: top"
fi
fi
#Torsmo
if ! cttestlink ~/.ctafconf/etc/torsmorc ~/.torsmorc ; then
if [ x$ctafconf_install_torsmo = xyes ] || ( [ x$ctafconf_install_torsmo != xno ] && $dial --yesno "Install configuration for torsmo (.torsmorc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/torsmorc ~/.torsmorc
echo "Installing ctafconf for: torsmo"
fi
fi
#Xbindkeys
if ! cttestlink ~/.ctafconf/etc/xbindkeysrc ~/.xbindkeysrc ; then
if [ x$ctafconf_install_xbindkeys = xyes ] || ( [ x$ctafconf_install_xbindkeys != xno ] && $dial --yesno "Install configuration for xbindkeys (.xbindkeysrc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/xbindkeysrc ~/.xbindkeysrc
echo "Installing ctafconf for: xbindkeys"
fi
fi
#emacs
if ! cttestlink ~/.ctafconf/etc/emacs/emacs ~/.emacs ; then
if [ x$ctafconf_install_emacs = xyes ] || ( [ x$ctafconf_install_emacs != xno ] && $dial --yesno "Install configuration for emacs (.emacs)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/emacs/emacs ~/.emacs
ctfile ~/.emacs.mine ~/.ctafconf/share/mine/emacs.mine
echo "Installing ctafconf for: emacs"
fi
fi
#nano
if ! cttestlink ~/.ctafconf/etc/nanorc ~/.nanorc ; then
if [ x$ctafconf_install_nano = xyes ] || ( [ x$ctafconf_install_nano != xno ] && $dial --yesno "Install configuration for nano (.nanorc)[y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/nanorc ~/.nanorc
echo "Installing ctafconf for: nano"
fi
fi
#ctafconf user profile
ctfile ~/.ctafconf/user-profile.mine ~/.ctafconf/share/mine/user-profile.mine
if ! cttestlink ~/.ctafconf/etc/xsession/xsession ~/.xsession ; then
if [ x$ctafconf_install_xsession = xyes ] || ( [ x$ctafconf_install_xsession != xno ] && $dial --yesno "Support xdm (~/.xsession) [y/N]?" 0 0) ; then
ctlink ~/.ctafconf/etc/xsession/xsession ~/.xsession
ctfile ~/.xsession.mine ~/.ctafconf/share/mine/xsession.mine
echo "Installing ctafconf for: xdm"
fi
fi
if ! cttestlink ~/.ctafconf/etc/xsession/xsession ~/.xinitrc ; then
if [ x$ctafconf_install_xinitrc = xyes ] || ( [ x$ctafconf_install_xinitrc != xno ] && $dial --yesno "Support startx(~/.xinitrc) [y/N]?" 0 0) ; then
#we reuse xsession, it's the same think
ctlink ~/.ctafconf/etc/xsession/xsession ~/.xinitrc
ctfile ~/.xsession.mine ~/.ctafconf/share/mine/xsession.mine
echo "Installing ctafconf for: startx"
fi
fi
if [ x$ctafconf_install_gdmkdm = xyes ] || ( [ x$ctafconf_install_gdmkdm != xno ] && $dial --yesno "Support gdm and kdm? The sudo command need to be set correctly. This make two symlinks: /usr/share/xsession/ctafconf.desktop and /usr/bin/ct-xsession. Support gdm and kdm [y/N]?" 0 0) ; then
ctsudolink ~/.ctafconf/etc/xsession/ctafconf.desktop /usr/share/xsession
ctsudolink ~/.ctafconf/bin/ct-xsession /usr/bin/ct-xsession
echo "Installing ctafconf for: gdm/kdm"
fi
#set default permission on ~/.ctafconf
#chmod -R $ctafconf_install_perm ~/.ctafconf/
#setting's for gnome
gnomesettings
echo "----------------------"
echo "installation successed"
echo "----------------------"
echo "You can put your own settings in :.emacs.mine, .zshrc.mine,"
echo " .zshenv.mine, .bashrc.mine, .tcshrc.mine, .xsession.mine"