Download script fix, CHANGELOG update, and small doc changes.
[jben.git] / linux_scripts / download_script
blobf7241195ee5b0dfccf32a101dff8eead584fb4de
1 #!/bin/sh
3 # Dictionary/SOD download script for J-Ben 1.2.1
4 # This script is intended to be executed from the src folder,
5 # as it downloads files to relative paths ../dicts and ../sods.
7 get_yn ()
9 while [ 0 ]; do
10 read yn
11 if [ "$yn" == "Y" ]; then
12 yn = "y"
13 elif [ "$yn" == "N" ]; then
14 yn = "n"
17 if [ -z "$yn" ]; then
18 if [ ! -z "$1" ]; then
19 yn="$1"
22 if [ "$yn" == "y" ]; then
23 return 0
24 elif [ "$yn" == "n" ]; then
25 return -1
27 echo -ne "Please enter \"Y\" or \"N\": "
28 done
32 # Check for existance of wget, tar and gzip, and bail if not found
33 if ! which wget &> /dev/null; then
34 echo -e "wget not found. wget is required to automatically download dictionaries and stroke order\ndiagrams."
35 exit -1
37 if ! which tar &> /dev/null; then
38 echo -e "tar not found. tar is required for unpacking downloaded stroke order diagram packages."
39 exit -1
41 if ! which gzip &> /dev/null; then
42 echo -e "wget not found. wget is required to automatically download dictionaries and stroke order\ndiagrams."
43 exit -1
46 # Ask for auto-dl of dictionaries
47 # * EDICT2 [Y/n]
48 # * KANJIDIC [Y/n]
49 # * KANJIDIC2 [y/N]
50 echo -ne \
51 "\nJ-Ben needs dictionary files in order to work properly. From now, you\n"\
52 "will be given a choice of files to download. However, you can skip\n"\
53 "this if you wish to set them up yourself.\n\n"\
55 "Select dictionary files for download and auto-installation? [Y/n]: "
56 get_yn y
57 if [ "$?" == "0" ]; then dl_dicts=0; fi
59 if [ $dl_dicts ]; then
60 echo -ne \
61 "\nEDICT2: Extended English-Japanese word dictionary.\n\n"\
63 "This is the standard English-Japanese dictionary file used by J-Ben.\n"\
64 "Download this unless you already have a copy from elsewhere\n"\
65 "(ex.: from your Linux distribution)\n\n"\
67 "Download EDICT2? [Y/n]: "
68 get_yn y
69 if [ "$?" == "0" ]; then dl_edict2=0; fi
71 echo -ne \
72 "\nKANJIDIC: Standard character dictionary.\n\n"\
74 "This is the standard character dictionary file used by J-Ben,\n"\
75 "containing information on 6,355 kanji characters.\n"\
76 "Download this unless you already have a copy from elsewhere\n"\
77 "(ex.: from your Linux distribution)\n\n"\
79 "Download KANJIDIC? [Y/n]: "
80 get_yn y
81 if [ "$?" == "0" ]; then dl_kanjidic=0; fi
83 echo -ne \
84 "\nKANJIDIC2: Extended character dictionary.\n\n"\
86 "KANJIDIC2 is an expanded character dictionary file, containing data\n"\
87 "on 13,108 kanji characters. It contains much extra information not\n"\
88 "found in KANJIDIC, but may be overkill for most users. It's also a\n"\
89 "large file and will increase the load time of J-Ben significantly.\n\n"\
91 "Download KANJIDIC2? [y/N]: "
92 get_yn n
93 if [ "$?" == "0" ]; then dl_kanjidic2=0; fi
96 # Ask for auto-dl of stroke order diagrams
97 # * Static charts [Y/n]
98 # * Animations [y/N]
99 echo -ne \
100 "\nJ-Ben supports stroke order diagrams from the SODER project at\n"\
101 "KanjiCafe.com. These are not required, but are recommended.\n\n"\
103 "Do you wish to download stroke order diagrams? [Y/n]: "
104 get_yn y
105 if [ "$?" == "0" ]; then dl_sods=0; fi
107 if [ $dl_sods ]; then
108 echo -ne \
109 "\nStatic Stroke Order Diagrams\n\n"\
111 "This package contains stroke order diagrams for 1,513 kanji characters.\n"\
112 "These diagrams are not animated, showing a grid with one stroke drawn and\n"\
113 "highlighted per box. These are highly recommended.\n\n"\
115 "Do you wish to download static (non-animated) stroke order diagrams? [Y/n]: "
116 get_yn y
117 if [ "$?" == "0" ]; then dl_static_sods=0; fi
119 echo -ne \
120 "\nAnimated Stroke Order Diagrams\n\n"\
122 "This package contains animated stroke order diagrams for 1,513 kanji\n"\
123 "characters. These diagrams show a single box which walks through each of the\n"\
124 "kanji strokes in sequence. Some users prefer these.\n\n"\
126 "Do you wish to download animated stroke order diagrams? [y/N]: "
127 get_yn n
128 if [ "$?" == "0" ]; then dl_anim_sods=0; fi
131 # Download all selected files and place in ../dicts or ../sods
132 echo -e "\nDownloading selected components:"
133 if [ $dl_edict2 ]; then echo "* EDICT2"; fi
134 if [ $dl_kanjidic ]; then echo "* KANJIDIC"; fi
135 if [ $dl_kanjidic2 ]; then echo "* KANJIDIC2"; fi
136 if [ $dl_static_sods ]; then echo "* KanjiCafe.com static stroke order diagrams"; fi
137 if [ $dl_anim_sods ]; then echo "* KanjiCafe.com animated stroke order diagrams"; fi
138 echo
140 # Reset dict/sod vars to null; we'll set them if a download completes
141 # successfully.
142 dl_dicts=
143 dl_sods=
145 if [ $dl_edict2 ]; then
146 # Download only if not present.
147 if [ -e "../dicts/edict2.gz" ]; then
148 echo -e "EDICT2 already downloaded; skipping.\n"
149 else
150 wget -P../dicts http://www.vultaire.net/software/jben/files/dicts/edict2.gz
151 if [ "$?" == "0" ]; then dl_dicts=0; fi
154 if [ $dl_kanjidic ]; then
155 if [ -e "../dicts/kanjidic.gz" ]; then
156 echo -e "KANJIDIC already downloaded; skipping.\n"
157 else
158 wget -P../dicts http://www.vultaire.net/software/jben/files/dicts/kanjidic.gz
159 if [ "$?" == "0" ]; then dl_dicts=0; fi
162 if [ $dl_kanjidic2 ]; then
163 if [ -e "../dicts/kanjidic2.xml.gz" ]; then
164 echo -e "KANJIDIC2 already downloaded; skipping.\n"
165 else
166 wget -P../dicts http://www.vultaire.net/software/jben/files/dicts/kanjidic2.xml.gz
167 if [ "$?" == "0" ]; then dl_dicts=0; fi
170 if [ $dl_static_sods ]; then
171 if [ -e "../sods/sod-utf8-hex.tar.gz" ]; then
172 echo -e "Static SODs already downloaded; skipping.\n"
173 else
174 wget -P../sods http://www.vultaire.net/software/jben/files/sods/sod-utf8-hex.tar.gz
175 if [ "$?" == "0" ]; then dl_sods=0; fi
178 if [ $dl_anim_sods ]; then
179 if [ -e "../sods/soda-utf8-hex.tar.gz" ]; then
180 echo -e "Animated SODs already downloaded; skipping.\n"
181 else
182 wget -P../sods http://www.vultaire.net/software/jben/files/sods/soda-utf8-hex.tar.gz
183 if [ "$?" == "0" ]; then dl_sods=0; fi
187 #Notify user on success, explain where files were placed.
188 echo "Done."
189 if [ $dl_dicts ]; then echo "Dictionary files were placed in the ../dicts directory."; fi
190 if [ $dl_sods ]; then echo "Stroke order diagrams were placed in the ../sods directory."; fi
192 ##Extract SOD archives if necessary
193 #if [ -e "../sods/sod-utf8-hex.tar.gz" -a ! -e ../sods/sod-utf8-hex ]; then
194 # cd ../sods && tar -xzf sod-utf8-hex.tar.gz
196 #if [ -e "../sods/soda-utf8-hex.tar.gz" -a ! -e ../sods/soda-utf8-hex ]; then
197 # cd ../sods && tar -xzf soda-utf8-hex.tar.gz
200 exit 0