ansible/roles/minecraft/templates/install.sh

34 lines
859 B
Bash
Raw Normal View History

2020-06-24 10:38:24 -05:00
#! /bin/sh
#
# install.sh
# Because writing this logic in Ansible is kinda dumb
# Copyright (C) 2020 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
#
set -e
# Get to our magic dir
export MINECRAFT_DIR="/var/minecraft/{{ mcname }}"
cd "$MINECRAFT_DIR" || exit 50
# If the mods and config directories exist, we don't need to do anything
# We make the inference here because the previous step of the playbook removed them
if [ -d "mods" ]; then
exit 0
fi
# MultiMC packs are organized as such:
# ./Pack Name/.minecraft/{mods,configs,etc.}
# ./Pack Name/minecraft/{mods,configs,etc.}
# I'm going to elect not to support the latter just for the sake of my sanity
packdir="$(find -type d -iname ".minecraft" | head -n 1)"
if ! [ -d "$packdir" ]; then
exit 51
fi
# Just move the shit out 4head
2020-06-24 23:39:14 -05:00
mv -f "$packdir"/* .
2020-06-24 10:38:24 -05:00
exit 0