mirror of
https://port.numenaute.org/aleajactaest/bazar_alea.git
synced 2024-11-09 16:59:02 +00:00
114 lines
2.3 KiB
Bash
114 lines
2.3 KiB
Bash
|
#!/bin/bash
|
||
|
#
|
||
|
# Script to launch server
|
||
|
#
|
||
|
# Copyright (C) 2023 AleaJactaEst
|
||
|
#
|
||
|
# This program is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, either version 3 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
#
|
||
|
declare DEBUG=0
|
||
|
declare HELP=0
|
||
|
declare BUILD=0
|
||
|
declare WORKDIR="$(dirname $(readlink -f $0))"
|
||
|
declare RUSTDIR="$WORKDIR/.rust"
|
||
|
declare SERVERDIR="$WORKDIR/server"
|
||
|
|
||
|
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 byebye()
|
||
|
{
|
||
|
local CODE=$?
|
||
|
if [ $CODE -ne 0 ]
|
||
|
then
|
||
|
msg_error "return code:$code"
|
||
|
else
|
||
|
msg_info "End"
|
||
|
fi
|
||
|
exit $CODE
|
||
|
}
|
||
|
|
||
|
while getopts hdb flag
|
||
|
do
|
||
|
case "${flag}" in
|
||
|
h) HELP=1;;
|
||
|
d) DEBUG=1;;
|
||
|
b) BUILD=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
|
||
|
-b : (re)build program
|
||
|
EOF
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
trap byebye EXIT
|
||
|
|
||
|
msg_info "Start"
|
||
|
msg_debug "WORKDIR:$WORKDIR"
|
||
|
|
||
|
|
||
|
if [[ ($BUILD -ne 0) || (! -x $SERVERDIR/target/debug/server) ]]
|
||
|
then
|
||
|
export CARGO_HOME="$RUSTDIR/.cargo"
|
||
|
export RUSTUP_HOME="$RUSTDIR/.rustup"
|
||
|
|
||
|
mkdir -p $RUSTDIR
|
||
|
if [ ! -f $RUSTDIR/install.sh ]
|
||
|
then
|
||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > $RUSTDIR/install.sh
|
||
|
fi
|
||
|
if [ ! -f $RUSTDIR/.cargo/env ]
|
||
|
then
|
||
|
sh .rust/install.sh -t $RUSTDIR/.cargo --no-modify-path -y
|
||
|
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -h
|
||
|
fi
|
||
|
if [ -f $RUSTDIR/.cargo/env ]
|
||
|
then
|
||
|
source $RUSTDIR/.cargo/env
|
||
|
cd $SERVERDIR
|
||
|
cargo build
|
||
|
else
|
||
|
msg_error "Error to load envi rust"
|
||
|
exit 2
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
$SERVERDIR/target/debug/server
|
||
|
|
||
|
# END (call function byebye)
|