Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
system.linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simple Deploy- and Management
system.linux
Commits
1c57448c
Verified
Commit
1c57448c
authored
5 years ago
by
Christoph Johannes Kleine
Browse files
Options
Downloads
Patches
Plain Diff
installer.sh: improvements to comments and indentation
parent
8c4a30c5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/installer.sh
+80
-80
80 additions, 80 deletions
files/installer.sh
with
80 additions
and
80 deletions
files/installer.sh
+
80
−
80
View file @
1c57448c
...
@@ -15,7 +15,7 @@ export DISK_DEVICES
...
@@ -15,7 +15,7 @@ export DISK_DEVICES
# convertSizeToByte - converts a given size to byte
# convertSizeToByte - converts a given size to byte
# parameter:
# parameter:
# $1 - size in "kB", "MB", "MiB", "GB", "GiB", "TB" or "TiB"
# $1 - size in "kB",
"kiB",
"MB", "MiB", "GB", "GiB", "TB" or "TiB"
# return:
# return:
# size in byte
# size in byte
convertSizeToByte
()
{
convertSizeToByte
()
{
...
@@ -24,43 +24,43 @@ convertSizeToByte() {
...
@@ -24,43 +24,43 @@ convertSizeToByte() {
local factor
=
1
local factor
=
1
case
${
unit
}
in
case
${
unit
}
in
"B"
)
factor
=
1
;;
"B"
)
factor
=
1
;;
"kB"
)
factor
=
1000
;;
"kB"
)
factor
=
1000
;;
"MB"
)
factor
=
1000000
;;
"MB"
)
factor
=
1000000
;;
"GB"
)
factor
=
1000000000
;;
"GB"
)
factor
=
1000000000
;;
"TB"
)
factor
=
1000000000000
;;
"TB"
)
factor
=
1000000000000
;;
"kiB"
)
factor
=
1024
;;
"kiB"
)
factor
=
1024
;;
"MiB"
)
factor
=
1048576
;;
"MiB"
)
factor
=
1048576
;;
"GiB"
)
factor
=
1073741824
;;
"GiB"
)
factor
=
1073741824
;;
"TiB"
)
factor
=
1099511627776
;;
"TiB"
)
factor
=
1099511627776
;;
*
)
factor
=
1
;;
*
)
factor
=
1
;;
esac
esac
res
=
$(
dc
-e
"0k
${
value
}
${
factor
}
* p"
)
res
=
$(
dc
-e
"0k
${
value
}
${
factor
}
* p"
)
echo
"
${
res
%.*
}
"
echo
"
${
res
%.*
}
"
}
}
# convertByteToSize - converts a byte size to a given unit
# convertByteToSize - converts a byte size to a given unit
# parameter:
# parameter:
# $1 - size in byte
# $1 - size in byte
# $2 - unit like "kB", "MB", "MiB", "GB", "GiB", "TB" or "TiB"
# $2 - unit like "kB",
"kiB",
"MB", "MiB", "GB", "GiB", "TB" or "TiB"
# return:
# return:
# rounded size with unit
# rounded size with unit
convertByteToSize
()
{
convertByteToSize
()
{
local factor
=
1
local factor
=
1
case
$2
in
case
$2
in
"B"
)
factor
=
1
;;
"B"
)
factor
=
1
;;
"kB"
)
factor
=
1000
;;
"kB"
)
factor
=
1000
;;
"MB"
)
factor
=
1000000
;;
"MB"
)
factor
=
1000000
;;
"GB"
)
factor
=
1000000000
;;
"GB"
)
factor
=
1000000000
;;
"TB"
)
factor
=
1000000000000
;;
"TB"
)
factor
=
1000000000000
;;
"kiB"
)
factor
=
1024
;;
"kiB"
)
factor
=
1024
;;
"MiB"
)
factor
=
1048576
;;
"MiB"
)
factor
=
1048576
;;
"GiB"
)
factor
=
1073741824
;;
"GiB"
)
factor
=
1073741824
;;
"TiB"
)
factor
=
1099511627776
;;
"TiB"
)
factor
=
1099511627776
;;
*
)
factor
=
1
;;
*
)
factor
=
1
;;
esac
esac
res
=
$(
dc
-e
"2k
$1
${
factor
}
/ p"
)
res
=
$(
dc
-e
"2k
$1
${
factor
}
/ p"
)
...
@@ -70,20 +70,20 @@ convertByteToSize() {
...
@@ -70,20 +70,20 @@ convertByteToSize() {
# validateDiskScheme - checks the scheme of a disk device
# validateDiskScheme - checks the scheme of a disk device
# parameter:
# parameter:
# $1 - disk device name
# $1 - disk device name
# retur:
# retur
n
:
# 0 - no changes
# 0 - no changes
# 1 - label has changed
# 1 - label has changed
validateScheme
()
{
validateScheme
()
{
local
lbl
=
$(
echo
$diskdata
[
0] |
cut
-f
6
-d
":"
)
local
lbl
=
$(
echo
$diskdata
[
0] |
cut
-f
6
-d
":"
)
local
retval
=
1
local
retval
=
1
local
scheme
=
$(
eval echo
\$
DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_SCHEME
)
local
scheme
=
$(
eval echo
\$
DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_SCHEME
)
if
[
"x
${
scheme
}
"
=
"x
${
lbl
}
"
]
;
then
retval
=
0
fi
return
${
retval
}
if
[
"x
${
scheme
}
"
=
"x
${
lbl
}
"
]
;
then
retval
=
0
fi
return
${
retval
}
}
}
# initialDiskScheme - initials the scheme of a disk device
# initialDiskScheme - initials the scheme of a disk device
...
@@ -111,38 +111,38 @@ initialDiskScheme() {
...
@@ -111,38 +111,38 @@ initialDiskScheme() {
# 0 - no changes
# 0 - no changes
# 1 - partions has changed
# 1 - partions has changed
validateDiskPartitions
()
{
validateDiskPartitions
()
{
declare
-a
parts
=()
declare
-a
parts
=()
local
retval
=
0
local
retval
=
0
for
part
in
$(
eval
"for p in
\$
{DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_PARTITIONS[@]}; do echo
\$
p; done "
)
for
part
in
$(
eval
"for p in
\$
{DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_PARTITIONS[@]}; do echo
\$
p; done "
)
do
do
parts+
=(
${
part
}
)
parts+
=(
${
part
}
)
done
done
if
[
${#
parts
[@]
}
-eq
$((${#
diskdata
[@]
}
-
1
))
]
;
if
[
${#
parts
[@]
}
-eq
$((${#
diskdata
[@]
}
-
1
))
]
;
then
then
for
idx
in
$(
seq
1 1
${#
parts
[@]
}
)
for
idx
in
$(
seq
1 1
${#
parts
[@]
}
)
do
do
gsize
=
$(
convertSizeToByte
$(
echo
${
parts
[
$((${
idx
}
-
1
))
]
}
|
cut
-f
1
-d
":"
))
gsize
=
$(
convertSizeToByte
$(
echo
${
parts
[
$((${
idx
}
-
1
))
]
}
|
cut
-f
1
-d
":"
))
dsize
=
$(
convertSizeToByte
$(
echo
${
diskdata
[
${
idx
}
]
}
|
cut
-f
4
-d
":"
))
dsize
=
$(
convertSizeToByte
$(
echo
${
diskdata
[
${
idx
}
]
}
|
cut
-f
4
-d
":"
))
diffperc
=
$(
dc
-e
"2k
$dsize
$gsize
- 100 *
$gsize
/ p"
|
sed
-e
"s/^-//g"
)
diffperc
=
$(
dc
-e
"2k
$dsize
$gsize
- 100 *
$gsize
/ p"
|
sed
-e
"s/^-//g"
)
if
[
-n
"x
${
diffperc
%.*
}
"
]
;
if
[
-n
"x
${
diffperc
%.*
}
"
]
;
then
then
diffperc
=
0
diffperc
=
0
fi
fi
#if difference between current disk size and given disk size more than 1% then partitions has changed
#if difference between current disk size and given disk size more than 1% then partitions has changed
if
[
${
diffperc
%.*
}
-gt
1
]
;
if
[
${
diffperc
%.*
}
-gt
1
]
;
then
then
retval
=
1
retval
=
1
fi
fi
done
done
else
else
retval
=
1
retval
=
1
fi
fi
return
${
retval
}
return
${
retval
}
}
}
# initialDiskPartitions - initial the partitions of a disk device
# initialDiskPartitions - initial the partitions of a disk device
...
@@ -151,21 +151,21 @@ validateDiskPartitions() {
...
@@ -151,21 +151,21 @@ validateDiskPartitions() {
# return:
# return:
# none
# none
initialDiskPartitions
()
{
initialDiskPartitions
()
{
declare
-a
parts
=()
declare
-a
parts
=()
local
start
=
$(
convertSizeToByte
"1MiB"
)
local
start
=
$(
convertSizeToByte
"1MiB"
)
local
fs
=
""
local
fs
=
""
local
size
=
""
local
size
=
""
local
end
=
""
local
end
=
""
for
part
in
$(
eval
"for p in
\$
{DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_PARTITIONS[@]}; do echo
\$
p; done "
)
for
part
in
$(
eval
"for p in
\$
{DISK_
$(
echo
$1
|
tr
[
a-z]
[
A-Z]
)
_PARTITIONS[@]}; do echo
\$
p; done "
)
do
do
fs
=
$(
echo
${
part
}
|
cut
-f
2
-d
":"
)
fs
=
$(
echo
${
part
}
|
cut
-f
2
-d
":"
)
fsize
=
$(
echo
${
part
}
|
cut
-f
1
-d
":"
)
fsize
=
$(
echo
${
part
}
|
cut
-f
1
-d
":"
)
size
=
$(
convertSizeToByte
$(
echo
${
part
}
|
cut
-f
1
-d
":"
))
size
=
$(
convertSizeToByte
$(
echo
${
part
}
|
cut
-f
1
-d
":"
))
end
=
$((${
start
}
+
${
size
}))
end
=
$((${
start
}
+
${
size
}))
parted
-a
optimal
-s
-m
/dev/
$1
mkpart primary
${
fs
}
$(
convertByteToSize
${
start
}
"MiB"
)
$(
convertByteToSize
${
end
}
"MiB"
)
parted
-a
optimal
-s
-m
/dev/
$1
mkpart primary
${
fs
}
$(
convertByteToSize
${
start
}
"MiB"
)
$(
convertByteToSize
${
end
}
"MiB"
)
start
=
${
end
}
start
=
${
end
}
done
done
}
}
for
disk
in
${
DISK_DEVICES
[@]
}
for
disk
in
${
DISK_DEVICES
[@]
}
...
...
This diff is collapsed.
Click to expand it.
Pietsch, Martin
@mpietsch
mentioned in commit
ee9627de
·
5 years ago
mentioned in commit
ee9627de
mentioned in commit ee9627de4c7b930629bdea4628afe729e38dd1b1
Toggle commit list
Pietsch, Martin
@mpietsch
mentioned in merge request
!1 (closed)
·
5 years ago
mentioned in merge request
!1 (closed)
mentioned in merge request !1
Toggle commit list
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