[Comm] Доработка после установки

Michael Shigorin mike на osdn.org.ua
Пт Авг 7 01:23:16 MSD 2009


On Fri, Aug 07, 2009 at 09:13:11AM +1300, Arcady Ivanov wrote:
> Что такое here-documents?

cat > FILE << __EOF__
line1
  line2
    line3
__EOF__

См. тж. bash(1) и практически любую книжку с упоминанием UNIX
shell, особенно рекомендую "UNIX: универсальная среда
программирования" (Керниган, Пайк).

> Забыл указать, что цель скрипта - ликвидировать однообразную
> ручную работу при настройке традиционных для меня вариантов
> систем и заодно запомнить в коде все нюансы настройки, которые
> имеют тенденцию забываться.

Ага... :)

-- 
-rwxrwxr-x 1 mike mike 3670 Feb 19  1999 rh5.1clean
----------- следующая часть -----------
#!/bin/bash
# Red Hat Linux 5.1 (Manhattan) doctor :)
# they at RedHat think we need just everything. But we often don't,
# especially those of us who are short of disk.
# And of course, our users *do* need to work with floppies and CDs
# So, I tried to make the script crawl out and fix some annoying things.
# Among them I'd like to implement these:
#	- /usr cleanup (man, doc, share...)
# 	- colour ls	\_  done by 
# 	- .inputrc	/~  EayCyrillic in fact
#	- my own fd/CD scripts, together with
#	- some /dev/fd* entries & permission fix
#       - cyrillization of bash and mc at least...
# ...of course, this could only be run by root to accomplish.

EASYCYRILLIC="./easy-cyrillic"
TIMEREGION="Europe"
TIMEZONE="Kiev"

ask_yes ()
{
    echo -n "$1 [Y/n]?"
    read answer
    case $answer in
	n|N|no) OK=;;		# empty string
	*)   	OK=yes;;	# just not empty :)
    esac
}

ask_no ()
{
    echo -n "$1 [N/y]?"
    read answer
    case $answer in
	y|Y|yes) OK=yes;;
	*)   	 OK=;;
    esac
}
clear
echo "I'm gonna clean your disk a bit. Here's your disk stats:"
df -h -t ext2
echo "I think there may be some extra files on your disk..."
ask_no "So, should I proceed"
if [ $OK ]; then
    echo "Proceeding..."
else
    echo "Maybe next time?"
    exit 1
fi
echo
echo -n "Checking free space on root filesystem... "
STARTFREE=`df -h / |tail -n1|cut -c33-43`
echo $STARTFREE
echo "Entering /usr..."
cd /usr
echo -n "  /usr/man: online manual pages -- "
du -h man|tail -n1|cut -f1
if [ -d man ]; then
    ask_yes "  Should we gzip manual pages (don't worry, man _will_ understand)"
    if [ $OK ];then
	echo "  /usr/man -- gzipping man pages"
	gzip man/man?/*
    else
	echo "  OK, leaving them alone"
    fi
else
    echo "Nothing to be done for /usr/man"
fi
echo
echo -n "  /usr/share: some collection of spare info -- "
du -h share|tail -n1|cut -f1
echo "  We can shrink it a bit by removing extra timezone/terminfo/locale files"
ask_yes "  So, let's do it"
if [ $OK ]; then
    cd /usr/share
    echo "    /usr/share/zoneinfo: time zones all around the world! But if you live in"
    echo -n "    $TIMEZONE, $TIMEREGION, you can do without rest which takes "
    du -h zoneinfo|tail -n1|cut -f1
    ask_yes "    Remove extra timezone info"
    if [ $OK ]; then
	cd zoneinfo
	for i in *; do
	    if [ -d $i ]; then		# this is a directory
		echo -n "      >$i... "
		cd $i
		if [ $i = $TIMEREGION ]; then	# ...e.g. "Europe"
		    echo -n " aha!.. "
		    for j in *; do
			if [ $j != $TIMEZONE ]; then
			    rm -f $j
			fi
		    done
		    cd ..
		    echo "cleaned up."
		else
		    rm -f *
		    cd ..
		    rmdir $i
		    echo "bye."
		fi
	    else			# then maybe a file?..
		rm -f $i
	    fi
	done
	cd ..
	echo -n "    So, now it wants "
        du -h zoneinfo|tail -n1|cut -f1	# We've just cleaned it up...
    else
	echo "Yes sir."
    fi

else
    echo "Nothing to be done for /usr/share"
fi



if [ -f $EASYCYRILLIC.tgz ]; then
    echo
    echo "Let's install Easy Cyrillic! It's COOL, COOL, COOL!"
    echo "Since it allows us to use cp866, koi8, and (under tortures) cp1251"
    echo "and uses various swicher-keys"
    ask_yes "So, OK to install"
    if [ $OK ]; then
	echo "Installing, installing, installing!"
	tar zxf $EASYCYRILLIC.tgz
	$EASYCYRILLIC/Install.me
    else
	echo "You'll be back. EC is nice."
    fi
else
    echo "-----------------------------------------------------------"
    echo "There should be $EASYCYRILLIC.tgz here, but I can't see it."
    echo "I was relying a bit on it! (because it's worthy)."
    echo "I recommend you to get & set it up ASAP!"
    echo "-----------------------------------------------------------"
fi
	
    
    


Подробная информация о списке рассылки community