From 433e35e79b17019f1447f277f40a6a70fbc2353c Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 22 Apr 2021 02:57:00 +0000 Subject: [PATCH] Add update script --- run_linux.sh | 6 ++++ update_linux.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100755 update_linux.sh diff --git a/run_linux.sh b/run_linux.sh index a4c005c..243c9da 100755 --- a/run_linux.sh +++ b/run_linux.sh @@ -2,6 +2,12 @@ set -eu +if [ ! -d "mosfet" ] +then + echo "You must run this from the mosfet-minecraft-bot directory." + exit +fi + if ! command -v virtualenv &> /dev/null then echo "virtualenv could not be found, please install with:" diff --git a/update_linux.sh b/update_linux.sh new file mode 100755 index 0000000..5f49bdc --- /dev/null +++ b/update_linux.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +set -eu + +if [ ! -d "mosfet" ] +then + echo "You must run this from the mosfet-minecraft-bot directory." + exit +fi + +if ! command -v virtualenv &> /dev/null +then + echo "virtualenv could not be found, please install with:" + echo "sudo apt install python3-virtualenv" + exit +fi + +if ! command -v wget &> /dev/null +then + echo "wget could not be found, please install with:" + echo "sudo apt install wget" + exit +fi + +if ! command -v unzip &> /dev/null +then + echo "unzip could not be found, please install with:" + echo "sudo apt install unzip" + exit +fi + +if ! command -v python3 &> /dev/null +then + echo "python3 could not be found, please install with:" + echo "sudo apt install python3" + exit +fi + +if ! command -v pip3 &> /dev/null +then + echo "pip3 could not be found, please install with:" + echo "sudo apt install pip3" + exit +fi + +if ! command -v git &> /dev/null +then + echo "git could not be found, please install with:" + echo "sudo apt install pip3" + exit +fi + + +# download minecraft data + +echo "Grabbing minecraft data..." +sleep 2 + +VERSION="1.16.4" + +wget -Omcdata.zip "https://apimon.de/mcdata/$VERSION/$VERSION.zip" +rm -r minecraft_data || true +mkdir minecraft_data +unzip mcdata.zip -d minecraft_data +rm mcdata.zip + + +# update code + +git stash +git pull --rebase +git stash pop || true + + +# create virtual environment + +echo "Installing Python requirements..." +sleep 2 + +rm -r env || true +rm -r __pycache__ || true +virtualenv -p python3 env +source env/bin/activate +pip install -r requirements.txt + + +echo "Done."