Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dotfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chris Coley
dotfiles
Commits
d7a69884
Commit
d7a69884
authored
5 years ago
by
Chris Coley
Browse files
Options
Downloads
Patches
Plain Diff
Implement a --quiet flag in the update-gitlab tool
parent
3ae1eb01
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/update-gitlab
+25
-7
25 additions, 7 deletions
bin/update-gitlab
with
25 additions
and
7 deletions
bin/update-gitlab
+
25
−
7
View file @
d7a69884
...
...
@@ -61,6 +61,7 @@ EOF
# Parse command options
flag_dry_run
=
0
flag_verbose
=
0
flag_quiet
=
0
flag_exit_code
=
0
while
[[
$#
-gt
0
]]
;
do
case
"
$1
"
in
...
...
@@ -70,6 +71,9 @@ while [[ $# -gt 0 ]]; do
"-v"
|
"--verbose"
)
flag_verbose
=
1
;;
"-q"
|
"--quiet"
)
flag_quiet
=
1
;;
"-c"
|
"--code"
)
flag_exit_code
=
1
;;
...
...
@@ -86,16 +90,24 @@ done
# Make sure we're running as root
if
[
$(
id
-u
)
-ne
0
]
;
then
echo
"This script must be run as root or with sudo"
exit
1
error_exit
"This script must be run as root or with sudo"
fi
# Make sure we're not quiet and verbose at the same time
if
[
${
flag_verbose
}
-eq
1
]
&&
[
${
flag_quiet
}
-eq
1
]
;
then
error_exit
"Using --verbose and --quiet options together is not supported"
fi
# Update Apt-Cache if older than 15 minutes
if
[
"
$[
$(
date
+%s
)
-
$(
stat
-c
%Z /var/lib/apt/periodic/update-success-stamp
)
]"
-ge
900
]
;
then
if
[
${
flag_quiet
}
-eq
0
]
;
then
echo
"APT cache is stale; updating..."
fi
apt-get
-qq
update
if
[
${
flag_quiet
}
-eq
0
]
;
then
echo
fi
fi
latest
=
`
apt-cache policy
${
package
}
|
sed
-n
's/ Candidate: \([0-9]\+\.[0-9]\+\.[^ ]\+\).*/\1/p'
`
installed
=
`
apt-cache policy
${
package
}
|
sed
-n
's/ Installed: \([0-9]\+\.[0-9]\+\.[^ ]\+\).*/\1/p'
`
...
...
@@ -110,18 +122,24 @@ if [ ${flag_verbose} -eq 1 ]; then
fi
if
[
"
${
installed
}
"
==
"
${
target
}
"
]
;
then
if
[
${
flag_quiet
}
-eq
0
]
;
then
echo
"Most recent patch version (
${
target
}
) of last minor version is already installed."
fi
if
[
${
flag_exit_code
}
-eq
1
]
;
then
exit
64
fi
elif
[
"
${
target
}
"
!=
`
echo
-e
"
${
installed
}
\n
${
target
}
"
|
sort
-Vr
|
sed
-n
1p
`
]
;
then
if
[
${
flag_quiet
}
-eq
0
]
;
then
echo
"Installed version (
${
installed
}
) is newer than the target version (
${
target
}
.*). Not upgrading."
fi
if
[
${
flag_exit_code
}
-eq
1
]
;
then
exit
64
fi
else
if
[
${
flag_dry_run
}
-eq
0
]
;
then
if
[
${
flag_quiet
}
-eq
0
]
;
then
echo
"Upgrading from
${
installed
}
to
${
target
}
"
fi
apt-get
install
${
package
}
=
${
target
}
else
echo
"Would upgrade from
${
installed
}
to
${
target
}
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment