OSDN Git Service

Merge branch 'master' of https://scm.osdn.net/gitroot/linuxjm/jm
[linuxjm/jm.git] / admin / JM-release-all.sh
1 #!/bin/bash
2
3 CMDDIR=$(dirname $0)
4 CMD=$CMDDIR/JM-release.sh
5
6 OPTS="-f -q"
7
8 TARGET_DIR="draft/man?"
9
10 init_progress() {
11     COUNT=0
12     WIDTH=70
13     TOTAL=`find $TARGET_DIR -type f | wc -l`
14 }
15
16 show_progress() {
17     COUNT=`expr $COUNT + 1`
18
19     PROGRESS=`expr 100 \* $COUNT / $TOTAL`
20
21     PREV_DONE=$W_DONE
22     W_DONE=`expr $WIDTH \* $PROGRESS / 100`
23     W_REST=`expr $WIDTH - $W_DONE`
24
25     #if [ "$PREV_DONE" == "$W_DONE" ]; then
26     #   return
27     #fi
28
29     if [ "$W_DONE" -eq 0 ]; then
30         STR_DONE=""
31     else
32         STR_DONE=`printf "%0${W_DONE}d" 0 | tr 0 =`
33     fi
34     if [ "$W_REST" -eq 0 ]; then
35         STR_REST=""
36     else
37         STR_REST=`printf "%${W_REST}s" " "`
38     fi
39     STR_PROG=`printf "%4d/%d (%3d%%)" $COUNT $TOTAL $PROGRESS`
40
41     echo -ne "|${STR_DONE}${STR_REST}| ${STR_PROG}\r"
42 }
43
44 finish_progress() {
45     echo -ne "\n"
46 }
47
48 ##################################################
49 # Main Routine
50 ##################################################
51
52 # optparse
53 while getopts "cv" OPT
54 do
55     case $OPT in
56         "c") OPTS="${OPTS} -c" ;;
57         "v") OPTS="${OPTS} -v" ;;
58     esac
59 done
60
61 init_progress
62
63 for d in $TARGET_DIR; do
64     for f in `find $d -type f | sort`; do
65         $CMD $OPTS $f release
66         show_progress
67     done
68 done
69
70 finish_progress