2021-10-25 16:09:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
# Authors: 2021 Petr Menšík <pemensik@fedoraproject.org>
|
|
|
|
|
|
|
|
ETHOME="$HOME/.etlegacy"
|
|
|
|
ETMAIN="$ETHOME/etmain"
|
|
|
|
FOUNDPAK=
|
|
|
|
DATAPAGE=/usr/share/etlegacy/etlegacy-data.html
|
2021-10-25 22:07:43 +00:00
|
|
|
INSTALLER="$(type -p etl-installer 2>/dev/null)"
|
2021-10-25 16:09:07 +00:00
|
|
|
|
|
|
|
[ -d "$ETHOME" ] || mkdir -p "$ETHOME"
|
|
|
|
[ -d "$ETMAIN" ] || mkdir "$ETMAIN"
|
|
|
|
|
2021-10-25 22:07:43 +00:00
|
|
|
show_instructions() {
|
|
|
|
exec xdg-open "$DATAPAGE"
|
|
|
|
}
|
|
|
|
|
2023-03-17 13:00:34 +00:00
|
|
|
# First option argument is variant. Others are passed to the executable
|
2021-10-25 22:07:43 +00:00
|
|
|
start_game() {
|
2023-03-17 13:00:34 +00:00
|
|
|
local VARIANT="${1:-}"
|
|
|
|
[ "$#" -gt 0 ] && shift
|
|
|
|
exec /usr/bin/etl${VARIANT} "$@"
|
2021-10-25 22:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_installer() {
|
|
|
|
if tty 2>/dev/null; then
|
|
|
|
"$INSTALLER" && return 0
|
|
|
|
else
|
|
|
|
# In graphical session, try running it in terminal
|
|
|
|
# Do not care about errors here
|
|
|
|
# FIXME: is there better way to run command in terminal? Something like xdg-open?
|
|
|
|
gnome-terminal --title "ET Legacy data installer" -- "$INSTALLER" && return 0
|
|
|
|
konsole "$INSTALLER" && return 0
|
|
|
|
uxterm "$INSTALLER" && return 0
|
|
|
|
xterm "$INSTALLER" && return 0
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2021-10-25 16:09:07 +00:00
|
|
|
for PAK in etmain/pak{0,1,2}.pk3
|
|
|
|
do
|
|
|
|
if ! [ -f "$ETHOME/$PAK" ]; then
|
|
|
|
[ -L "$ETHOME/$PAK" ] && rm "$ETHOME/$PAK"
|
|
|
|
for DIR in /usr{,/local}{,/games}/enemy-territory/ $ETHOME
|
|
|
|
do
|
|
|
|
[ "$DEBUG" = y ] && echo "Checking $DIR/$PAK"
|
|
|
|
if [ -f "$DIR/$PAK" ] && ! [ -L "$DIR/$PAK" ]; then
|
|
|
|
FOUNDPAK=Y
|
|
|
|
echo "Found $DIR/$PAK"
|
|
|
|
(cd $ETMAIN && ln -vs "$DIR/$PAK")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
FOUNDPAK=Y
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2021-10-25 22:07:43 +00:00
|
|
|
if [ -z "$FOUNDPAK" ]; then
|
|
|
|
echo "pak[012].pk3 data not found!"
|
|
|
|
if [ -x "$INSTALLER"]; then
|
2023-03-17 13:00:34 +00:00
|
|
|
start_installer && start_game "$@"
|
2021-10-25 22:07:43 +00:00
|
|
|
# Would terminate here on success
|
|
|
|
fi
|
|
|
|
if [ -f "$DATAPAGE" ]; then
|
|
|
|
show_instructions
|
|
|
|
fi
|
2021-10-25 16:09:07 +00:00
|
|
|
fi
|
2023-03-17 13:00:34 +00:00
|
|
|
start_game "$@"
|