#!/bin/bash # # import.sh # This is a shell file that simply imports a zip file with three stages: # # Identify Mods # Install Mods # Clean Up zipDir=$HOME/server-side.zip serverDir=$HOME/minecraft_server modDir=$HOME/minecraft_server/mods # Extracting the profile unzip $zipDir -d $modDir # Grabs list of mods by parsing html file, saves to array modList=($(grep href $modDir/modlist.html | awk -F '"' '{ print $2 }' | awk -F "\/" '{ print $6 }')) # Grabs projectIDs, used for downloading projectID=($(grep projectID $modDir/manifest.json | awk -F ":" '{ print substr($2, 1, length($2)-2) }' | awk '{ print $1 }')) # Grabs fileIDs, used for downloading fileID=($(grep fileID $modDir/manifest.json | awk -F ":" '{ print substr($2, 1, length($2)-2) }' | awk '{ print $1 }')) # Download each mod for ID in $(seq 1 ${#projectID[@]}) do ID=$ID-1 link=https://www.curseforge.com/api/v1/mods/${projectID[$ID]}/files/${fileID[$ID]}/download wget -P $modDir $link mv $modDir/download $modDir/${modList[$ID]}.jar done # Cleaning up rm $modDir/modlist.html rm $modDir/manifest.json Echo "Mods have been installed!" #--