Switch gears, use installer script

This commit is contained in:
Salt 2020-06-24 10:38:24 -05:00
parent 8e9f6a9582
commit 7db2c2bbab
2 changed files with 40 additions and 20 deletions

View File

@ -70,30 +70,17 @@
remote_src: yes
dest: "/var/minecraft/{{ mcname }}"
notify: "restart minecraft {{ mcname }}"
- name: Look for MultiMC pack
find:
path: "/var/minecraft/{{ mcname }}"
patterns: '.minecraft'
ignore_errors: yes
register: find_multimc
- name: Move .minecraft contents to root
- name: Template out install script
template:
src: "install.sh"
dest: "/var/minecraft/{{ mcname }}/install.sh"
- name: Run install script
command:
chdir: "/var/minecraft/{{ mcname }}"
argv:
- mv
- "/var/minecraft/{{ mcname }}/*/.minecraft/*"
- "."
- bash
- "./install.sh"
notify: "restart minecraft {{ mcname }}"
when: not find_multimc is failed
- name: Remove MultiMC artifacts
file:
path: "{{ item }}"
state: absent
loop:
- "/var/minecraft/{{ mcname }}/.minecraft"
- "/var/minecraft/{{ mcname }}/instance.cfg"
- "/var/minecraft/{{ mcname }}/mmc-pack.json"
when: not find_multimc is failed
when: get_mcpack is changed
- name: Check for Forge
stat:

View File

@ -0,0 +1,33 @@
#! /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
mv "$packdir"/* .
exit 0