7 echo "Oracle Spoiler Manager (by) Caelyl <caelyl@gmail.com>
8 A script to manage Oracle card data spoilers for Magic: The Gathering.
10 Usage: mtgspoiler < [ -? | --help ] | [ -d | --defaultdir ] | directory > ...
13 This script will download the current Oracle spoiler in full from the Gatherer
14 online database (http://ww2.wizards.com/gatherer/index.aspx) and format it as a
15 flatfile database for use with Mindless Automaton. The filename will be
16 generated of the form 'oracle-MMddYYYY.txt', and a symlink 'oracle.txt' will be
22 Show this usage information.
25 Use the default directory of '/usr/share/mindless'.
28 The directory in which to place the spoiler and symlink.
31 Suppress the warning about an invalid or missing directory.
33 The default spoiler directory is used if [ directory ] is either not specified
34 or is invalid." |
less
37 echo "Could not create directory '${_directory}'. Aborting."
40 echo "This script is designed to run as a non-root user. Users must be in the 'games'
41 group in order to use this script without specifying an alternate starting
42 directory. (see 'mtgspoiler -?' for help on how to use the script)"
50 mkdir
-p "${_directory}" || die nomakedir
57 if [[ "${_quiet}" = 0 ]]; then
58 echo "Warning: No directory specified, defaulting to '/usr/share/mindless'."
62 echo "Warning: Invalid directory specified. Create it (else default to
63 '/usr/share/mindless')? [y/n]"
64 if [[ "${_quiet}" = 0 ]]; then
69 if [[ "${_reply}" = "y" ]]; then
74 if [[ "${_quiet}" = 0 ]]; then
75 echo "Warning: Default directory ('/usr/share/mindless') does not exist.
85 if [[ "${_username}" = "root" ]]; then
88 wget
-O "${_spoiler}" "${_livespoiler}"
89 sed -n -i -e '/xmp/,/xmp/p' "${_spoiler}"
90 sed -i -e '/xmp/d' "${_spoiler}"
91 ln -sf "${_spoiler}" "${_spoilerlink}"
92 chown
:games
"${_spoiler}" "${_spoilerlink}"
93 chmod a
=r
,ug
+w
"${_spoiler}"
98 echo wget
-O "${_spoiler}" "${_livespoiler}"
99 echo sed -n -i -e '/xmp/,/xmp/p' "${_spoiler}"
100 echo sed -i -e '/xmp/d' "${_spoiler}"
101 echo ln -sf "${_spoiler}" "${_spoilerlink}"
102 echo chown
:games
"${_spoiler}"
103 echo chmod a
=r
,ug
+w
"${_spoiler}"
112 for _argument
in ${*}; do
113 case "${_argument}" in
120 "-d" |
"--defaultdir" )
121 _directory
=/usr
/share
/mindless
127 _directory
="${_argument}"
132 if [[ -z "${_directory}" ]]; then
134 elif [[ ! -d "${_directory}" ]]; then
137 if [[ ! -z "${_warntype}" ]]; then
141 if [[ ! -d "${_directory}" ]] ||
[[ -z "${_directory}" ]]; then
142 _directory
=/usr
/share
/mindless
144 if [[ ! -d "${_directory}" ]]; then
147 if [[ ! -z "${_warntype}" ]]; then
152 if [[ ${_directory: -1} = "/" ]]; then
153 _safedirectory
=${_directory:0:${#_directory}-1}
155 _safedirectory
=${_directory}
157 _spoiler
=${_safedirectory%/}/oracle-
`date +%m%e%Y`.txt
158 _spoilerlink
=${_safedirectory%/}/oracle.txt
159 _livespoiler
="http://ww2.wizards.com/gatherer/index.aspx?term=%20&Field_Name=on&Field_Rules=on&Field_Type=on&setfilter=All%20sets&output=Oracle%20Spoiler"
161 if [[ "${_debug}" = 0 ]]; then