All pastes #284910 Raw Edit

daqsdqsd

public shellscript v1 · immutable
#284910 ·published 2006-12-19 12:59 UTC
rendered paste body
#!/usr/local/bin/bash# EasyFreeBSD FreeBSD complete modular updating script# 29/07/2005 Ludovic L'hoir <xylan@netbsd-fr.org> (c) GNU GPL	########################	#                      #	#  EasyFreeBSD-0.5.3_9 #	#----------------------#	#     verifiez le log  #	#/var/log/BigUpdateLog #    	#       a la fin       #	#  de votre upgrade    #	# pour voir sil y a eu #	#      des erreurs     #	#                      #	###########################					       ######  On met en place les variable necessaires  ######					       ###EASYFREEBSD="0.5.3_9"DATE=`date "+Date courante: %Y-%m-%d%nHeure: %H:%M:%S"` LOG=/var/log/BigUpdateLogBUILDLOG=/var/log/BuildLogOBJ=/usr/obj SRC=/usr/srcDISTFILES=/usr/ports/distfilesCHECKLOG=`ls -u /var/log | grep BigUpdateLog | wc -l` CHECKBUILDLOG=`ls -u /var/log | grep BuildLog | wc -l`KERN=`uname -v | awk '{print $10}' | cut -d '/' -f 7`XDIALOG=`pkg_info | grep xdialog`CDIALOG=`pkg_info -x cdialog`SHELL_TYPE=`echo $SHELL`PORTUPGRADE=`which portupgrade`CVSUP=`pkg_info | grep cvsup-without-gui` OS_TYPE=`uname`##############################################################   verification et installation de cdialog          ######   necessaire pour les enhanced features de dialog  ############################################################  	if [ "$CDIALOG" = "" ]        	then        	echo "cdialog n'est pas installe sur votre systeme"        	echo "nous allons l'installer"		cd /usr/ports/devel/cdialog && make install clean 1>> $BUILDLOG 2>&1          		fi#########################################################if [ "$XDIALOG" = "" ]; thenDIALOG=dialog	elsifDIALOG=cdialog	elseDIALOG=Xdialogfi###########################################################$DIALOG --title "EasyFreeBSD-0.5.3_9" \        --msgbox "EasyFreeBSD est un script dont le but est de vous simplifier les taches de mise a jour devotre systeme, il enchaine les actions suivantes : Verification portupgrade / installation Verification cvsup / installation-conf automatique Nettoyage de /usr/obj Nettoyage de /usr/src Nettoyage des ports Effacement des disfiles (gain de place) Cvsup ports-supfiles Cvsup stable-supfilesCvsup doc-supfiles Mise a jour du ports tree Mise a jour du pkgdb Compilation du  buildworld Compilation kernel Installation kernel Installation world Creation de 2 logs dans /var/log BigUpdateLog et BuildLog ." 28 55case $? in  0)    clear;;esac###                                                    ######      on verifie que l'on utilise bien un bash      ######                                                    ###if [ "$SHELL_TYPE" != "/usr/local/bin/bash" ]	then#		echo "ATTENTION EasyFreeBSD ne doit etre lance que dans un bash "#		echo "et vous utilisez `echo $SHELL`"$DIALOG --title "Verification de l'utilisation de bash" \	--msgbox "ATTENTION EasyFreeBSD ne doit etre lance quedans un shell bash, et vous utilisez `echo $SHELL`" 10 55case $? in  0)    clear;;esac		exit 1fi###                                                    ###### on verifie que c'est bien Root qui lance le script ######                				       ###if [ "`id -u`" != "0" ]; then $DIALOG --title "ATTENTION !!! ATTENTION" \	--msgbox "ATTENTION EasyFreeBSD ne doit etre lance quepar root ou avec sudo " 10 55case $? in  0)    clear;;esac	exit 1fi###                                                    ###### verification et/ou installation de portupgrade     ######                                                    ###	if [ "$PORTUPGRADE" = "" ]        	then        	echo "portupgrade n'est pas installe sur votre systeme"        	echo "nous allons l'installer"		cd /usr/ports/sysutils/portupgrade && make install clean 1>> $BUILDLOG 2>&1          		fi###                                                    ######      verification et/ou installation de cvsup      ######                                                    ####DIALOG=${DIALOG=dialog}$DIALOG --title "Verification de votre cvsup" --clear \        --yesno "Avez vous cvsup installez sur votre machine ? si oui, veuillez deplacer vos *supfilesdans /usr/local/share/cvsup/ si ils n'y sont pas puis relancez le script et choisissez non. Si vous n'avez pas cvsup, veuillez choisirnon, afin que le script vous l'installe automatiquement, et vous le configure en fonction de votre machine. Sivous avez deja cvsup, le script passera a l'etape suivante " 18 45case $? in  0)    exit 1;;  1)	if [ "$CVSUP" = "" ]		then		echo "cvsup n'est pas installe sur votre systeme"        	echo "nous allons l'installer"		cd /usr/ports/net/cvsup-without-gui && make install clean 1>> $BUILDLOG 2>&1  		cp /usr/src/share/examples/cvsup/*supfile /usr/local/share/cvsup		sed -i '' s/CHANGE_THIS/cvsup4.fr/ /usr/local/share/cvsup/stable-supfile		sed -i '' s/CHANGE_THIS/cvsup4.fr/ /usr/local/share/cvsup/ports-supfile		sed -i '' s/CHANGE_THIS/cvsup4.fr/ /usr/local/share/cvsup/doc-supfile		sed -i '' -E s/tag=RELENG[0-9_]+/tag=`sysctl kern.osrelease|sed -E s/.+\ \([0-9\.]+\)-.+/RELENG_\\\1/|sed s/\\\./_/g`/ /usr/local/share/cvsup/stable-supfile		        		fi  ;;  255)    echo "ESC pour sortir.";;esac###                                    ###### on verif que c'est bien un freebsd ######                                    ###if [ "$OS_TYPE" != "FreeBSD" ]	then		echo "ATTENTION EasyFreeBSD ${EASYFREEBSD} ne marche QUE sur FreeBSD !"		echo "et vous etes sur `uname`"		exit 1fi###				######   on efface les vieux logs  ######				###if [ $CHECKBUILDLOG != 1 ] ; then	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1elserm $BUILDLOG	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1fi#tail -f $LOG & if [ $CHECKLOG != 1 ] ; then        	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~                                 ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~    EasyFreeBSD  ${EASYFREEBSD}  ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~                                 ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	echo EasyFreeBSD : $DATE > $LOG "\n"	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1elserm $LOG #tail -f $LOG &	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~                                 ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~    EasyFreeBSD  ${EASYFREEBSD}  ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~                                 ~~~~~~\n" >> $LOG 2>&1	echo -en "      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	echo EasyFreeBSD : $DATE > $LOG $DIALOG --title "Suivi du bon deroulement de EasyFreeBSD" --tailbox $LOG 20 54 &case $? in  0)    clear;;#  1)#    echo "Cancel pressed.";;#  255)#    echo "Box closed.";;esac & fi###				             ###### On commence par un nettoyage de la bête  ######    decommentez les lignes souhaitees     ###### si 1: vous avez portupgrade (portsclean) ###### si 2: vous voulez effacer vos /distfiles ######      dans le but d'un gain de place      ######				             ####echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1echo -en "Nettoyage de /usr/obj \n " >> $LOG 2>&1 #echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1cd $OBJ( chflags -R noschg * ; rm -rf * ) 1>> $BUILDLOG 2>/dev/nullecho -en "Nettoyage du /usr/src \n " >> $LOG 2>&1 #echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1 cd $SRC ; make cleandir 1>> $BUILDLOG 2>&1 echo -en "Nettoyage des ports  \n " >> $LOG 2>&1 #echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1portsclean -C 1>> $BUILDLOG 2>&1 && portsclean -DD 1>> $BUILDLOG 2>&1 echo -en "Effacement pour gain de place des distfiles  \n " >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1cd $DISTFILES ( chflags -R noschg * ; rm -rf * ) 1>> $BUILDLOG  2>/dev/null######  cvsup + portsdb + pkgdb ###echo -en "Cvsup du ports-supfile en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1/usr/local/bin/cvsup -g -L0 /usr/local/share/cvsup/ports-supfile echo -en "Cvsup du ports-supfile termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1echo -en "Cvsup du stable-supfile en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1/usr/local/bin/cvsup -g -L0 /usr/local/share/cvsup/stable-supfileecho -en "Cvsup du ports-supfile termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1echo -en "Cvsup du doc-supfile en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1/usr/local/bin/cvsup -g -L0 /usr/local/share/cvsup/doc-supfile echo -en "Cvsup du ports-supfile termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"echo -en "le cvsup c'est termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1echo -en "Mise a jour du PT  en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1/usr/local/sbin/portsdb -Uu 1>> $BUILDLOG 2>&1 echo -en "Fin de la maj du PT \n" >> $LOG 2>&1 #echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1echo -en "Mide a jour du pkgdb en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1/usr/local/sbin/pkgdb -u 1>> $BUILDLOG 2>&1 echo -en "Fin de la maj de pkgdb \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1### 		            ###### on lance le buildworld  ###### et on previent root     ###### par mail si ya un pb    ###### 		            ###cd /usr/srcecho -en "Le make buildworld en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1if make -j2 buildworld 1>> $BUILDLOG 2>&1 then echo -en "Le buildworld est termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"	else echo -en "Le buildworld a eu un probleme \n" >> $LOG 2>&1; tail -30 $BUILDLOG | mail -s "Il y a eu un probleme durant le buildworld" root	exit 1fi### 		            ###### on lance le buildkernel ###### et on previent root     ###### par mail si ya un pb    ###### 		            ###echo -en "Le make buildkernel  en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1if make buildkernel "KERNCONF=${KERN}" 1>> $BUILDLOG 2>&1 then echo -en "Le buildkernel est termine \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	else echo -en"le buildkernel a eu un probleme. rebootez sur kernel.old pour reparer \n ">> $LOG 2>&1 ; tail -30 $BUILDLOG | mail -s "le buildkernel a crashe..." root	exit 1fi### 		            ###### on lance l'installkernel ###### et on previent root     ###### par mail si ya un pb    ###### 		            ###echo -en "L'installkernel  en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1if make installkernel "KERNCONF=${KERN}" 1>> $BUILDLOG 2>&1 	then echo -en "		L'installkernel est termine\n" >> $LOG 2>&1	#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	else echo -en"l'installkernel a eu un probleme. rebootez sur kernel.old pour reparer \n ">> $LOG 2>&1 ; tail -30 $BUILDLOG | mail -s "le buildkernel a crashe..." root	exit 1fi### 		            ###### on lance l'installworld ###### et on previent root     ###### par mail si ya un pb    ###### 		            ###echo -en "Le make install world  en cours \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1if make installworld 1>> $BUILDLOG 2>&1 	then echo -en "L'installworld est termine \n" >> $LOG 2>&1 	#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1	else echo -en "L'installworld a eu un probleme \n" >> $LOG 2>&1; tail -30 $BUILDLOG | mail -s "L'installworld a eu un probleme" root	exit 1fi### 				     ###### on envoit un mail  pour prevenir ###### que tout est fini et qu'il faut  ######    rebooter en singleuser pour   ######     effectuer le mergemaster     ###### 				     ###echo -en "regardez le log complet , puis rebootez en single user et effectuez un mergemaster \n" >> $LOG 2>&1#echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" >> $LOG 2>&1 | mail -s "Rebuild et installation complete" rootexit 1