|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# Author: Castro-Fidel (linux-gaming.ru)
|
|
|
|
|
# License MIT
|
|
|
|
|
########################################################################
|
|
|
|
|
unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL
|
|
|
|
|
export portname="PortProton"
|
|
|
|
|
export port_ver=1.0
|
|
|
|
|
########################################################################
|
|
|
|
|
export NO_AT_BRIDGE=1
|
|
|
|
|
ENG_LANG="English"
|
|
|
|
|
RUS_LANG="Russian"
|
|
|
|
|
[ -z "${LANG}" ] && export LANG=C
|
|
|
|
|
deflink="${HOME}/PortWINE/${portname}"
|
|
|
|
|
[ "$(id -u)" -eq 0 ] && echo "This script should NOT be run by root!" && zenity --error --text "This script should NOT be run by root!" 2> /dev/null && exit 1
|
|
|
|
|
my_dir=$(dirname "$(readlink -f "$0")")
|
|
|
|
|
if [ "$my_dir" == "/usr/bin" ] ; then
|
|
|
|
|
[ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share"
|
|
|
|
|
if [ -f "${XDG_DATA_HOME}/PortWINE/PortProton/data/scripts/start.sh" ] ; then
|
|
|
|
|
/usr/bin/env bash "${XDG_DATA_HOME}/PortWINE/PortProton/data/scripts/start.sh" "$@"
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
if [ -n "$(locale | grep "LANG=ru_RU.UTF-8")" ] ; then
|
|
|
|
|
PW_SET_LANG=$RUS_LANG
|
|
|
|
|
else
|
|
|
|
|
PW_SET_LANG=$ENG_LANG
|
|
|
|
|
fi
|
|
|
|
|
export PW_SILENT_INSTALL="1"
|
|
|
|
|
export PW_AUTOPLAY=1
|
|
|
|
|
deflink="${XDG_DATA_HOME}/PortWINE/${portname}"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
########################################################################
|
|
|
|
|
export INSTALLING_PORT=1
|
|
|
|
|
export PROGS_INST=""
|
|
|
|
|
export vexit=0
|
|
|
|
|
########################################################################
|
|
|
|
|
for PROGS in "wget" "curl" "tar" "awk" "zenity" "cabextract" "pidof" ; do
|
|
|
|
|
if [ ! -x "$(command -v "${PROGS}" 2>/dev/null)" ] ; then
|
|
|
|
|
PROGS_INST="${PROGS_INST} ${PROGS}" && vexit=1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
if [ "${vexit}" -eq "1" ] ; then
|
|
|
|
|
echo "You will need to install: ${PROGS_INST}, and restart the script"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
########################################################################
|
|
|
|
|
cd "$my_dir"
|
|
|
|
|
export links
|
|
|
|
|
links="$(pwd)"
|
|
|
|
|
########################################################################
|
|
|
|
|
if [ "$1" = "-rus" ] ; then
|
|
|
|
|
PW_SET_LANG=$RUS_LANG
|
|
|
|
|
export PW_SILENT_INSTALL="1"
|
|
|
|
|
elif [ "$1" = "-eng" ] ; then
|
|
|
|
|
PW_SET_LANG=$ENG_LANG
|
|
|
|
|
export PW_SILENT_INSTALL="1"
|
|
|
|
|
elif [ -z "${PW_SET_LANG}" ] ; then
|
|
|
|
|
PW_SET_LANG=$(zenity --title "Install $portname" --text "Select installation language:" --list --radiolist \
|
|
|
|
|
--column="" --column "Language" \
|
|
|
|
|
TRUE "$RUS_LANG" \
|
|
|
|
|
FALSE "$ENG_LANG" ) 2> /dev/null
|
|
|
|
|
if [ $? -eq 1 ] ; then echo "Installation language not set!" && exit 1 ; fi
|
|
|
|
|
case $PW_SET_LANG in
|
|
|
|
|
"$RUS_LANG")
|
|
|
|
|
INFO_TEXT="Вы запустили установщик ${portname} версии ${port_ver}. \n\nЭто некоммерческий продукт и развивается исключительно за идею и Ваши пожертвования. \nВсе права стороннего программного обеспечения принадлежат их владельцам! \nПродолжая установку, Вы автоматически соглашаетесь с данными условиями." > /dev/null 2>&1 ;;
|
|
|
|
|
"$ENG_LANG")
|
|
|
|
|
INFO_TEXT="You’ve started ${portname} installer v.${port_ver}. \n\nIt is a non-commercial product and is developed only for the idea and with the help of your donations. \nAll third-party software rights belong to their respective owners! \nIf you continue installation, you agree to these terms." > /dev/null 2>&1 ;;
|
|
|
|
|
esac
|
|
|
|
|
zenity --info --title "INFO" --text "$INFO_TEXT" --no-wrap 2> /dev/null
|
|
|
|
|
if [ $? -eq 1 ] ; then echo "INFO message not displayed!" && exit 1 ; fi
|
|
|
|
|
fi
|
|
|
|
|
########################################################################
|
|
|
|
|
if [ "${PW_SILENT_INSTALL}" = "1" ] ; then
|
|
|
|
|
echo "${portname} is installed in ${deflink}"
|
|
|
|
|
D_PATH="${deflink}"
|
|
|
|
|
else
|
|
|
|
|
case $PW_SET_LANG in
|
|
|
|
|
"$RUS_LANG")
|
|
|
|
|
inst1=$(zenity --title "Установка ${portname}" --text "Выберите путь для установки (обновления) ${portname} \nили оставьте его по умолчанию." --list --radiolist --width=350 --height=220 \
|
|
|
|
|
--column="" --column "Путь:" \
|
|
|
|
|
TRUE "${deflink}" \
|
|
|
|
|
FALSE "Другой путь..." ) 2> /dev/null
|
|
|
|
|
if [ $? -eq 1 ] ; then echo "Installation path not set!" && exit 1 ; fi
|
|
|
|
|
case $inst1 in
|
|
|
|
|
"${deflink}")
|
|
|
|
|
D_PATH="${deflink}" ;;
|
|
|
|
|
"Другой путь...")
|
|
|
|
|
D_PATH=$(zenity --file-selection --directory --title="Выберите путь..." )
|
|
|
|
|
D_PATH="${D_PATH}/${portname}" ;;
|
|
|
|
|
esac ;;
|
|
|
|
|
"$ENG_LANG")
|
|
|
|
|
inst1=$(zenity --title "Install ${portname}" --text "Choose path to install (update) ${portname} \nor leave it as default." --list --radiolist --width=350 --height=220 \
|
|
|
|
|
--column="" --column "Path:" \
|
|
|
|
|
TRUE "${deflink}" \
|
|
|
|
|
FALSE "Other path..." ) 2> /dev/null
|
|
|
|
|
if [ $? -eq 1 ] ; then echo "Installation path not set!" && exit 1; fi
|
|
|
|
|
case $inst1 in
|
|
|
|
|
"${deflink}")
|
|
|
|
|
D_PATH="${deflink}" ;;
|
|
|
|
|
"Other path...")
|
|
|
|
|
D_PATH=$(zenity --file-selection --directory --title="Choose your path..." )
|
|
|
|
|
D_PATH="${D_PATH}/${portname}" ;;
|
|
|
|
|
esac ;;
|
|
|
|
|
esac
|
|
|
|
|
if [ $? -eq 1 ] ; then echo "error" && exit 1 ; fi
|
|
|
|
|
fi
|
|
|
|
|
########################################################################
|
|
|
|
|
case $PW_SET_LANG in
|
|
|
|
|
"$RUS_LANG")
|
|
|
|
|
progress_bar() {
|
|
|
|
|
zenity --progress --title="Установка..." --text="Установка ${portname}" --pulsate --auto-close --auto-kill --width=450 > /dev/null 2>&1
|
|
|
|
|
} ;;
|
|
|
|
|
"$ENG_LANG")
|
|
|
|
|
progress_bar() {
|
|
|
|
|
zenity --progress --title="Install..." --text="Install ${portname}" --pulsate --auto-close --auto-kill --width=450 > /dev/null 2>&1
|
|
|
|
|
} ;;
|
|
|
|
|
esac
|
|
|
|
|
########################################################################
|
|
|
|
|
export PORT_WINE_PATH="${D_PATH}"
|
|
|
|
|
scripts_dir="${PORT_WINE_PATH}/data/scripts"
|
|
|
|
|
if [ ! -d "${PORT_WINE_PATH}" ] ; then
|
|
|
|
|
mkdir -p "$PORT_WINE_PATH"
|
|
|
|
|
else
|
|
|
|
|
rm -fr "${PORT_WINE_PATH}/data/tmp"
|
|
|
|
|
rm -f "${scripts_dir}/"* > /dev/null 2>&1
|
|
|
|
|
fi
|
|
|
|
|
########################################################################
|
|
|
|
|
mkdir -p "${PORT_WINE_PATH}/data/tmp"
|
|
|
|
|
echo "${port_ver}" > "${PORT_WINE_PATH}/data/tmp/${portname}_ver"
|
|
|
|
|
case $PW_SET_LANG in
|
|
|
|
|
"$RUS_LANG") echo "RUS" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;;
|
|
|
|
|
"$ENG_LANG") echo "ENG" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;;
|
|
|
|
|
esac
|
|
|
|
|
########################################################################
|
|
|
|
|
export PORT_WINE_TMP_PATH="${PORT_WINE_PATH}/data/tmp"
|
|
|
|
|
cd "${PORT_WINE_PATH}"
|
|
|
|
|
try_download_scripts () {
|
|
|
|
|
wget -O "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -nd -c --read-timeout 300 \
|
|
|
|
|
--retry-connrefused --timeout 15 --tries 3 \
|
|
|
|
|
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" \
|
|
|
|
|
"https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz"
|
|
|
|
|
if [ "$?" = "0" ] ; then
|
|
|
|
|
tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}"
|
|
|
|
|
if [ "$?" = "0" ] ; then
|
|
|
|
|
[ ! -d "${PORT_WINE_PATH}/data/" ] && mkdir "${PORT_WINE_PATH}/data/"
|
|
|
|
|
cp -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/data_from_portwine/"* "${PORT_WINE_PATH}/data/"
|
|
|
|
|
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
|
|
|
|
|
rm -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/"
|
|
|
|
|
export scripts_current_ver
|
|
|
|
|
scripts_current_ver=$(cat "${scripts_dir}/var" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}')
|
|
|
|
|
echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
|
|
|
|
|
else
|
|
|
|
|
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
|
|
|
|
|
try_download_scripts
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
try_download_scripts
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
if [ "${PW_SILENT_INSTALL}" = "1" ] && [ ! -f "/usr/bin/portproton" ] ; then
|
|
|
|
|
try_download_scripts
|
|
|
|
|
else
|
|
|
|
|
try_download_scripts | progress_bar
|
|
|
|
|
fi
|
|
|
|
|
chmod 755 -R "${PORT_WINE_PATH}"
|
|
|
|
|
########################################################################
|
|
|
|
|
cd "${scripts_dir}"
|
|
|
|
|
/usr/bin/env bash "${scripts_dir}/setup.sh" && exit 0
|