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

move: wget->curl, zenity->yad

parent a2f74589
...@@ -4,16 +4,35 @@ ...@@ -4,16 +4,35 @@
######################################################################## ########################################################################
unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL
export portname="PortProton" export portname="PortProton"
export port_ver=1.3 export port_ver=1.4
######################################################################## ########################################################################
cd "$(dirname "$(readlink -f "$0")")" cd "$(dirname "$(readlink -f "$0")")"
script_path="$(pwd)" script_path="$(pwd)"
def_path="${HOME}/${portname}" def_path="${HOME}/${portname}"
######################################################################## ########################################################################
if [ "$(id -u)" == "0" ] ; then fatal () {
echo "Do not run the script from the superuser!" echo -e "\n${1}\n"
zenity --error --text "Do not run ${portname} from the superuser!" 2>/dev/null
exit 1 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 fi
[ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share" [ -z "${XDG_DATA_HOME}" ] && export XDG_DATA_HOME="$HOME/.local/share"
...@@ -43,65 +62,59 @@ export PW_SILENT_INSTALL=1 ...@@ -43,65 +62,59 @@ export PW_SILENT_INSTALL=1
export PW_AUTOPLAY=1 export PW_AUTOPLAY=1
export INSTALLING_PORT=1 export INSTALLING_PORT=1
######################################################################## ########################################################################
if [ -z "${PW_SET_LANG}" ] ; then if [[ "${PW_USE_NS}" != "1" ]] ; 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
case $PW_SET_LANG in case $PW_SET_LANG in
"Russian") "Russian")
INFO_TEXT="Вы запустили установщик PortWINE ${portname} версии ${port_ver}. \n\nЭто не коммерческий продукт и развивается исключительно за идею и Ваши пожертвования. \nВсе права сторонего програмного обеспечения принадлежат их владельцам! \nПродолжая установку вы автоматически соглашаетесь с данными условиями." ;; inst1=$($yad_gui --title "Install ${portname}" --text "Выберите путь для установки (обновления) ${portname},\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)." --list --radiolist --width=600 --height=200 \
"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 \
--column="Выбор" --column "Путь:" \ --column="Выбор" --column "Путь:" \
TRUE "${def_path}" \ TRUE "${def_path}" \
FALSE "Другой путь...") FALSE "Другой путь...")
[ "$?" != "0" ] && exit 1 [ "$?" != "0" ] && exit 1
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
case $inst1 in case $inst1 in
"${def_path}") "${def_path}")
D_PATH="${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 ;; esac ;;
"English") "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:" \ --column="Set..." --column "Path:" \
TRUE "${def_path}" \ TRUE "${def_path}" \
FALSE "Other path...") FALSE "Other path...")
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
[ "$?" != "0" ] && exit 1 [ "$?" != "0" ] && exit 1
case $inst1 in case $inst1 in
"${def_path}") "${def_path}")
D_PATH="${def_path}" ;; D_PATH="${def_path}" ;;
"Other 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 ;;
esac esac
echo "${D_PATH}" | grep -i "${portname}" 2>/dev/null || D_PATH="${D_PATH}/${portname}" [[ -z "${D_PATH}" ]] && fatal
######################################################################## echo "${D_PATH}" | grep -i "${portname}" 2>/dev/null || D_PATH="${D_PATH}/${portname}"
case $PW_SET_LANG in
case $PW_SET_LANG in
"Russian") "Russian")
progress_bar() { 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") "English")
progress_bar() { 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}" export PORT_WINE_PATH="${D_PATH}"
echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}" echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}"
if [ ! -d "${PORT_WINE_PATH}" ] ; then 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 else
rm -fr "${PORT_WINE_PATH}/data/tmp" rm -fr "${PORT_WINE_PATH}/data/tmp"
rm -f "${PORT_WINE_PATH}/data/scripts/"* 2>/dev/null rm -f "${PORT_WINE_PATH}/data/scripts/"* 2>/dev/null
...@@ -114,38 +127,36 @@ case "${PW_SET_LANG}" in ...@@ -114,38 +127,36 @@ case "${PW_SET_LANG}" in
"English") echo "ENG" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;; "English") echo "ENG" > "${PORT_WINE_PATH}/data/tmp/${portname}_loc" ;;
esac 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" export PORT_WINE_TMP_PATH="${PORT_WINE_PATH}/data/tmp"
cd "${PORT_WINE_PATH}" cd "${PORT_WINE_PATH}"
try_download_scripts () { echo -e "\nTry download scripts from gitlab.eterfund.ru..."
echo "Try 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' \
if ! wget -O "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -nd -c --read-timeout 300 \ -L "https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" \
--retry-connrefused --timeout 15 --tries 3 \ -o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" \ then
"https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" echo -e "\nError.\nTry download scripts from github.com..."
then curl -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
echo -e "Error.\nTry download scripts from github.com..." -L "https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz" \
wget -O "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -nd -c --read-timeout 300 \ -o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
--retry-connrefused --timeout 15 --tries 3 \ [ "$?" != "0" ] && fatal "Critical error during file download!"
--user-agent="Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" \ fi
"https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz" echo "Try unpacking scripts..."
[ "$?" != "0" ] && echo "Fatal error! Exiting." && exit 1 tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}"
fi if [ "$?" = "0" ] ; then
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/" [ ! -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/" 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 -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
rm -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/" 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}') 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" echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
else else
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && echo "Fatal error! Exiting." && exit 1 [ "$?" != "0" ] && fatal "Critical error during file unpacking!"
fi fi
}
######################################################################## ########################################################################
try_download_scripts | progress_bar
cd "${PORT_WINE_PATH}/data/scripts" cd "${PORT_WINE_PATH}/data/scripts"
/usr/bin/env bash "${PORT_WINE_PATH}/data/scripts/setup.sh" && exit 0 /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