Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clewsy
scripts
Commits
22f6cc5f
Commit
22f6cc5f
authored
Jul 30, 2020
by
clewsy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PATH override for sudo to avoid error on system when sudo PATH is not adequate for apt-get.
parent
4d535d21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
apt_all.sh
apt_all.sh
+10
-5
No files found.
apt_all.sh
View file @
22f6cc5f
...
...
@@ -56,6 +56,11 @@ QUIET=false
## "" : System default.
PROTOCOL
=
"-4"
######### Define path override used with sudo over ssh.
## Fixes an error that otherwise arises if sudo default PATH does not include paths of commands needed by apt-get.
## E.g. Default sudo PATH is negated on an OSMC installation by the /etc/sudoers.d/osmc-no-secure-path file.
PATH_DEF
=
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
########## Interpret options
while
getopts
'vqh'
OPTION
;
do
## Call getopts to identify selected options and set corresponding flags.
case
"
$OPTION
"
in
...
...
@@ -160,7 +165,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt update.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
-n
"
${
BOLD
}
update...
\t\t
${
RESET
}
"
;
fi
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes update"
>
${
DEST
}
;
then
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"
${
PATH_DEF
}
sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes update"
>
${
DEST
}
;
then
{
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get update
\t\t
${
RED
}
Failure.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
...
...
@@ -175,7 +180,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
fi
###### Use apt to check if any packages can be upgraded.
NEW
=
$(
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
sudo
apt list
--upgradable
--quiet
=
2
)
NEW
=
$(
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"
${
PATH_DEF
}
sudo apt list --upgradable --quiet=2"
)
if
[[
!
${
NEW
}
]]
;
then
## There are no new packages to update.
{
echo
-E
"
${
BOLD
}
║
${
RESET
}
Up-to-date
\t\t
${
GREEN
}
Skipped.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
...
...
@@ -187,7 +192,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
else
## There are new packages to update.
###### Attempt dist-upgrade.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
-n
"
${
BOLD
}
dist-upgrade...
\t
${
RESET
}
"
;
fi
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes --show-progress dist-upgrade"
>
${
DEST
}
;
then
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"
${
PATH_DEF
}
sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes --show-progress dist-upgrade"
>
${
DEST
}
;
then
{
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get dist-upgrade
\t
${
RED
}
Failure.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
...
...
@@ -203,7 +208,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt autoremove.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
-n
"
${
BOLD
}
autoremove...
\t\t
${
RESET
}
"
;
fi
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes --show-progress autoremove"
>
${
DEST
}
;
then
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"
${
PATH_DEF
}
sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes --show-progress autoremove"
>
${
DEST
}
;
then
{
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get autoremove
\t
${
RED
}
Failure.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
...
...
@@ -219,7 +224,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt autoclean.
if
[
${
QUIET
}
=
false
]
;
then
echo
-e
-n
"
${
BOLD
}
autoclean...
\t\t
${
RESET
}
"
;
fi
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes autoclean"
>
${
DEST
}
;
then
if
!
ssh
"
${
PROTOCOL
}
"
-o
"BatchMode=yes"
"
${
REM_SYS
}
"
"
${
PATH_DEF
}
sudo apt-get
${
APT_GET_VERBOSITY
}
--assume-yes autoclean"
>
${
DEST
}
;
then
{
echo
-E
"
${
BOLD
}
║
${
RESET
}
apt-get autoclean
\t
${
RED
}
Failure.
${
RESET
}${
BOLD
}
║
${
RESET
}
"
echo
-E
"
${
BOLD
}
╠═══════════════════════════════╣
${
RESET
}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment