-
Notifications
You must be signed in to change notification settings - Fork 0
/
webaom.sh
executable file
·191 lines (152 loc) · 5.84 KB
/
webaom.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/sh
scriptversion="trunk"
scriptlastedit="20150825"
scriptauthor="John Pyper"
scriptsite="https://github.com/jpyper/bash-scripts"
#############
### ABOUT ###
#############
# This is a simple script that downloads webaom.jnlp from static.anidb.net and runs the
# client locally. Since the script always downloads the webaom.jnlp file each time it
# is run, it will make sure you are running the latest version of the java client (even
# though it hasn't been updated in ages).
#
# Information about the AniDB WebAOM (Anime-O-Matic) can be found at:
# http://wiki.anidb.info/w/WebAOM
####################
### REQUIREMENTS ###
####################
# openjdk-7-jre, icedtea-netx, wget
###############
### LICENSE ###
###############
# This script is licensed under the MIT License.
# Details here: http://opensource.org/licenses/MIT
############################
### CONFIGURABLE OPTIONS ###
############################
# workdir: a temporary directory where files can be downloaded to and work from.
workdir="/tmp/${USER}/webaom"
# javabin: full path location of 'java' binary.
javabin="$(which java)"
# javawsbin: full path location of 'javaws' binary.
javawsbin="$(which javaws)"
# wgetbin: full path location of 'wget' binary.
wgetbin="$(which wget)"
#########################
### MAGIC INGREDIENTS ###
#########################
waom_test_util_requirements() {
# test for external requirements to do the job
echo "+---------------------------------+"
echo "| Checking for external utilities |"
echo "+---------------------------------+"
echo
# check for java installation
if [ ! -f "${javabin}" ]; then
echo ":-( This script can not locate the 'java' binary."
echo " Check the 'javabin' variable at the top of this script. Make sure it is pointing to the 'java' binary."
echo " Install the 'openjdk-8-jre' package provided by your distribution, or"
echo " obtain source from http://openjdk.java.net/ and compile a binary to use."
echo
exit 1
else
echo ":-) [X] openjdk-?-jre"
fi
# check for javaws installation
if [ ! -f "${javawsbin}" ]; then
echo ":-( This script can not locate the 'javaws' binary."
echo " Check the 'javawsbin' variable at the top of this script. Make sure it is pointing to the 'javaws' binary."
echo " Install the 'icedtea-netx' package provided by your distribution, or"
echo " obtain source from http://icedtea.classpath.org/ and compile a binary to use."
echo
exit 1
else
echo ":-) [X] icedtea-netx"
fi
# check for wget installation
if [ ! -f "${wgetbin}" ]; then
echo ":-( This script can not locate the 'wget' binary."
echo " Check the 'wgetbin' variable at the top of this script. Make sure it is pointing to the 'wget' binary."
echo " Install the 'wget' package provided by your distribution, or"
echo " obtain source from https://www.gnu.org/software/wget/ and compile a binary to use."
echo
exit 1
else
echo ":-) [X] wget"
echo
fi
}
waom_check_work_directory() {
# check for work directory
echo "+-----------------------------+"
echo "| Checking for work directory |"
echo "+-----------------------------+"
echo
if [ ! -d "${workdir}" ]; then
echo ":-( Can't find work directory:"
echo " ${workdir}"
echo ":-| Creating directory."
mkdir -p "${workdir}"
if [ ${?} -gt 0 ]; then
echo ":-( There was a problem creating the directory."
echo " Make sure you have write permissions to the directory specified."
echo
exit 1
fi
echo ":-) Directory successfully created."
echo
else
echo ":-) Found output directory:"
echo " ${outdir}"
echo
fi
}
waom_download_run_webaom() {
# try to download java webstart file and run it
echo "+--------------------------------------------------------+"
echo "| Attempting to download file from AniDB.net's server... |"
echo "+--------------------------------------------------------+"
echo
# download the webaom.jnlp file from anidb
${wgetbin} -nv http://static.anidb.net/client/webaom.jnlp -O "${workdir}/webaom.jnlp"
if [ ${?} -gt 0 ]; then
echo ":-( Download FAILED."
echo
echo " Some reasons why the download may have failed:"
echo " 1) The server at AniDB.net might be over capacity, preventing download."
echo " Please try running this script again in a few minutes to see if the"
echo " server traffic has subsided."
echo " 2) You might not have write permissions to ${workdir}"
echo " Make sure the 'workdir' variable at the top of this script points to"
echo " a directory that is writable by the user running this script."
echo
exit 1
else
echo
echo ":-) File successfully downloaded."
echo " Running AniDB.net WebAOM client."
echo
${javawsbin} "${workdir}/webaom.jnlp"
echo
fi
}
########################
### [ MAGICAL SOUP ] ###
########################
# let's start with a blank screen
clear
# display script header
echo
echo "+--------------------------------------------------"
echo "| AniDB Java WebAOM (Anime-O-Matic) Downloader"
echo "| version: ${scriptversion} (${scriptlastedit})"
echo "| by: ${scriptauthor}"
echo "| web: ${scriptsite}"
echo
# step 1: check for required possibly not installed by default binaries to operate script.
waom_test_util_requirements
# step 2: test for work directory. create if needed.
waom_check_work_directory
# step 3: try to download .jnlp file and run it
waom_download_run_webaom