53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Fetch and update minetest mod. Read all the comments!
|
|
#
|
|
# Created by: Amy Moriyama amymoriyama84@gmail.com
|
|
|
|
|
|
|
|
|
|
# set this variable to your mods folder
|
|
mods="/home/username/Programs/minetest-server/worlds/world/worldmods2/"
|
|
|
|
current="$(echo $PWD)"
|
|
|
|
if [ -z "$1" ]
|
|
then
|
|
echo 'You need to use a mod name! ./fetch.sh mobs_redo for example' >&2
|
|
echo "If just the mod_name returns multiple results, you can also"
|
|
echo "do ./fetch.sh mod_name gitusername"
|
|
exit 1
|
|
else
|
|
echo "Proceeding... =^..^="
|
|
fi
|
|
|
|
url="$(grep "$1" $current/mods | sed 's/^.*|//' | grep "$2")"
|
|
|
|
if [ -z "$url" ]
|
|
then
|
|
echo 'Please check if mod is supported in the mod file' >&2
|
|
exit 1
|
|
else
|
|
echo "(-(-_(-_-)_-)-)"
|
|
fi
|
|
|
|
cd "$mods"
|
|
name="$(grep $1 $current/mods | sed 's/|.*//g')"
|
|
proj="$(echo "$url" | cut -c 9- | rev | cut -c 5- | rev | awk '{print $NF}' FS=/)"
|
|
if [[ -d "$name" ]]
|
|
then
|
|
echo "$name exists, updating it (\/)(;,,;)(\/)"
|
|
cd $name
|
|
git pull
|
|
else
|
|
echo "$proj does not exist ♪┏(°.°)┛┗(°.°)┓┗(°.°)┛┏(°.°)┓ ♪"
|
|
git clone "$url"
|
|
if [[ $proj != $name ]]; then
|
|
echo "git folder not named properly, fixing (╯°□°)╯ ︵ ┻━┻"
|
|
mv $proj $name
|
|
fi
|
|
fi
|
|
|
|
echo "<(''<) <( ' ' )> (> '')>"
|