Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IFS=$'\n'
- OSUROOT="/mnt/f/Games/osu!"
- DESTROOT="/mnt/z/Backups/Games/osu"
- function packArchive() {
- Z_ACT="${1}"
- Z_FILE="${2}"
- shift 2
- "7za" "${Z_ACT}" -scrcCRC32 -stl -tzip -mx=9 -mtc=off -mcu=on "${Z_FILE}" "${@}" 2>/dev/null > /dev/null
- if [ $? -ne 0 ] && [ "${1}" == "u" ]; then
- echo "Update failed, re-creating..."
- rm -rf "${2}"
- echo "Creating $(echo ${2} | rev | cut -d'/' -f1 | rev)"
- packArchive "a" "${2}" "${3}"
- fi
- }
- function packSkins() {
- cd "${OSUROOT}/Skins"
- if [ ! -d "${DESTROOT}/Skins" ]; then
- mkdir "${DESTROOT}/Skins";
- fi
- for f in $(ls -1); do
- case "${f}" in
- "User")
- continue
- ;;
- esac
- if [ -d "${f}" ]; then
- NEWDIR="${OSUROOT}/Skins/${f}"
- cd -- "${NEWDIR}"
- OUTFILE=$(echo "${f}" | sed 's/%/\_/g;s/[+]/ /g;s/[|]/\_/g')
- FULLOUT="${DESTROOT}/Skins/${OUTFILE}.osk"
- if [ -f "${FULLOUT}" ]; then
- VERB="Updating"
- Z7ACT="u"
- else
- VERB="Creating"
- Z7ACT="a"
- fi
- echo "${VERB} ${OUTFILE}.osk"
- packArchive "${Z7ACT}" "${FULLOUT}" "."
- cd ..
- fi
- done
- }
- function packData() {
- cd "${OSUROOT}/Data"
- if [ ! -d "${DESTROOT}/Data" ]; then
- mkdir "${DESTROOT}/Data";
- fi
- for f in $(ls -1); do
- case "${f}" in
- "SubmissionCache")
- continue
- ;;
- esac
- if [ -d "${f}" ]; then
- NEWDIR="${OSUROOT}/Data/${f}"
- cd -- "${NEWDIR}"
- OUTFILE=$(echo "${f}" | sed 's/%/\_/g;s/[+]/ /g;s/[|]/\_/g')
- FULLOUT="${DESTROOT}/Data/${OUTFILE}.zip"
- if [ -f "${FULLOUT}" ]; then
- VERB="Updating"
- Z7ACT="u"
- else
- VERB="Creating"
- Z7ACT="a"
- fi
- echo "${VERB} ${OUTFILE}.zip"
- packArchive "${Z7ACT}" "${FULLOUT}" "."
- cd ..
- fi
- done
- }
- function packClient() {
- cd "${OSUROOT}"
- if [ ! -d "${DESTROOT}" ]; then
- mkdir "${DESTROOT}";
- fi
- NEWPACK=()
- for f in $(ls -1); do
- case "${f}" in
- "Data"|"Logs"|"Skins"|"Songs"|"sync.ffs_db")
- continue
- ;;
- esac
- NEWPACK+=("${f}")
- done
- NEWDIR="${OSUROOT}"
- cd -- "${NEWDIR}"
- OUTFILE="client"
- FULLOUT="${DESTROOT}/${OUTFILE}.zip"
- if [ -f "${FULLOUT}" ]; then
- VERB="Updating"
- Z7ACT="u"
- else
- VERB="Creating"
- Z7ACT="a"
- fi
- echo "${VERB} ${OUTFILE}.zip"
- packArchive "${Z7ACT}" "${FULLOUT}" "${NEWPACK[@]}"
- cd ..
- }
- function packSongs() {
- cd "${OSUROOT}/Songs"
- if [ ! -d "${DESTROOT}/Songs" ]; then
- mkdir "${DESTROOT}/Songs";
- fi
- for f in $(ls -1); do
- case "${f}" in
- "altimitmine - Twitch Friends Appreciation Song")
- continue
- ;;
- esac
- if [ -d "${f}" ]; then
- NEWDIR="${OSUROOT}/Songs/${f}"
- cd -- "${NEWDIR}"
- OUTFILE=$(echo "${f}" | sed 's/%/\_/g;s/[+]/ /g;s/[|]/\_/g')
- FULLOUT="${DESTROOT}/Songs/${OUTFILE}.osz"
- if [ -f "${FULLOUT}" ]; then
- VERB="Updating"
- Z7ACT="u"
- else
- VERB="Creating"
- Z7ACT="a"
- fi
- echo "${VERB} ${OUTFILE}.osz"
- packArchive "${Z7ACT}" "${FULLOUT}" "."
- cd ..
- fi
- done
- }
- if [ -z "${OSUEMBED}" ]; then
- if [ "$1" == "client" ]; then
- packClient;
- elif [ "$1" == "skins" ]; then
- packSkins;
- elif [ "$1" == "songs" ]; then
- packSongs;
- elif [ "$1" == "data" ]; then
- packData;
- elif [ "$1" == "all" ]; then
- packClient;
- packSkins;
- packSongs;
- packData;
- else
- echo "Usage: $0 [client|skins|songs|data|all]";
- exit 1;
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement