fix_ct.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # LinuxGSM fix_ct.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Resolves issues with Craftopia.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. if [ -f "${servercfgfullpath}" ]; then
  9. savepath="$(sed -n 's/^savePath=//p' "${servercfgfullpath}" | tr -d '\r')"
  10. if [ -n "${savepath}" ] && [ "${savepath:0:1}" != "/" ]; then
  11. oldsavedir="${serverfiles}${savepath%/}"
  12. newsavedir="${serverfiles}/${savepath%/}"
  13. if [ -e "${oldsavedir}" ] && [ -e "${newsavedir}" ]; then
  14. fn_print_warn_nl "Craftopia saves found in both ${oldsavedir} and ${newsavedir}"
  15. fn_script_log_warn "Craftopia saves found in both ${oldsavedir} and ${newsavedir}"
  16. echo -e "* Keep the one you want in ${newsavedir}, remove the other, then start again."
  17. else
  18. if [ -e "${oldsavedir}" ]; then
  19. fixname="move saves to ${newsavedir}"
  20. fn_fix_msg_start
  21. mkdir -p "$(dirname "${newsavedir}")"
  22. mv "${oldsavedir}" "${newsavedir}"
  23. exitcode=$?
  24. fn_fix_msg_end
  25. fi
  26. if [ ! -e "${oldsavedir}" ]; then
  27. fixname="savePath ${serverfiles}/${savepath}"
  28. fn_fix_msg_start
  29. sed -i "s|^savePath=[^\r]*|savePath=${serverfiles}/${savepath}|" "${servercfgfullpath}"
  30. exitcode=$?
  31. fn_fix_msg_end
  32. fi
  33. fi
  34. fi
  35. fi