清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/bash ############################################################ #function md5check #usage: Md5Check FILE1 FILE2 function Md5Check() { local F1 local F2 local V1 local V2 F1=$1 F2=$2 V1=$(md5sum ${F1} | awk '{print $1}') V2=$(md5sum ${F2} | awk '{print $1}') if [ ${V1} = ${V2} ] then echo "${V1} : ${F1}" echo "${V2} : ${F2}" echo "OK" else echo "${V1} : ${F1}" echo "${V2} : ${F2}" echo "ERROR" fi } ############################################################ clear echo "NOW I try to configure the system ..." echo "please wait ..." ############################################################ #00.use hard disks #configure fstab FSTABPATH='/etc/' FFSTAB='fstab' DISKFSTABPATH='fstabconfig/' DISKFSTAB='diskfstab.txt' INSERTLINENUMBER=1 #insert all the content of the file $DISKFSTAB after the Line $INSERTLINENUMBER of $FFSTAB #sed -i "${INSERTLINENUMBER}r${DISKFSTABPATH}${DISKFSTAB}" ${FSTABPATH}${FFSTAB} sed -i "${INSERTLINENUMBER}r${DISKFSTABPATH}${DISKFSTAB}" ${DISKFSTABPATH}${FFSTAB} Md5Check ${FFSTAB} ${FSTABPATH}${FFSTAB} # ############################################################ #01.add 000 regular user #configure 000 user PWPATH='/etc/' PFILE='passwd' SFILE='shadow' GFILE='group' GSFILE='gshadow' ADDUSER='000' ADDUSERHOME="/home/${ADDUSER}" ADDGROUP='000' AUID='5200' AGID='520' #1.1 configure the passwd ADDINF="${ADDUSER}::${AUID}:${AGID}::${ADDUSERHOME}:/bin/bash" #add user information to passwd sed -i "$ a${ADDINF}" ${PWPATH}${PFILE} #sed -i "$ a${ADDINF}" ${PFILE} Md5Check ${PFILE} ${PWPATH}${PFILE} # #1.2 configure the shadow #get some data from the first line DAYINF=$(awk -F ':' 'FNR==1{print $3}' ${SFILE} ) CCINF=$(awk -F ':' 'FNR==1{print $4}' ${SFILE} ) SADDINF="${ADDUSER}::${DAYINF}:${CCINF}:::::" sed -i "$ a${SADDINF}" ${PWPATH}${SFILE} #sed -i "$ a${SADDINF}" ${SFILE} Md5Check ${SFILE} ${PWPATH}${SFILE} # #1.3 configure the group #ALLGROUPS='root,bin,daemon,sys,adm,tty,disk,lp,mem,kmem,wheel,floppy,mail,news,uucp,man,dialout,audio,video,cdrom,games,slocate,utmp,smmsp,tape,mysql,rpc,sshd,gdm,shadow,ftp,oprofile,apache,messagebus,haldaemon,plugdev,power,netdev,pop,scanner,nobody,nogroup,users,console,000,vboxusers' ADDGROUPS='bin tty disk lp wheel mail news man audio video cdrom games mysql ftp messagebus plugdev power netdev pop users console 000 vboxusers' #remove ${ADDUSER} from ${GFILE} #sed -r -i "s/,?${ADDUSER}$//" ${PWPATH}${GFILE} #sed -r -i "s/,?${ADDUSER}$//" ${GFILE} #add ${ADDUSER} to ${GFILE} for gs in ${ADDGROUPS} do #be care of the sequence:first replace the line not end with ":",then replace the line end with ":" sed -r -i "/^${gs}/{s/([^:])$/\1,${ADDUSER}/; s/(:)$/\1${ADDUSER}/}" ${PWPATH}${GFILE} #sed -r -i "/^${gs}/{s/([^:])$/\1,${ADDUSER}/; s/(:)$/\1${ADDUSER}/}" ${GFILE} done Md5Check ${GFILE} ${PWPATH}${GFILE} #1.4 configure the gshadow # Md5Check ${GSFILE} ${PWPATH}${GSFILE} # #1.5 configure sudoers #add ${ADDUSER} to sudoers SUDOPATH='/etc/' SUDOF='sudoers' SUDOUSERINF="${ADDUSER} ALL=(ALL) NOPASSWD: ALL" PRIVILEGETK='User privilege specification' chmod 640 ${SUDOPATH}${SUDOF} sed -i "/${PRIVILEGETK}/{ n n a\ ${SUDOUSERINF} }" ${SUDOPATH}${SUDOF} chmod 440 ${SUDOPATH}${SUDOF} Md5Check ${SUDOF} ${SUDOPATH}${SUDOF} # #1.6 create user home directory if [ ! -d ${ADDUSERHOME} ] then mkdir -p ${ADDUSERHOME} chown -R ${ADDUSER}:${ADDGROUP} ${ADDUSERHOME} fi # ############################################################ #02.support CJK characters set #configure locale #function ChangLocale #usage: ChangLocale LOCALEFILE function ChangLocale() { local FN local TK1 local TK2 FN=$1 TK1='default locale' TK2='en_US.UTF-8' ############################################################ #add "#" to the beginnig of next line contains ${TK1} ############################################################ #way1:use sed and regular express engine sed -i "/${TK1}/{n;s/^#*/#/}" ${FN} ############################################################ #remove "#" in the beginning of line contains ${TK2} ############################################################ #way1:use sed and regular express engine sed -i "/${TK2}/{s/^#*//}" ${FN} ############################################################ #way2:get the line number #local LN1 #LN1=$(grep -n "${TK1}" ${FN} | awk -F ':' '{print $1}' ) } # PATH1='/etc/profile.d/' F1='lang.sh' F2='lang.csh' ChangLocale ${PATH1}${F1} ChangLocale ${PATH1}${F2} #ChangLocale ${F1} #ChangLocale ${F2} Md5Check ${F1} ${PATH1}${F1} Md5Check ${F2} ${PATH1}${F2} #active locale source ${PATH1}${F1} source ${PATH1}${F2} # ############################################################ #03.configure alsamixer(alsactl store) #config alsa #initial file location: PREFIX/share/alsa/init/00main #state file location: /var/lib/alsa/asound.state ASSPATH='/var/lib/alsa/' ASSFILE='asound.state' cp ${ASSFILE} ${ASSPATH}${ASSFILE} chown root:root ${ASSPATH}${ASSFILE} chmod 644 ${ASSPATH}${ASSFILE} ############################################################ #04.fonts configure SCFONTSPATH='fonts/SourceCodePro_FontsOnly/' ADFONTSPATH='fonts/usedfonts/' cd ${SCFONTSPATH} sh cpfonts.sh #"2> /dev/null" do not echo the fall back messages cd - 2> /dev/null cd ${ADFONTSPATH} sh cpfonts.sh cd - 2> /dev/null # ############################################################ #05.input CJK characters #configure scim.sh and scim.csh F3='scim.sh' F4='scim.csh' chmod +x ${PATH1}${F3} chmod +x ${PATH1}${F4} #chmod +x ${F3} #chmod +x ${F4} #active scim source ${PATH1}${F3} source ${PATH1}${F4} # ############################################################ #06.configure scim SCIMPATH='${ADDUSERHOME}/.scim/' SCIMCF='config' SCIMGF='global' SCIMCOFIGPATH='scim/' cd ${SCIMCOFIGPATH} SCONFIG=$(ls update*.sh 2> /dev/null) sh ${SCONFIG} cd - 2> /dev/null # ############################################################ #07.configure vim and gvim,emacs VIMCONFIGPATH='vimconfig/' EMACSCONFIGPATH='emacsconfig/' cd ${VIMCONFIGPATH} VIMCFILE=$(ls update*.sh 2> /dev/null) sh ${VIMCFILE} cd - 2> /dev/null cd ${EMACSCONFIGPATH} EMACSCFILE=$(ls update*.sh 2> /dev/null) sh ${EMACSCFILE} cd - 2> /dev/null # ############################################################ #08.texlive path #configure profile TEXCONFIGPATH='texlivepathconfig/' FTEXCONFIG='texlivepath.txt' PROFILEPATH='/etc/' FPROFILE='profile' cat ${TEXCONFIGPATH}${FTEXCONFIG} >> ${PROFILEPATH}${FPROFILE} #cat ${TEXCONFIGPATH}${FTEXCONFIG} >> ${TEXCONFIGPATH}${FPROFILE} #active the $PATH source ${PROFILEPATH}${FPROFILE} # ############################################################ #09.configure x keyboard shortcuts #configure xfce keyboard shortcuts MUTTPATH="${ADDUSERHOME}/" MUTTCPATH='mutt/' XFCEGLOBALPATH='/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/' XFCEPATH="${ADDUSERHOME}/.config/xfce4/xfconf/xfce-perchannel-xml/" XFCEROOTPATH="root/.config/xfce4/xfconf/xfce-perchannel-xml/" THUNARPATH="${ADDUSERHOME}/.config/Thunar/" THUNARCPATH='thunar/' XFCEPANELPATH="${ADDUSERHOME}/.config/xfce4/" XFCEPANELCPATH='panel/' XFCECPATH='xfce4/' MUTTRCF='.muttrc' KTKS='name="XF86WWW" type="string"' XFCECF='xfce4-keyboard-shortcuts.xml' KSHORTCUTSF='xfce4keyshortcuts.txt' XTHUNARF='thunar.xml' THUNARFSCM='accels.scm' XPANELF='xfce4-panel.xml' XPOWERFILE='xfce4-power-manager.xml' #09.1 configure mutt cp ${MUTTCPATH}${MUTTRCF} ${MUTTPATH}${MUTTRCF} #09.2 configure keyboard shortcuts if [ ! -d ${XFCEPATH} ] then mkdir -p ${XFCEPATH} fi sed -i "/${KTKS}/{n;n;r\ ${XFCECPATH}${KSHORTCUTSF} }" ${XFCEPATH}${XFCECF} sed -i "/${KTKS}/{n;n;r\ ${XFCECPATH}${KSHORTCUTSF} }" ${XFCEROOTPATH}${XFCECF} #09.3 configure thunar if [ ! -d ${THUNARPATH} ] then mkdir -p ${THUNARPATH} fi cp ${THUNARCPATH}${THUNARFSCM} ${THUNARPATH}${THUNARFSCM} cp ${XFCECPATH}${XTHUNARF} ${XFCEPATH}${XTHUNARF} #09.4 configure xfce panel if [ ! -d ${XFCEPANELPATH} ] then mkdir -p ${XFCEPANELPATH} fi cp ${XFCECPATH}${XPANELF} ${XFCEPATH}${XPANELF} cp -r ${XFCECPATH}${XFCEPANELCPATH} ${XFCEPANELPATH} #09.5 configure power manager cp ${XFCECPATH}${XPOWERFILE} ${XFCEPATH}${XPOWERFILE} # #09.6 configure kde keyboard shortcuts # chown -R ${ADDUSER}:${ADDGROUP} ${ADDUSERHOME} # ############################################################ #10.configure audacious AUPATH="${ADDUSERHOME}/.config/audacious/" AUFILE='config' AUCPATH='audacious/' AMIDITK='\[amidiplug\]' ADDAUINF='fsyn_soundfont_file=/media/sda2/lsoftware/player/midi/soundfonts/midi_xp/2gmgsmt.sf2' AMIDIF='audaciousconfig.txt' if [ ! -d ${AUPATH} ] then mkdir -p ${AUPATH} fi if [ ! -f ${AUPATH}${AUFILE} ] then touch ${AUPATH}${AUFILE} fi chown -R ${ADDUSER}:${ADDGROUP} ${ADDUSERHOME} chmod 644 ${AUPATH}${AUFILE} sed -i "$ r${AUCPATH}${AMIDIF}" ${AUPATH}${AUFILE} # ############################################################ #11.configure browser and mailer #configure mozilla firefox, thunderbird, seamonkey MFPATH="${ADDUSERHOME}/.mozilla/firefox/" MTPATH="${ADDUSERHOME}/.thunderbird/" MSPATH="${ADDUSERHOME}/.mozilla/seamonkey/" MPROFILES='profiles.ini' MPREFS='prefs.js' MFFOLD='229/' MFCFOLD='mozilla/firefox/' MTCFOLD='thunderbird/' MSCFOLD='mozilla/seamonkey/' if [ ! -d ${MFPATH}${MFFOLD} ] then mkdir -p ${MFPATH}${MFFOLD} fi if [ ! -d ${MTPATH}${MFFOLD} ] then mkdir -p ${MTPATH}${MFFOLD} fi if [ ! -d ${MSPATH}${MFFOLD} ] then mkdir -p ${MSPATH}${MFFOLD} fi cp ${MFCFOLD}${MPROFILES} ${MFPATH}${MPROFILES} cp ${MTCFOLD}${MPROFILES} ${MTPATH}${MPROFILES} cp ${MSCFOLD}${MPROFILES} ${MSPATH}${MPROFILES} chmod 644 ${MFPATH}${MPROFILES} chmod 644 ${MTPATH}${MPROFILES} chmod 644 ${MSPATH}${MPROFILES} cp ${MFCFOLD}${MFFOLD}${MPREFS} ${MFPATH}${MFFOLD}${MPREFS} cp ${MTCFOLD}${MFFOLD}${MPREFS} ${MFPATH}${MFFOLD}${MPREFS} cp ${MSCFOLD}${MFFOLD}${MPREFS} ${MSPATH}${MFFOLD}${MPREFS} chmod 644 ${MFPATH}${MFFOLD}${MPREFS} chmod 644 ${MTPATH}${MFFOLD}${MPREFS} chmod 644 ${MSPATH}${MFFOLD}${MPREFS} chown -R ${ADDUSER}:${ADDGROUP} ${ADDUSERHOME} # ############################################################ #12.configure flashplayer FLASHPATH1='/media/sda2/lsoftware/flashplayer/' FFFILE='libflashplayer.so' MOZILLALIBPATH='/usr/lib64/mozilla/plugins/' TEMPFILE1=$(mktemp -t 229_XXXXXX) TEMPFILE2=$(mktemp -t 229_XXXXXX) MAXVER='468' #get the latest version of flashplayer directory ls -vFd ${FLASHPATH1}install* | grep "/$" > ${TEMPFILE1} awk -F '/' '{/* NF is total number of Fields */;n=NF-1;print $n}' $TEMPFILE1 > ${TEMPFILE2} MAXVER=$(awk -F '_' ' BEGIN{max='${MAXVER}'} #using shell variable in awk: using single quotation marks, as form '${variable}' #NR is record number #FNR is record number of the current file #$7 is the version number $7>max{max=$7} END{print max}' ${TEMPFILE2}) LATESTFF=$(sed -n "/${MAXVER}/p" ${TEMPFILE2})"/${FFFILE}" #update lib of flashplayer cp ${FLASHPATH1}${LATESTFF} ${MOZILLALIBPATH} chmod 755 ${MOZILLALIBPATH}${FFFILE} #delete any used temp files rm $TEMPFILE1 rm $TEMPFILE2 # ############################################################ #13.install texlive #14.install virtualbox #15.install maxima #16.install audacious #17.install smplayer #18.install free PASCAL (fpc)