geek rescue kit Code
Brought to you by:
ctaf
#!/bin/sh
## ct-profile.sh for ct-profile in /home/ctaf/.ctafconf/bin
##
## Made by GESTES Cedric
## Login <ctaf@epita.fr>
##
## Started on Sun Sep 25 21:51:34 2005 GESTES Cedric
## Last update Thu Apr 20 23:00:07 2006 GESTES Cedric
##
##CTAFCONF
#parameter for read
# readparam=""
# echo test_bob | read -e testbob >/dev/null 2>/dev/null;
# if [ x$? = x0 ]; then
# readparam="-e"
# fi
#we use ssft
#catch a signal, else termcaps shit
_trap_kill ()
{
echo killing
exit 0
}
trap _trap_kill INT
export SSFT_FRONTEND="text"
. ~/.ctafconf/etc/shlib/ssft.sh
#ctafconf user profile file (don't use quote to expand ~)
savefile=~/.ctafconf/perso/user-profile
bakfile=~/.ctafconf/perso/previous/user-profile
showconf()
{
echo "name : $ctafconf_name"
echo "mail : $ctafconf_mail"
echo "config : $ctafconf_config"
echo "wallpp : $ctafconf_wallpaper"
echo "sudo : $ctafconf_sudo"
echo "zprompt : $ctafconf_zprompt"
echo "wm : $ctafconf_wm"
echo "interface : $ctafconf_interface"
}
#show the ctafconf
showctafconf ()
{
# echo "--------------------------------------"
echo "Your actual configuration:"
echo "--------------------------------------"
showconf
echo "--------------------------------------"
echo "Do you want to edit this configuration?"
}
#show the new configuration
shownewconf()
{
# echo "--------------------------------------"
echo "Your new configuration:"
echo "--------------------------------------"
showconf
echo "--------------------------------------"
echo "I will backup your previous configuration in .ctafconf/perso/previous/user-profile"
echo "Save the new configuration?"
}
#enum all wallpaper
enumwallpp()
{
ls -1 ~/.ctafconf/etc/wallpaper 2>/dev/null | while read line; do
echo -n "$line"/
done
ls -1 ~/.ctafconf/perso/wallpaper 2>/dev/null | while read line; do
echo -n "$line"/
done
}
#save the new configuration
savectafconf()
{
local setcmd
setcmd=$1
if [ -f $savefile ]; then
echo "storing your previous configuration"
echo -"to: $bakfile-previous"
rm -rf $bakfile-previous
mv $savefile $bakfile-previous
fi
echo "saving...."
touch $savefile
if [ x$setcmd = x ]; then
echo "#!/bin/sh" > $savefile
else
echo "#!/bin/csh" > $savefile
fi
echo "#CTAFCONF user configuration file" >> $savefile
echo "#this file is autogenerated by ct-profile" >> $savefile
echo "#You can edit this file with: ct-profile" >> $savefile
echo "" >> $savefile
echo "$setcmd ctafconf_name='$ctafconf_name'" >> $savefile
echo "$setcmd ctafconf_mail='$ctafconf_mail'" >> $savefile
echo "$setcmd ctafconf_config='$ctafconf_config'" >> $savefile
echo "$setcmd ctafconf_wallpaper='$ctafconf_wallpaper'" >> $savefile
echo "$setcmd ctafconf_sudo='$ctafconf_sudo'" >> $savefile
echo "$setcmd ctafconf_zprompt='$ctafconf_zprompt'" >> $savefile
echo "$setcmd ctafconf_wm='$ctafconf_wm'" >> $savefile
echo "$setcmd ctafconf_interface='$ctafconf_interface'" >> $savefile
echo "your new configuration has been saved"
echo "you should LOGOUT to reload the new configuration"
}
#return val if set, or default
getvaldef()
{
local val
local def
val=$1
def=$2
if [ "x$val" = x ] ; then
echo $def
else
echo $val
fi
}
##START##
if [ -f ~/.ctafconf/perso/user-profile ]; then
. ~/.ctafconf/perso/user-profile
fi
export SSFT_FRONTEND=$(getvaldef "$ctafconf_interface" "text")
echo "using frontend: $SSFT_FRONTEND, you could change it with ct-profile"
if [ -f ~/.ctafconf/perso/user-profile ]; then
SSFT_DEFAULT=no
if ! ssft_yesno "you already have a configuration file" "`showctafconf`"; then
#sourced or standalone
return 2>/dev/null
exit 0
fi
fi
ctafconf_interface=$(getvaldef "$ctafconf_interface" "text")
SSFT_DEFAULT=$ctafconf_interface
if ssft_select_single "Interface for the ctafconf" "choose a graphic one from 'zenity'(gnome) or 'kdialog'(kde) or choose a console one from 'dialog' (ncurse) or 'text'. I recommand 'DIALOG'" zenity kdialog dialog text; then
ctafconf_interface=$(getvaldef "$SSFT_RESULT" "$ctafconf_interface")
fi
export SSFT_FRONTEND=$ctafconf_interface
SSFT_DEFAULT=$ctafconf_name
if ssft_read_string "Complete Name" "enter your complete Name"; then
ctafconf_name=$(getvaldef "$SSFT_RESULT" "$ctafconf_name")
fi
SSFT_DEFAULT=$ctafconf_mail
if ssft_read_string "Unix Email" "enter your Unix Email"; then
ctafconf_mail=$(getvaldef "$SSFT_RESULT" "$ctafconf_mail")
fi
echo `enumwallpp`
ancIFS=$IFS
IFS="/"
ctafconf_wallpaper=$(getvaldef "$ctafconf_wallpaper" 'ctafconf-psycho.jpg' )
SSFT_DEFAULT=$ctafconf_wallpaper
if ssft_select_single "Wallpaper" "choose your wallpaper from the list" `enumwallpp`; then
ctafconf_wallpaper=$(getvaldef "$SSFT_RESULT" "$ctafconf_wallpaper" )
fi
IFS=$ancIFS
SSFT_DEFAULT=$ctafconf_config
if ssft_select_single "Distribution" "Choose your distribution" debian gentoo freebsd epita other; then
ctafconf_config=$(getvaldef "$SSFT_RESULT" "$ctafconf_config")
if [ "x$ctafconf_config" = xother ] ; then
ctafconf_config=""
fi
fi
SSFT_DEFAULT=$ctafconf_sudo
if ssft_select_single "sudo command" "Choose your sudo command, choose empty if your are root, or if you don't want to install the ctafconf for gdm/kdm" "empty" "sudo" "su root -c"; then
ctafconf_sudo=$(getvaldef "$SSFT_RESULT" "$ctafconf_sudo" )
if [ "x$ctafconf_sudo" = xempty ] ; then
ctafconf_sudo=""
fi
fi
ctafconf_zprompt=$(getvaldef "$ctafconf_zprompt" 'ctaf' )
SSFT_DEFAULT=$ctafconf_zprompt
if ssft_select_single "Zsh prompt" "Choose your zshprompt (another may be available (test with prompt command in zsh)" ctaf adam1 adam2 bart zefram fade redhat suse walters bigfade clint elite elite2 fire off olivier; then
ctafconf_zprompt=$(getvaldef "$SSFT_RESULT" "$ctafconf_zprompt" )
fi
ctafconf_wm=$(getvaldef "$ctafconf_wm" 'fluxbox' )
SSFT_DEFAULT=$ctafconf_wm
if ssft_select_single "Window Manager" "Choose your wm from the list" fluxbox gnome kde xfce4 e16 term; then
ctafconf_wm=$(getvaldef "$SSFT_RESULT" "$ctafconf_wm" )
fi
if ssft_yesno "Save your settings" "`shownewconf`"; then
savectafconf
savefile=$savefile".csh"
bakfile=$bakfile".csh"
savectafconf "set"
fi