Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
fix issue with final notification message not closing. a few other ad…
Browse files Browse the repository at this point in the history
…justments.
  • Loading branch information
lots0logs committed Jul 19, 2016
1 parent 6855cae commit 367b0b5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)
### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen
1 change: 1 addition & 0 deletions dist/antergos-iso
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ hotfix_run_when_connected() {
fi

[[ -f /tmp/.setup-running ]] || start_cnchi
notify-send.sh -s "${LAST_SENT}"
}


Expand Down
33 changes: 25 additions & 8 deletions iso-hotfix-utility
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ if [[ -z "${_INITIALIZED}" ]]; then
NETWORK_ALIVE=1
NOTIFIED='False'
SCRIPT_UPDATED='False'
LAST_SENT=''
APP_ICON=''
APP_NAME=''
_INITIALIZED='True'
LAST_SENT=''
fi


Expand All @@ -56,48 +56,65 @@ _2log() {
}


_is_network_alive() {
for site in google.com yandex.ru baidu.com
do
ping -c1 "http://${site}" >/dev/null 2>&1 && return 0
done

return 1
}


_do_network_check() {
{ is_network_alive && NETWORK_ALIVE='True'; } || NETWORK_ALIVE='False'
}


_setup_environment() {
_2log '[iso-hotfix-utility] Setting up environment..'

NETWORK_ALIVE=$(ping -c1 8.8.8.8 >/dev/null 2>&1; echo $?)

if [[ $0 = *'iso-hotfix-utility'* ]]; then
SCRIPT_UPDATED='True'
NETWORK_ALIVE='True'
_2log '[iso-hotfix-utility] Script has been updated.'
else
_do_network_check
fi
}


_notify_user() {
[[ -f /tmp/.last_sent ]] && read -r LAST_SENT < /tmp/.last_sent

if [[ "${LAST_SENT}" != '' ]]; then
LAST_SENT=$(notify-send.sh -a "${APP_NAME}" -i "${APP_ICON}" -u "${LEVEL}" -p -r "${LAST_SENT}" "$1" "$2")
else
LAST_SENT=$(notify-send.sh -a "${APP_NAME}" -i "${APP_ICON}" -u "${LEVEL}" -p "$1" "$2")
fi

echo "${LAST_SENT}" > /dev/null
echo "${LAST_SENT}" > /tmp/.last_sent && read -r LAST_SENT < /tmp/.last_sent
}


_maybe_wait_for_internet_connection() {
local connected
connected='[iso-hotfix-utility] We have internet connection.'

if [[ "${NETWORK_ALIVE}" = 0 ]]; then
if [[ "${NETWORK_ALIVE}" = 'True' ]]; then
_2log "${connected}"
return
fi

hotfix_waiting_for_internet

while [[ "${NETWORK_ALIVE}" != 0 ]]; do
while [[ "${NETWORK_ALIVE}" != 'True' ]]; do
if [[ "${NOTIFIED}" = 'False' ]]; then
_notify_user "${NO_CONNECTION}" "${NO_CONNECTION_SUB}"
NOTIFIED='True'
fi

NETWORK_ALIVE=$(ping -c1 8.8.8.8 >/dev/null 2>&1; echo $?)

_do_network_check
sleep 1;
done

Expand Down

0 comments on commit 367b0b5

Please sign in to comment.