#!/bin/sh

#cp {etc/skel/,~/}.xinitrc

#:: database update :: 

#----------------------------------------------------------------------
# - configuration.sh

configuration(){

echo "copying skel files ..."
cp -r files/etc/skel /etc/

echo "
[archlinuxfr]
#Server = http://repo.archlinux.fr/x86_64
Server = http://repo.archlinux.fr/i686

" >> /etc/pacman.conf

pacman -Sy --noconfirm
pacman -Syu --noconfirm
pacman -Syy --noconfirm
	

pacman -S --noconfirm \
		sudo \
		yaourt pacman-color \
		shaman		
		
echo -n "# type a new user and press [ENTER]:"
read USER

echo "# Adding user $USER ..."
useradd -m -s /bin/bash $USER
passwd $USER
#usermod -G users,wheel,slocate,audio,optical,floppy,storage,video $USER
#usermod -G users,wheel,audio,optical,floppy,storage,video $USER
#adduser $USER admin

# other
#usermod -G users,wheel,slocate,audio,video,lp,floppy,optical,storage,scanner,power,log < nom_utilisateur >
#usermod -G users,wheel,audio,video,lp,floppy,optical,storage,scanner,power,log $USER

usermod -G users,vboxusers,abs,wheel,audio,video,lp,floppy,optical,storage,camera,scanner,power,log $USER


echo "Added user $USER"

echo "
$USER ALL=(ALL) ALL
$USER ALL=NOPASSWD: /usr/bin/pacman
$USER ALL=NOPASSWD: /usr/bin/pacdiffviewer

">> /etc/sudoers
echo "Adding $USER to sudoers"

#cf: http://wiki.archlinux.fr/man:archlinux:vim
echo "
###############################################################################
# opening /etc/yaourtrc...
#
# please uncheck :
#
# PacmanBin /usr/bin/pacman-color
#
# press [ENTER] to continue
###############################################################################
"
read choice

vi /etc/yaourtrc
}



#----------------------------------------------------------------------
# - Apps.sh
apps(){
pacman -S --noconfirm \
	bzip2 gzip unrar zip unzip lzop \
	transcode libtheora jasper codecs flac libdvdcss libdvdread xvidcore musepack-tools \
	firefox-fr thunderbird-i18n \
	opera pidgin \
	flashplugin codecs gecko-mediaplayer \
	mplayer mplayer-plugin mplayer-skins vlc \
	xine-ui libdvdcss \
	geany vim gvim gftp terminator \
    gedit gedit-plugins gedit-plugins-extra gnome-terminal \
    xfce4-panel \
    rhythmbox \
	wine virtualbox \
	lighttpd fcgi php
}

#----------------------------------------------------------------------
# - materiel.sh
materiel(){
pacman -S --noconfirm \
	xorg hwd \
	ttf-dejavu ttf-ms-fonts ttf-liberation \
	alsa-lib alsa-utils pciutils \
	hal dbus pulseaudio \
	openssh
		 
#hwd -xa

echo ""
echo "#copying and Installing hwd for xorg.conf"
X -configure
#Xorg --configure
mv /root/xorg.conf.new /etc/X11/xorg.conf

alsaconf

echo "
###############################################################################
# Si votre carte son n'est pas detectee
# taper
# alsamixer
# alsactl store
#
# ajouter le demon hal dans /etc/rc.conf : 
# DAEMONS=(syslog-ng network netfs crond @hal @alsa @sshd)
#
# Editez le fichier /etc/hosts.allow comme suit: 
#
# sshd: ALL
# ALL:ALL:DENY
#
# pour lancer le demon ssh
#
# /etc/rc.d/sshd start
#
# Si votre reseau fonctionne vous pouvez maintenant vous connecter a distance:
# ssh root@Adresse_IP_de_ma_super_install
###############################################################################
"
}

#----------------------------------------------------------------------
# - wm.sh
wm(){
pacman -S --noconfirm \
	wmii libxp dmenu plan9port dwm \
	openbox openbox-themes obconf lxappearance \
	conky transset obmenu pypanel adesklets idesk bbpager \
	gdm gdm-themes archlinux-themes-gdm xfce4 esd
    #xfce4-goodies gtk2-themes-collection \
    #gnome gnome-extra \
    #compiz compiz-fusion \
    #kde kde-extragear kde-l10n-fr \
		
echo "
###############################################################################
# do this as a regular user, not as root.
#------------------------------------------------------------------------------
# mkdir -p ~/.config/openbox/
# cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml
# cp /etc/xdg/openbox/menu.xml ~/.config/openbox/menu.xml

# http://icculus.org/openbox/index.php/Openbox:Themes
# http://www.box-look.org/content/show.php/1977+Openbox?content=69196
# http://www.box-look.org/content/show.php/Nova?content=60053
###############################################################################

# add to ~/.xinitrc
# exec gnome-session
# exec xfce4-session
# exec openbox-session

# rajouter dans /etc/rc.conf
les daemons : dbus hal fam pulseaudio
"
	
}


kdeMod(){

#Remove your existing KDE installation with
#	pacman -Rd kde
#-------------------------------------------------------------------------------
#as KDEmod conflicts with KDE from the official repos.
#You can check which KDE packages are already installed by entering
#	pacman -Q | grep kde
#-------------------------------------------------------------------------------





#-------------------------------------------------------------------------------

#(Trondheim / Norway / 1000Mbit)
#Server = http://kdemod.iskrembilen.com/core/i686

#(Stuttgart / Germany / 1000Mbit)
#Server = ftp://ftp.wh-stuttgart.net/kdemod/core/i686

#(Rochester / NY / USA / 200Mbit)
#Server = http://mirror.rit.edu/kdemod/core/i686

#(Frankfurt / Germany / 100Mbit)
#Server = http://chakra-project.org/repo/core/i686

#(Berlin / Germany / 2Mbit)
#Server = ftp://mirrors.igprolin-online.org/kdemod/core/i686

# Step 3 - Add the Repository
#-----------------------------------------
#
# You must also activate the [community] repository in pacman.conf because
# KDEmod needs some packages from this repository. 

echo "
[kdemod-core]
#Server = ftp://ftp.wh-stuttgart.net/kdemod/core/x86_64
Server = ftp://ftp.wh-stuttgart.net/kdemod/core/i686

[kdemod-extragear]
#Server = ftp://ftp.wh-stuttgart.net/kdemod/extragear/x86_64
Server = ftp://ftp.wh-stuttgart.net/kdemod/extragear/i686

[kdemod-playground]
#Server = ftp://ftp.wh-stuttgart.net/kdemod/playground/x86_64
Server = ftp://ftp.wh-stuttgart.net/kdemod/playground/i686

" >> /etc/pacman.conf

#-------------------------------------------------------------------------------


# Step 4 - Install it!
#-----------------------------------------

pacman -Sy
pacman -S kdemod
#pacman -S kdemod-complete

#-------------------------------------------------------------------------------


# Step 5 - Finishing touches
#-----------------------------------------
# Install your localization and any extra stuff. Simply do
#	pacman -Ss kdemod-kde-l10n
#to see a list of all available localizations and install yours afterwards.
#To see everything that is available in our repo, just do
#
#	pacman -Sl kdemod-core
#
#You can also install complete KDE modules.
#If you want to install the whole kdepim suite, just do
#
#	pacman -S kdemod-kdepim
#
#This works with every KDE module,
#e.g. kdemod-kdetoys, kdemod-kdegames et cetera, you get it... 


# Korganiser, KMail, etc
#	pacman -S kdemod-kdepim
#
#-------------------------------------------------------------------------------

# Step 6 - Not really a Step ...
#-----------------------------------------
# You can now enable your KDE installation either by uncommenting the startkde 
# entry in your .xinitrc or by adding the kdm entry to the daemons array in your
# /etc/rc.conf, or by modifying your /etc/inittab.


}

show_help(){
	echo "usage:"
	echo "sh $0 [ configuration | apps | materiel | yaourt | wm | kdemod | all | tips ]"
}

tips(){
echo "#rebuild the kernel"
echo "/sbin/mkinitcpio -k 2.6.29-ARCH -c /etc/mkinitcpio.conf -g /boot/kernel26.img"
echo "/sbin/mkinitcpio -k 2.6.29-ARCH -c /etc/mkinitcpio.conf -g /boot/kernel26-fallback.img -S autodetect"
}

    case $1 in
    
		configuration*)
			configuration
			;;
		apps*)
			apps
			;;
		materiel*)
			materiel
			;;
		wm*)
			wm
			;;
		yaourt*)
			yaourt -S prism-0.9 sqldeveloper php-xdebug
			;;
		
		kdemod*)
			kdeMod
			;;
			
		all*)
			materiel
			wm		
			apps
            configuration
			;;
			
		tips*)
			show_help
			;;
			
		--help*)
			tips
			;;
			
		*)
			show_help
			;;
    esac
        

# apps a lancer en user
#yaourt -S prism-0.9 sqldeveloper



