From 709ef38c3e245c94c912f779cb0fe50d625da8d0 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 22 Jul 2020 15:33:30 +0200 Subject: Decent start --- .local/bin/system-upgrade | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to '.local/bin/system-upgrade') diff --git a/.local/bin/system-upgrade b/.local/bin/system-upgrade index 36ccef8..2391947 100755 --- a/.local/bin/system-upgrade +++ b/.local/bin/system-upgrade @@ -15,13 +15,14 @@ use constant { GREP_PATH => '/usr/bin/grep', WC_PATH => '/usr/bin/wc', TR_PATH => '/usr/bin/tr', + TEE_PATH => '/usr/bin/tee', FREEBSD_UPDATE_PATH => '/usr/sbin/freebsd-update', PORTMASTER_PATH => '/usr/local/sbin/portmaster', ESPEAK_PATH => '/usr/local/bin/espeak', NOTIFY_PATH => '/usr/local/bin/notify-send', }; -sub shell { +sub root_shell { system( DASH_PATH, '-c', @@ -42,12 +43,29 @@ EOF' } sub fbsd_update { + my $out; user_shell(NOTIFY_PATH . ' "Fetching" "Fetching FreeBSD updates"'); user_shell(ESPEAK_PATH . ' "Fetching FreeBSD updates" &'); - shell(FREEBSD_UPDATE_PATH . ' fetch'); + open( + PS, + DASH_PATH . ' -c "' . + FREEBSD_UPDATE_PATH . ' fetch" |' + ); + while (my $read = ) { + print $read; + $out .= $read; + } + close(PS); return; } +sub clean_exit { + my $end_date = `/bin/date`; + chomp($end_date); + print "\n\n" . $end_date . ": system upgrade complete!\n"; + exit; +} + sub main { my $p = Net::Ping->new; if (!($p->ping('freebsd.org', 2))) { @@ -60,7 +78,7 @@ sub main { close($fh); tee(STDOUT, '>>', LOG_FILE); fbsd_update(); - exit; + clean_exit(); } main(); -- cgit v1.2.3