From b39a76d6bd86f8b4f06a5db8fcc364cb3fd6bfa0 Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sun, 16 Jan 2022 22:41:19 +0100 Subject: [PATCH] adding script to launch godot & khanat client --- .gitignore | 3 ++ start-khanat-client.sh | 118 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100755 start-khanat-client.sh diff --git a/.gitignore b/.gitignore index 950df47..64e44a3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ libgdnative.*.so # Ignore temp temp/ + +# Ignore Godot.zip & Godot* +Godot* diff --git a/start-khanat-client.sh b/start-khanat-client.sh new file mode 100755 index 0000000..3ddbf28 --- /dev/null +++ b/start-khanat-client.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +declare DEBUG=0 +declare HELP=0 +declare EDITOR=0 +declare WORKDIR="$(dirname $(readlink -f $0))" +declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/3.4.2/Godot_v3.4.2-stable_x11.64.zip" +declare OUTZIP="$WORKDIR/Godot.zip" +declare OPTION="" + +function msg_debug() +{ + if [ $DEBUG -ne 0 ] + then + echo "### DEBUG : $*" >&2 + fi +} + +function msg_info() +{ + echo "--- INFO : $*" >&2 +} + +function msg_error() +{ + echo "*** ERROR : $*" >&2 +} + +function download() +{ + local package="$1" + local out="$2" + if [ -f $2 ] + then + return 0 + fi + which curl 1>/dev/null 2>/dev/null + if [ $? -eq 0 ] + then + curl -o $out $package + if [ $? -eq 0 ] + then + msg_info "Package GODOT downloaded" + return 0 + fi + fi + which wget 1>/dev/null 2>/dev/null + if [ $? -eq 0 ] + then + wget https://downloads.tuxfamily.org/godotengine/3.4.2/Godot_v3.4.2-stable_x11.64.zip -O $out + if [ $? -eq 0 ] + then + msg_info "Package GODOT downloaded" + return 0 + fi + fi + msg_error "Impossible to download" + exit 2 +} + +function extract() +{ + local compressed_file="$1" + which unzip 1>/dev/null 2>/dev/null + if [ $? -eq 0 ] + then + unzip -u $compressed_file -d $WORKDIR 1>&2 + if [ $? -eq 0 ] + then + msg_info "Uncompressed GODOT" + unzip -Z1 $compressed_file + return 0 + fi + fi + msg_error "Impossible to extract" + exit 2 +} + + +while getopts hdeo:s: flag +do + case "${flag}" in + h) HELP=1;; + d) DEBUG=1;; + e) EDITOR=1;; + o) OUTZIP=${OPTARG};; + s) GODOT_SRC=${OPTARG};; + *) HELP=1;; + esac +done + +if [[ $HELP -ne 0 ]] +then + cat << EOF +$(basename $0) [Option] : Donwload Launch Godot + Option: + -h : Show help + -d : Show debug message + -e : Start Godot in editor mode +EOF + exit 1 +fi + +msg_info "Start" +msg_debug "WORKDIR:$WORKDIR OUTZIP:$OUTZIP GODOT_SRC:$GODOT_SRC" +download "$GODOT_SRC" "$OUTZIP" +EXE=$(extract "$OUTZIP") +msg_info "Prg:$EXE" + +if [ $EDITOR -ne 0 ] +then + OPTION="$OPTION -e" +fi + +$WORKDIR/$EXE $OPTION + + +msg_info "End"