From 95c17dcc238dfc9576534227d1bc3f4fb80220c0 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:26:06 +0200 Subject: [PATCH] chore(default-flatpaks): Increase connection attempts to 5 & print successful connection log --- modules/default-flatpaks/v1/system-flatpak-setup | 15 +++++++++------ modules/default-flatpaks/v1/user-flatpak-setup | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/default-flatpaks/v1/system-flatpak-setup b/modules/default-flatpaks/v1/system-flatpak-setup index e03a115..32047dc 100755 --- a/modules/default-flatpaks/v1/system-flatpak-setup +++ b/modules/default-flatpaks/v1/system-flatpak-setup @@ -4,7 +4,7 @@ # Check it 3 times in 3 second interval, to avoid until loop # Used when adding remotes & when installing flatpaks check_internet_connection() { - local max_attempts=3 + local max_attempts=5 local sleep_time=3 local attempt=1 @@ -125,10 +125,11 @@ done # Set up system-wide Flatpak repository if [[ $REPO_URL != "null" && $REPO_NAME != "null" ]]; then - echo "Adding system-wide remote $REPO_NAME from $REPO_URL" + echo "Adding system-wide remote $REPO_NAME from $REPO_URL (requires internet)" echo "Note that --if-not-exists flag doesn't prevent the repo from modifying repo URL" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" flatpak remote-add --if-not-exists --system "$REPO_NAME" "$REPO_URL" fi fi @@ -143,10 +144,10 @@ fi # Change repository title to configured title, if not null & if not already changed if [[ $REPO_TITLE != "null" ]] && ! ${no_title_modify}; then - echo "Setting title $REPO_TITLE for remote $REPO_NAME" + echo "Setting title $REPO_TITLE for system remote $REPO_NAME" flatpak remote-modify --system "$REPO_NAME" --title="$REPO_TITLE" elif [[ $REPO_TITLE != "null" ]] && ${no_title_modify}; then - echo "Custom flatpak remote title is already set" + echo "Custom flatpak system remote title is already set" fi # Notifications config @@ -215,15 +216,17 @@ if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then INSTALL_LIST="$COMBINED_INSTALL_LIST" fi if [[ -n $INSTALL_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then - echo "Installing system flatpaks from config list" + echo "Installing system flatpaks from config list (requires internet)" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" flatpak install --system --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]} fi elif [[ -n $INSTALL_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then - echo "Installing system flatpaks from config list" + echo "Installing system flatpaks from config list (requires internet)" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" notify-send-pre-install flatpak install --system --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]} notify-send-install diff --git a/modules/default-flatpaks/v1/user-flatpak-setup b/modules/default-flatpaks/v1/user-flatpak-setup index 2ec668d..123dae9 100755 --- a/modules/default-flatpaks/v1/user-flatpak-setup +++ b/modules/default-flatpaks/v1/user-flatpak-setup @@ -4,7 +4,7 @@ # Check it 3 times in 3 second interval, to avoid until loop # Used when adding remotes & when installing flatpaks check_internet_connection() { - local max_attempts=3 + local max_attempts=5 local sleep_time=3 local attempt=1 @@ -112,20 +112,21 @@ done # Set up per-user Flatpak repository if [[ $REPO_URL != "null" && $REPO_NAME != "null" ]]; then - echo "Adding remote $REPO_NAME from $REPO_URL" + echo "Adding user-wide remote $REPO_NAME from $REPO_URL (requires internet)" echo "Note that --if-not-exists flag doesn't prevent the repo from modifying repo URL" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" flatpak remote-add --if-not-exists --user "$REPO_NAME" "$REPO_URL" fi fi # Change repository title to configured title, if not null & if not already changed if [[ $REPO_TITLE != "null" ]] && ! ${no_title_modify}; then - echo "Setting title $REPO_TITLE for remote $REPO_NAME" + echo "Setting title $REPO_TITLE for user remote $REPO_NAME" flatpak remote-modify --user "$REPO_NAME" --title="$REPO_TITLE" elif [[ $REPO_TITLE != "null" ]] && ${no_title_modify}; then - echo "Custom flatpak remote title is already set" + echo "Custom flatpak user remote title is already set" fi # Notifications config @@ -166,15 +167,17 @@ if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then INSTALL_LIST="$COMBINED_INSTALL_LIST" fi if [[ -n $INSTALL_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then - echo "Installing user flatpaks from config list" + echo "Installing user flatpaks from config list (requires internet)" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" flatpak install --user --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]} fi elif [[ -n $INSTALL_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then - echo "Installing user flatpaks from config list" + echo "Installing user flatpaks from config list (requires internet)" check_internet_connection if "${internet_connection}"; then + echo "Internet connection is successful, applying the operation above" notify-send "Flatpak Installer" "Started install of user flatpaks" --app-name="Flatpak Installer" -u NORMAL flatpak install --user --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]} notify-send "Flatpak Installer" "Finished install of user flatpaks:\n$INSTALL_LIST" --app-name="Flatpak Installer" -u NORMAL