[go: up one dir, main page]

Menu

[r1]: / bin / ct-profile  Maximize  Restore  History

Download this file

279 lines (255 with data), 7.6 kB

#!/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 Tue Oct  4 16:00:08 2005 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

#ctafconf user profile file (don't use quote to expand ~)
savefile=~/.ctafconf/user-profile

conread ()
{
     echo $2
     read var
     if [ x$var = xyes ]; 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

#date parameter for backupfile
#dateparam='+%Y%m%d-%H%M%S'

#show the ctafconf
showctafconf ()
{
  echo "--------------------------------------"
  echo "Your actual configuration:"
  echo "--------------------------------------"
  echo "login   : $ctafconf_login"
  echo "group   : $ctafconf_group"
  echo "name    : $ctafconf_name"
  echo "home    : $ctafconf_home"
  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 "--------------------------------------"
}

#show the new configuration
shownewconf()
{
  echo "--------------------------------------"
  echo "Your new configuration:"
  echo "--------------------------------------"
  echo "login   : $login"
  echo "group   : $group"
  echo "name    : $name"
  echo "home    : $home"
  echo "mail    : $mail"
  echo "config  : $config"
  echo "wallpp  : $wallpaper"
  echo "sudo    : $sudo"
  echo "zprompt : $zprompt"
  echo "wm      : $wm"
  echo "--------------------------------------"
}

#save the new configuration
savenewconf()
{
  if [ -f $savefile ]; then
      echo "storing your previous configuration"
      echo -"to: "$savefile"-previous"
      rm -rf $savefile-previous
      mv $savefile $savefile-previous
  fi
  echo "saving...."
  touch $savefile
  echo "#CTAFCONF user configuration file" > $savefile
  echo "#You can edit this file with: ct-profile" >> $savefile
  echo "" >> $savefile
  echo "ctafconf_login='$login'"  >> $savefile
  echo "ctafconf_group='$group'" >> $savefile
  echo "ctafconf_name='$name'" >> $savefile
  echo "ctafconf_home='$home'" >> $savefile
  echo "ctafconf_mail='$mail'" >> $savefile
  echo "ctafconf_config='$config'" >> $savefile
  echo "ctafconf_wallpaper='$wallpaper'" >> $savefile
  echo "ctafconf_sudo='$sudo'" >> $savefile
  echo "ctafconf_zprompt='$zprompt'" >> $savefile
  echo "ctafconf_wm='$wm'" >> $savefile

  echo "your new configuration has been saved"
  echo "you should LOGOUT to reload the new configuration"
}
#save the new configuration
savenewconfcsh()
{
  if [ -f $savefile ]; then
      echo "storing your previous configuration"
      echo -"to: "$savefile"-previous"
      rm -rf $savefile-previous
      mv $savefile $savefile-previous
  fi
  echo "saving...."
  touch $savefile
  echo "#CTAFCONF user configuration file" > $savefile
  echo "#this file is autogenerated by ct-profile" > $savefile
  echo "#DONT MODIFY use ct-profile" >> $savefile
  echo "" >> $savefile
  echo "set ctafconf_login='$login'"  >> $savefile
  echo "set ctafconf_group='$group'" >> $savefile
  echo "set ctafconf_name='$name'" >> $savefile
  echo "set ctafconf_home='$home'" >> $savefile
  echo "set ctafconf_mail='$mail'" >> $savefile
  echo "set ctafconf_config='$config'" >> $savefile
  echo "set ctafconf_wallpaper='$wallpaper'" >> $savefile
  echo "set ctafconf_sudo='$sudo'" >> $savefile
  echo "set ctafconf_zprompt='$zprompt'" >> $savefile
  echo "set ctafconf_wm='$wm'" >> $savefile

  echo "your new configuration has been saved"
  echo "you should LOGOUT to reload the new configuration"
}

##START##
if [ -f ~/.ctafconf/user-profile ]; then
  echo "you already have a configuration file"
  . ~/.ctafconf/user-profile
  showctafconf
  echo -n "Do you want to edit this configuration [y/N]? :"
  read $readparam yesno
  if [ x$yesno != xy ] && [ x$yesno != xY ] ; then
      exit
  fi
fi

echo "--------------------------------------"
echo -n "your system report your current unix login is: "
echo $USER
if [ "x$ctafconf_login" = x ]; then
  ctafconf_login=$USER
fi
echo -n "enter your Unix login [$ctafconf_login]:"
read $readparam login
if [ "x$login" = x ] ; then
  login=$ctafconf_login
fi

echo "--------------------------------------"
echo -n "your system report your current unix group is: "
echo $(id -g -n)
if [ "x$ctafconf_group" = x ]; then
  ctafconf_group=$(id -g -n)
fi
echo -n "enter your Unix group [$ctafconf_group]:"
read $readparam group
if [ "x$group" = x ] ; then
  group=$ctafconf_group
fi

echo "--------------------------------------"
echo -n "enter your complete Name [$ctafconf_name]:"
read $readparam name
if [ "x$name" = x ] ; then
  name=$ctafconf_name
fi

echo "--------------------------------------"
echo -n "enter your Unix Email [$ctafconf_mail]:"
read $readparam mail
if [ "x$mail" = x ] ; then
  mail=$ctafconf_mail
fi

echo "--------------------------------------"
echo -n "your system report your current home directory is: "
echo $HOME
if [ "x$ctafconf_home" = x ]; then
  ctafconf_home=$HOME
fi
echo "please don't finish with a backslash (/)"
echo "eg write: /home not /home/"
echo -n "set your home directory [$ctafconf_home]:"
read $readparam home
if [ "x$home" = x ] ; then
  home=$ctafconf_home
fi

echo "--------------------------------------"
echo "choose your wallpaper from the list (include .jpg in your answer):"
echo $(ls ~/.ctafconf/share/wallpaper)
if [ x$ctafconf_wallpaper = x ] ; then
    ctafconf_wallpaper='meuhh.jpg'
fi
echo -n "wallpaper [$ctafconf_wallpaper]:"
read $readparam wallpaper
if [ "x$wallpaper" = x ] ; then
  wallpaper=$ctafconf_wallpaper
fi

echo "--------------------------------------"
echo "enter your distribution (debian,gentoo,freebsd,epita,generic)"
echo "if you are under an unlisted distribution type in generic."
echo -n "distribution [$ctafconf_config]:"
read $readparam config
if [ "x$config" = x ] ; then
  config=$ctafconf_config
fi
if [ "x$config" = xgeneric ] ; then
  config=""
fi

echo "--------------------------------------"
echo "enter your sudo command (type empty to let it empty!!)"
echo "if you are root you should type empty"
echo -n "sudo command [$ctafconf_sudo]:"
read $readparam sudo
if [ "x$sudo" = x ] ; then
  sudo=$ctafconf_sudo
fi
if [ "x$sudo" = xempty ] ; then
  sudo=""
fi

echo "--------------------------------------"
echo "Choose your zshprompt, you can use my style: ctaf"
echo "or any others style from zsh (test with the prompt command):"
echo "adam1 adam2 bart zefram fade redhat suse walters"
echo "bigfade clint elite elite2 fire off olivier"
echo -n "zsh prompt style [$ctafconf_zprompt]:"
read $readparam zprompt
if [ "x$zprompt" = x ] ; then
  zprompt=$ctafconf_zprompt
fi

echo "--------------------------------------"
echo "Choose your wm from the list:"
echo "fluxbox gnome"
if [ x$ctafconf_wm = x ] ; then
  ctafconf_wm=fluxbox
fi
echo -n "wm [$ctafconf_wm]:"
read $readparam wm
if [ "x$wm" = x ] ; then
  wm=$ctafconf_wm
fi

shownewconf
echo "Save the configuration?"
echo "I will make a backup of your previous user-profile"
echo -n "Save (y/N)? :"
read $readparam yesno
if [ "x$yesno" = xy ] || [ "x$yesno" = xY ] ; then
    savenewconf
    savefile=$savefile".csh"
    savenewconfcsh
fi