Last active
July 30, 2016 19:43
-
-
Save colstrom/ca184506eef4d7417234b7818240dbb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # The MIT License (MIT) | |
| # Copyright (c) 2016 Chris Olstrom <[email protected]> | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # The above copyright notice and this permission notice shall be included in | |
| # all copies or substantial portions of the Software. | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| # THE SOFTWARE. | |
| WORKDIR=${WORKDIR:-"${PWD}"} | |
| LOGS=${LOGS:-"${WORKDIR}/logs"} | |
| FML_SERVER_LOG=${LOGS}/${FML_SERVER_LOG:-'fml-server-latest.log'} | |
| MOD_LIST=${WORKDIR}/${MOD_LIST:-'autoreject.modlist'} | |
| fml_server_log_exists() { | |
| test -f "${FML_SERVER_LOG}" | |
| } | |
| suggest_client_only_mods() { | |
| if fml_server_log_exists | |
| then | |
| cat >&2 <<EOF | |
| According to ${FML_SERVER_LOG}, the following are client-only mods and | |
| can be safely disabled: | |
| EOF | |
| awk '/client side only/ { print $7 }' "${FML_SERVER_LOG}" | |
| cat >&2 <<EOF | |
| If this list looks satisfactory, you can write it to ${MOD_LIST} like so: | |
| ${0} >${MOD_LIST} 2>/dev/null | |
| EOF | |
| else | |
| cat >&2 <<EOF | |
| Precondition Failed: ${FML_SERVER_LOG} must exist. | |
| ==================== | |
| What happened? | |
| -------------- | |
| Expected ${FML_SERVER_LOG} to be a log file, but found nothing (not | |
| even an empty file). | |
| Why did this happen? | |
| -------------------- | |
| - Logs are generated when your server runs. If you haven't launched it | |
| yet (or if you have deleted or disabled logs), this is why you have | |
| no logs. | |
| - If you are logging to somewhere other than ${LOGS}, try running: | |
| env LOGS=/path/to/your/logs ${0} | |
| Recommended Action | |
| ------------------ | |
| Launch the server at least once. | |
| EOF | |
| return 111 | |
| fi | |
| } | |
| modlist_exists() { | |
| test -f "${MOD_LIST}" | |
| } | |
| remove_mods() { | |
| if modlist_exists | |
| then | |
| cat ${MOD_LIST} | while read -r MOD | |
| do | |
| rm -vf mods/${MOD}-*.jar | |
| done | |
| else | |
| cat >&2 <<EOF | |
| Precondition Check Failed: ${MOD_LIST} must exist | |
| ========================= | |
| What happened? | |
| -------------- | |
| Expected to find a list of (zero or more) mods to remove at | |
| ${MOD_LIST}, but found nothing (not even an empty file). | |
| Why did this happen? | |
| -------------------- | |
| - You may need to create this file, if you haven't already. | |
| - If your list of mods to remove is somewhere other than ${MOD_LIST}, | |
| try running: | |
| env MOD_LIST=path/to/your/mod.list ${0} | |
| Recommended Action | |
| ------------------ | |
| - Create an empty file at ${MOD_LIST} if you have no mods you want to | |
| remove. | |
| - Place a list of mods to remove at ${MOD_LIST}. This should be a | |
| file containing one mod to remove per line. | |
| EOF | |
| return 111 | |
| fi | |
| } | |
| main() { | |
| remove_mods || suggest_client_only_mods | |
| } | |
| main |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is it?
A maintenance script for modded Minecraft servers. It reads a list of mods to remove from a file, and removes them.
When would I want this?
Notable Features