-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·97 lines (87 loc) · 1.85 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# Documents are DocBook qandaset (SGML)
# For more see http://www.docbook.org/tdg/en/html/qandaset.html
# © 2017 Frank Jung. All rights reserved.
FAQ=$(dirname $0)
SCRIPTNAME=$(basename $0)
FTPSITE=$(grep machine ~/.netrc| cut -f 2)
# required program provided by docbook-utils
JW=/usr/bin/jw
do_help()
{
cat <<EOH >&2
Usage: ${SCRIPTNAME}
Build SGML into HTML and optionally FTP to a remote location.
Options:
-b = build
-f = ftp to site set in .netrc
-h = this help
Return codes:
0 = build completed successfully
1 = build failed, see previous messages
Copyright 2010-2017 Frank Jung. All rights reserved.
EOH
}
# check that conversion utility, jw(1) is installed
do_check()
{
# check dependencies
if [[ ! -x ${JW} ]]
then
echo -e "ERROR: ${JW} not installed\n" >&2
do_help
exit 1
fi
}
# convert to html using jw
do_build()
{
do_check
rm -rf $FAQ/index/*
rm -rf $FAQ/index.junk
${JW} -f docbook -b html -o index index.sgml
chmod 755 $FAQ/index/
chmod 644 $FAQ/index/*
}
# upload html to web site
do_ftp()
{
ftp -pv <<FTPFAQ
open $FTPSITE
ascii
verbose
prompt
reset
tick
put homepage.html
lcd $FAQ/index
dir .
delete index.html
put index.html
mdelete x*.html
mput x*.html
dir .
bye
FTPFAQ
}
#####################################################################
# MAINLINE
#####################################################################
# check for action to perform, show help if none
if [[ $# -eq 0 ]]
then
do_help
exit 0
fi
# need at least one parameter
while getopts "fbh" opt
do
case "$opt" in
b) do_build ;;
f) do_ftp ;;
h) do_help ;;
*) do_help
exit 1 ;;
esac
done
exit 0