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 remote_src: yes
dest: "/var/minecraft/{{ mcname }}" dest: "/var/minecraft/{{ mcname }}"
notify: "restart minecraft {{ mcname }}" notify: "restart minecraft {{ mcname }}"
- name: Look for MultiMC pack - name: Template out install script
find: template:
path: "/var/minecraft/{{ mcname }}" src: "install.sh"
patterns: '.minecraft' dest: "/var/minecraft/{{ mcname }}/install.sh"
ignore_errors: yes - name: Run install script
register: find_multimc
- name: Move .minecraft contents to root
command: command:
chdir: "/var/minecraft/{{ mcname }}" chdir: "/var/minecraft/{{ mcname }}"
argv: argv:
- mv - bash
- "/var/minecraft/{{ mcname }}/*/.minecraft/*" - "./install.sh"
- "."
notify: "restart minecraft {{ mcname }}" 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 when: get_mcpack is changed
- name: Check for Forge - name: Check for Forge
stat: 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