Advertisement
McModder

[OpenTTD] xUSSR Set updater

Jul 20th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # The MIT License (MIT)
  4.  
  5. # Copyright (c) 2017 mcmodder
  6.  
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. # The above copyright notice and this permission notice shall be included in all
  14. # copies or substantial portions of the Software.
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22.  
  23. # This script will download latest xUSSR Set version.
  24. # Used files: .xussr.ver with current xUSSR Set version; xussr.tar with xUSSR Set, both in ~/.openttd/newgrf
  25.  
  26. _NEWGRF_PATH="$HOME/.openttd/newgrf/"
  27. [ ! -e "${_NEWGRF_PATH}xussr.tar" ] && rm -f "${_NEWGRF_PATH}.xussr.ver"
  28.  
  29. _VERSION_DATA=$(curl -sL http://bundles.openttdcoop.org/xussrset/push/LATEST/custom_tags.txt)
  30. _XUSSR_REMOTE=$( grep NEWGRF_VERSION <<<"$_VERSION_DATA" | cut -f2 -d':' )
  31. _XUSSR_DATE=$( grep REPO_DATE <<<"$_VERSION_DATA" | cut -f2 -d':' )
  32. _XUSSR_INSTALLED=$(<"${_NEWGRF_PATH}.xussr.ver") 2>/dev/null && echo "Installed xUSSR Set version: r${_XUSSR_INSTALLED}"
  33. echo "Latest xUSSR Set version: r$_XUSSR_REMOTE"
  34.  
  35. [ ! -e "${_NEWGRF_PATH}xussr.tar" ] && _XUSSR_INSTALLED=""
  36. if [ "${_XUSSR_INSTALLED}" != "${_XUSSR_REMOTE}" ]; then
  37.   echo "Downloading xUSSR Set r${_XUSSR_REMOTE}..."
  38.   curl -qL "http://bundles.openttdcoop.org/xussrset/push/LATEST/xussr-r${_XUSSR_REMOTE}.zip" | funzip > "${_NEWGRF_PATH}xussr.tar"
  39.   echo "${_XUSSR_REMOTE}" > "${_NEWGRF_PATH}.xussr.ver"
  40.   echo "Downloaded xUSSR Set r${_XUSSR_REMOTE} (released ${_XUSSR_DATE})"
  41.   echo "View changelog at http://dev.openttdcoop.org/projects/xussrset/repository/changes"
  42. else
  43.   echo "Nothing to do"
  44. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement