From 0b917a84532c063b595dd1205d636a4db0d9952a Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Wed, 14 Apr 2021 15:27:27 -0400 Subject: [PATCH] Add a script to update ENLIVEN mods in place. --- pull-en-mods.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 pull-en-mods.sh diff --git a/pull-en-mods.sh b/pull-en-mods.sh new file mode 100755 index 0000000..59447a5 --- /dev/null +++ b/pull-en-mods.sh @@ -0,0 +1,42 @@ +#!/bin/bash +MODS_DIR="`pwd`" +TRY_MODS_DIR="/opt/minebest/mtworlds/center/ENLIVEN/mods" +GOOD_FLAG_DIR="metatools" +if [ ! -d "$MODS_DIR/$GOOD_FLAG_DIR" ]; then + if [ -d "$TRY_MODS_DIR/$GOOD_FLAG_DIR" ]; then + echo "* changing to '$TRY_MODS_DIR' (detected; changing since no $GOOD_FLAG_DIR in $MODS_DIR)" + MODS_DIR="$TRY_MODS_DIR" + fi +fi +if [ ! -d "$MODS_DIR/$GOOD_FLAG_DIR" ]; then + echo "Error: You must run this from the mods directory such as \"$TRY_MODS_DIR\"." + exit 1 +fi + +update_mod(){ + if [ -z "$1" ]; then + echo "Error: update_mod expects a mod name." + exit 1 + fi + MOD="$1" + if [ ! -d "$MODS_DIR/$MOD" ]; then + echo "Error: update_mod expects a mod name but \"$MODS_DIR/$MOD\" doesn't exist." + exit 1 + fi + printf "* cd \"$MODS_DIR/$MOD\"..." + cd "$MODS_DIR/$MOD" + if [ $? -ne 0 ]; then + echo "FAILED" + else + echo "OK" + fi + printf "* git pull..." + sudo -u minebest git pull + if [ $? -ne 0 ]; then + echo "FAILED" + else + echo "OK" + fi +} + +update_mod metatools