Редагування сторінок підручника/makeman.sh

Матеріал з docs.linux.org.ua — збірника документації з Unix/Linux українською мовою.

Перейти до: навігація, пошук
# !/bin/bash
# 20051210 makeman.sh hse@ukr.net http://docs.linux.org.ua/dlou/index.php/Man
# Distributed under the terms of the GNU General Public License v2 or later

# This script automate manpages-lang-encode-version.tar.bz2 generations from wiki
# formated file using wiki to man converter. Can be added to cron jobs.

# Edit to suite yours configuration:
# You language:
lang=uk
# Location of wiki formated man pages:
wikimandir=~/doc/Man
# Wiki to man converter (wiki2man.py):
converter=~/programs/man/wiki2man/wiki2man.py
# Some file for man instalation:
addfile=~/programs/man/wiki2man/manpages-$lang
# Working directory:
dirout=~/programs/man/test
# E-mail address for converter errors...
email=docs@linux.org.ua
# Release version:
version=`date +%Y%m%d`
# List of encodings for manual pages:
manencoding="utf8"

if [ -f $dirout/errors ]
  then
	rm -f $dirout/errors
fi

# Prepare output directory:
for i in $manencoding
  do
	# Name of man pages file. Next line will produce in the directory
	# $dirout file: "manpages-uk-utf8-20051114.tar.bz2"
	mansources=manpages-$lang-$i-$version
	# You also will get manpages sources in the directory:
	mandir=$dirout/$mansources
	
	if [ -d $mandir ]
	  then
		rm -rf $mandir
	fi

	for i in 1 2 3 4 5 6 7 8
	  do
		mkdir -p $mandir/man$i
		if [ -f $wikimandir/man$i/ALIASES ]
		  then
			cp $wikimandir/man$i/ALIASES $mandir/man$i/
		fi
	  done
  done

# Reformatting wiki -> roff:
for i in 1 2 3 4 5 6 7 8
  do
	if [ -d $wikimandir/man$i ]
	  then
		cd $wikimandir/man$i
		for j in `ls |grep '\.'`
		  do
			echo -n "Reformatting: $j ..."
			dirin=$wikimandir/man$i/
			file=`echo $j |awk -F'.' '{print $1}'`
			if [[ `echo $j |awk -F'.' '{print $3}'` == '' ]]
			  then
				ext=`echo $j |awk -F'.' '{print $2}'`
			  else
				file=$file.`echo $j |awk -F'.' '{print $2}'`
				ext=`echo $j |awk -F'.' '{print $3}'`
			fi
			#time=`date -I`
			time=`ls -l --time-style=long-iso $j |awk '{print $6}'`"-"`ls -l --time-style=long-iso $j |awk '{print $7}'`
			$converter 2>&1 $lang $dirin $dirout $file $ext $time $version $manencoding >> $dirout/errors
			echo "   OK!"
		  done
	fi
  done

# Errors notification or release!
if [ -s $dirout/errors ]
  then
	cat $dirout/errors
	mail -s "wiki2man.py errors" $email < $dirout/errors
	exit 1
  else
	# List of encodings for manual pages:
	for i in $manencoding
	  do
		# Name of man pages file. Next line will produce in the directory
		# $dirout file: "manpages-uk-utf8-20051114.tar.bz2"
		mansources=manpages-$lang-$i-$version
		# You also will get manpages sources in the directory:
		mandir=$dirout/$mansources
		
		# Copy some things to do manpage source code:
		cp -r $addfile/* $mandir
		
		# Create archive:
		cd $dirout
		tar cf $mansources.tar $mansources
		bzip2 -zf9 $mansources.tar
		
		# Release!
		#cp -f $dirout/$mansources.tar.bz2 /var/ftp/pub/man/$mansources.tar.bz2
	  done
	exit 0
fi
Особисті інструменти