Commit 266bd569 authored by Mikhail Tergoev's avatar Mikhail Tergoev

move: wget->curl, zenity->yad

parent a2f74589
......@@ -4,16 +4,35 @@
########################################################################
unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL
export portname="PortProton"
export port_ver=1.3
export port_ver=1.4
########################################################################
cd "$(dirname "$(readlink -f "$0")")"
script_path="$(pwd)"
def_path="${HOME}/${portname}"
########################################################################
if [ "$(id -u)" == "0" ] ; then
echo "Do not run the script from the superuser!"
zenity --error --text "Do not run ${portname} from the superuser!" 2>/dev/null
fatal () {
echo -e "\n${1}\n"
exit 1
}
pw_notify_send () {
if command -v notify-send &>/dev/null ; then
if [[ -f "/usr/share/icons/hicolor/scalable/apps/portproton.svg" ]]
then notify-send -u normal -a PortProton -i "/usr/share/icons/hicolor/scalable/apps/portproton.svg" $@ "${PW_NOTIFY_TEXT}"
else notify-send -u normal -a PortProton $@ "${PW_NOTIFY_TEXT}"
fi
fi
}
########################################################################
if [ "$(id -u)" == "0" ] ; then
$yad_gui --error --text "\nDo not run ${portname} from the superuser!" 2>/dev/null
fatal "Do not run the script from the superuser!"
fi
########################################################################
unset PW_USE_NS
if command -v yad &>/dev/null
then yad_gui="yad --window-icon=portproton.svg --borders=10 --center --text-align=center"
else PW_USE_NS=1
fi
[ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share"
......@@ -43,65 +62,59 @@ export PW_SILENT_INSTALL=1
export PW_AUTOPLAY=1
export INSTALLING_PORT=1
########################################################################
if [ -z "${PW_SET_LANG}" ] ; then
PW_SET_LANG=$(zenity --title "Install $portname" --text "Select the installation language" --list --radiolist \
--column="Set:" --column "Language:" \
TRUE "Russian" \
FALSE "English")
[ "$?" != "0" ] && exit 1
if [[ "${PW_USE_NS}" != "1" ]] ; then
case $PW_SET_LANG in
"Russian")
INFO_TEXT="Вы запустили установщик PortWINE ${portname} версии ${port_ver}. \n\nЭто не коммерческий продукт и развивается исключительно за идею и Ваши пожертвования. \nВсе права сторонего програмного обеспечения принадлежат их владельцам! \nПродолжая установку вы автоматически соглашаетесь с данными условиями." ;;
"English")
INFO_TEXT="You run the installer PortWINE ${portname} v. ${port_ver}. \n\nThis is not a commercial product and developed exclusively for the idea and donate. \nAll rights to third-party software belong to their respective owners! \nContinuing the installation of you agree to these terms." ;;
esac
zenity --info --title "INFO" --text "$INFO_TEXT" --no-wrap 2>/dev/null
[ "$?" != "0" ] && exit 1
fi
########################################################################
case $PW_SET_LANG in
"Russian")
inst1=$(zenity --title "Install ${portname}" --text "Выберите путь для установки (обновления) ${portname},\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)." --list --radiolist --width=350 --height=250 \
inst1=$($yad_gui --title "Install ${portname}" --text "Выберите путь для установки (обновления) ${portname},\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)." --list --radiolist --width=600 --height=200 \
--column="Выбор" --column "Путь:" \
TRUE "${def_path}" \
FALSE "Другой путь...")
[ "$?" != "0" ] && exit 1
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
case $inst1 in
"${def_path}")
D_PATH="${def_path}" ;;
"Другой путь...")
D_PATH="$(zenity --file-selection --directory --title="Выберите путь..." 2>/dev/null)" ;;
echo 111
D_PATH="$($yad_gui --file --directory --title="Выберите путь..." --width=800 --height=800)" ;;
esac ;;
"English")
inst1=$(zenity --title "Install ${portname}" --text "Select the installation path (update) port,\nor leave it in default." --list --radiolist --width=350 --height=250 \
inst1=$($yad_gui --title "Install ${portname}" --text "Select the installation path (update) port,\nor leave it in default." --list --radiolist --width=600 --height=200 \
--column="Set..." --column "Path:" \
TRUE "${def_path}" \
FALSE "Other path...")
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
[ "$?" != "0" ] && exit 1
case $inst1 in
"${def_path}")
D_PATH="${def_path}" ;;
"Other path...")
D_PATH="$(zenity --file-selection --directory --title="Select the path..." 2>/dev/null)" ;;
D_PATH="$($yad_gui --file --directory --title="Select the path...")" ;;
esac ;;
esac
echo "${D_PATH}" | grep -i "${portname}" 2>/dev/null || D_PATH="${D_PATH}/${portname}"
########################################################################
case $PW_SET_LANG in
esac
[[ -z "${D_PATH}" ]] && fatal
echo "${D_PATH}" | grep -i "${portname}" 2>/dev/null || D_PATH="${D_PATH}/${portname}"
case $PW_SET_LANG in
"Russian")
progress_bar() {
zenity --progress --title="Установка..." --text="Настройка ${portname}" --pulsate --auto-close --auto-kill --width=450 2>/dev/null
$yad_gui --progress --title="Установка..." --text="Настройка ${portname}" --pulsate --auto-close --auto-kill --width=500
} ;;
"English")
progress_bar() {
zenity --progress --title="Install..." --text="Install ${portname}" --pulsate --auto-close --auto-kill --width=450 2>/dev/null
$yad_gui --progress --title="Install..." --text="Install ${portname}" --pulsate --auto-close --auto-kill --width=500
} ;;
esac
esac
else
D_PATH="${def_path}"
PW_NOTIFY_TEXT="Installing PortProton..."
pw_notify_send
fi
########################################################################
export PORT_WINE_PATH="${D_PATH}"
echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}"
if [ ! -d "${PORT_WINE_PATH}" ] ; then
mkdir -p "$PORT_WINE_PATH" || exit 1
mkdir -p "$PORT_WINE_PATH" || fatal "Cannot create a directory: $PORT_WINE_PATH"
else
rm -fr "${PORT_WINE_PATH}/data/tmp"
rm -f "${PORT_WINE_PATH}/data/scripts/"* 2>/dev/null
......@@ -114,38 +127,36 @@ case "${PW_SET_LANG}" in
"English") echo "ENG" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;;
esac
########################################################################
if [[ "${PW_USE_NS}" != "1" ]] ; then
PW_NOTIFY_TEXT="Installing PortProton..."
pw_notify_send
fi
export PORT_WINE_TMP_PATH="${PORT_WINE_PATH}/data/tmp"
cd "${PORT_WINE_PATH}"
try_download_scripts () {
echo "Try download scripts from gitlab.eterfund.ru..."
if ! 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://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz"
then
echo -e "Error.\nTry download scripts from github.com..."
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"
[ "$?" != "0" ] && echo "Fatal error! Exiting." && exit 1
fi
echo "Try unpacking scripts..."
tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}"
if [ "$?" = "0" ] ; then
echo -e "\nTry download scripts from gitlab.eterfund.ru..."
if ! curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" \
-o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
then
echo -e "\nError.\nTry download scripts from github.com..."
curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz" \
-o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && fatal "Critical error during file download!"
fi
echo "Try unpacking scripts..."
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=$(cat "${PORT_WINE_PATH}/data/scripts/var" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}')
echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
else
else
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && echo "Fatal error! Exiting." && exit 1
fi
}
[ "$?" != "0" ] && fatal "Critical error during file unpacking!"
fi
########################################################################
try_download_scripts | progress_bar
cd "${PORT_WINE_PATH}/data/scripts"
/usr/bin/env bash "${PORT_WINE_PATH}/data/scripts/setup.sh" && exit 0
################################ARCH_BIN################################
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment