Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F10937828
report-pending-upgrades.sh
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
aborrero
Nov 22 2017, 1:54 PM
2017-11-22 13:54:36 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
report-pending-upgrades.sh
View Options
#!/bin/bash
if
[
"
$(
id -u
)
"
!
=
"0"
]
;
then
echo
"E: root required"
>
&
2
exit
1
fi
get_binary
()
{
BINARY
=
$(
which
$1
)
if
[
! -x
"
$BINARY
"
]
;
then
echo
"E: no
$1
binary found"
>
&
2
exit
1
fi
echo
$BINARY
}
APT_GET
=
$(
get_binary apt-get
)
APT_SHOW_VERSIONS
=
$(
get_binary apt-show-versions
)
UNATTENDED_UPGRADES
=
$(
get_binary unattended-upgrades
)
echo
"I: updating package cache"
$APT_GET
update >/dev/null
APT_SHOW_VERSIONS_OUTPUT
=
$(
$APT_SHOW_VERSIONS
|
grep upgradeable
)
n1
=
$(
echo
"
$APT_SHOW_VERSIONS_OUTPUT
"
|
grep -v ^$
|
wc -l
)
UNATTENDED_UPGRADES_OUTPUT
=
$(
$UNATTENDED_UPGRADES
--dry-run -v -d
|
grep
"Packages that will be upgraded"
|
awk -F
':'
'{print $2}'
|
grep -v ^
[[
:space:
]]
*$
)
n2
=
$(
echo
"
$UNATTENDED_UPGARDES_OUTPUT
"
|
grep -v ^$
|
wc -l
)
if
[
"
$n1
"
!
=
"0"
]
;
then
echo
"I: upgradeable packages:
$n1
"
echo
echo
"
$APT_SHOW_VERSIONS_OUTPUT
"
echo
fi
if
[
"
$n2
"
!
=
"0"
]
;
then
echo
"I: upgradeable packages by unattended-upgrades:
$n2
"
echo
echo
"
$UNATTENDED_UPGARDES_OUTPUT
"
echo
fi
echo
"I:
$n1
upgradeable packages,
$n2
upgradeable packages by unatteneded-upgrades"
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5114380
Default Alt Text
report-pending-upgrades.sh (1 KB)
Attached To
Mode
P6365 report-pending-upgrades.sh
Attached
Detach File
Event Timeline
Log In to Comment