Skip to content

Commit 8fda738

Browse files
committed
phreaknet.sh: Only check for updates periodically.
Rather than checking for updates whenever most commands are run, only check ~twice a day, so that commands can run faster. Also fixes some install logic that would not add DAHDI-dependent Asterisk modules if DAHDI was not installed at the same time (but was already present).
1 parent e59eef1 commit 8fda738

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

phreaknet.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
18151815
phreak_tree_module "res/res_phreaknet.c"
18161816
phreak_tree_module "res/res_pjsip_presence.c"
18171817

1818-
if [ "$CHAN_DAHDI" = "1" ]; then
1818+
if [ -d /etc/dahdi ]; then
18191819
phreak_tree_module "apps/app_loopdisconnect.c"
18201820
if [ "$RTPULSING" = "1" ]; then
18211821
phreak_tree_module "res/res_dialpulse.c"
@@ -2487,16 +2487,27 @@ fi
24872487

24882488
if which curl > /dev/null; then # only execute if we have curl
24892489
self=`grep "# v" $FILE_PATH | head -1 | cut -d'v' -f2`
2490-
upstream=`curl --silent https://raw.githubusercontent.com/InterLinked1/phreakscript/master/phreaknet.sh | grep -m1 "# v" | cut -d'v' -f2`
2491-
2492-
if [ "$self" != "$upstream" ] && [ "$cmd" != "update" ]; then
2493-
# Pull from GitHub here for version check for a) speed and b) stability reasons
2494-
# In this case, it's possible that our version number could actually be ahead of master, since we update from the dev upstream. We need to compare the versions, not merely check if they differ.
2495-
# Don't throw a warning if only the development tip is ahead of the master branch. But if master is ahead of us, then warn.
2496-
morerecent=`printf "%s\n%s" "$self" "$upstream" | sort | tail -1`
2497-
if [ "${morerecent}" != "${self}" ]; then
2498-
echoerr "WARNING: PhreakScript is out of date (most recent stable version is $upstream) - run 'phreaknet update' to update"
2499-
sleep 0.5
2490+
# Only download the first few lines of the file, to get the latest version number, and only check every so often
2491+
recent=$( find /tmp/phreaknet_upstream_version.txt -mmin -720 2>/dev/null | wc -l )
2492+
if [ "$recent" != "1" ]; then
2493+
printf " *** Checking if a more recent version is available..."
2494+
curl --silent https://raw.githubusercontent.com/InterLinked1/phreakscript/master/phreaknet.sh -r 0-210 > /tmp/phreaknet_upstream_version.txt
2495+
# Compare current version with latest upstream version
2496+
upstream=`grep -m1 "# v" /tmp/phreaknet_upstream_version.txt | cut -d'v' -f2`
2497+
if [ "$self" != "$upstream" ] && [ "$cmd" != "update" ]; then
2498+
# Pull from GitHub here for version check for a) speed and b) stability reasons
2499+
# In this case, it's possible that our version number could actually be ahead of master, since we update from the dev upstream. We need to compare the versions, not merely check if they differ.
2500+
# Don't throw a warning if only the development tip is ahead of the master branch. But if master is ahead of us, then warn.
2501+
morerecent=`printf "%s\n%s" "$self" "$upstream" | sort | tail -1`
2502+
if [ "${morerecent}" != "${self}" ]; then
2503+
printf " YES\n"
2504+
echoerr "WARNING: PhreakScript is out of date (most recent stable version is $upstream) - run 'phreaknet update' to update"
2505+
sleep 0.5
2506+
else
2507+
printf " NO (AHEAD)\n"
2508+
fi
2509+
else
2510+
printf " NO\n"
25002511
fi
25012512
fi
25022513
fi

0 commit comments

Comments
 (0)