godot-third-person-basic-scene/start-khanat-client.sh

157 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
declare DEBUG=0
declare HELP=0
declare EDITOR=0
declare FORCE=0
2022-03-06 17:15:34 +00:00
declare IMPORT=0
2022-03-28 20:44:23 +00:00
declare ERASEIMPORT=0
declare WORKDIR="$(dirname $(readlink -f $0))"
2022-09-06 22:27:28 +00:00
declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/4.0/alpha14/Godot_v4.0-alpha14_linux.64.zip"
2022-02-12 13:16:26 +00:00
declare OUTZIP="$WORKDIR/$(basename $GODOT_SRC)"
declare OPTION=""
2022-03-31 20:26:32 +00:00
declare NEWPRG=0
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 [[ $FORCE -eq 0 && -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 $package -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
fileout=$(unzip -Z1 $compressed_file)
if [[ $FORCE -eq 0 && -f $fileout ]]
then
echo $fileout
return 0
fi
unzip -u $compressed_file -d $WORKDIR 1>&2
if [ $? -eq 0 ]
then
msg_info "Uncompressed GODOT"
echo $fileout
2022-03-31 20:26:32 +00:00
NEWPRG=1
return 0
fi
fi
msg_error "Impossible to extract"
exit 2
}
2022-03-31 20:26:32 +00:00
while getopts hdeo:s:fix flag
do
case "${flag}" in
h) HELP=1;;
d) DEBUG=1;;
e) EDITOR=1;;
o) OUTZIP=${OPTARG};;
s) GODOT_SRC=${OPTARG};;
f) FORCE=1;;
2022-03-06 17:15:34 +00:00
i) IMPORT=1;;
2022-03-28 20:44:23 +00:00
x) ERASEIMPORT=1;;
*) 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
-f : force download & uncompress
2022-03-06 17:15:34 +00:00
-i : force import data
2022-03-28 20:44:23 +00:00
-x : erase import data
-o <File> : target godot file (downloaded)
-s <Url> : Url to download a specific godot version
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"
2022-03-31 20:26:32 +00:00
if [ $NEWPRG -ne 0 ]
then
ERASEIMPORT=1
IMPORT=1
fi
2022-03-28 20:44:23 +00:00
if [ $ERASEIMPORT -ne 0 ]
then
rm -f $WORKDIR/.godot/imported/*
fi
2022-03-31 20:26:32 +00:00
if [[ ($IMPORT -ne 0) || (! -d $WORKDIR/.godot) ]]
2022-03-06 17:15:34 +00:00
then
2022-04-15 07:53:44 +00:00
echo "Launch import (please wait)"
2022-03-06 17:15:34 +00:00
$WORKDIR/$EXE --editor --quit
2022-04-15 07:53:44 +00:00
echo "Import finished"
2022-03-06 17:15:34 +00:00
fi
if [ $EDITOR -ne 0 ]
then
OPTION="$OPTION -e"
fi
$WORKDIR/$EXE $OPTION
2022-03-06 17:15:34 +00:00
msg_info "End"