Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
26880872
Commit
26880872
authored
Dec 04, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move functions to functions.sh
parent
218533e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
functions.sh
hdd/functions.sh
+46
-0
raid_restore.sh
hdd/raid_restore.sh
+2
-47
No files found.
hdd/functions.sh
View file @
26880872
...
@@ -44,6 +44,9 @@ print_model()
...
@@ -44,6 +44,9 @@ print_model()
print_size
()
print_size
()
{
{
print_partsize
"
$1
"
return
# dont't use hdparm
local
dev
=
"
$1
"
local
dev
=
"
$1
"
local
sectors
local
sectors
sectors
=
"
$(
hdparm
-i
$dev
|
grep
"LBAsects="
|
sed
-e
"s|.*LBAsects=
\(
.*
\)
|
\1
|"
)
"
#"
sectors
=
"
$(
hdparm
-i
$dev
|
grep
"LBAsects="
|
sed
-e
"s|.*LBAsects=
\(
.*
\)
|
\1
|"
)
"
#"
...
@@ -63,3 +66,46 @@ print_partsize()
...
@@ -63,3 +66,46 @@ print_partsize()
echo
"
$((
$sectors
/
2
/
1024
/
1024
))
GB"
echo
"
$((
$sectors
/
2
/
1024
/
1024
))
GB"
}
}
# device as param (/dev/sdb2)
get_array_uuid_by_device
()
{
local
dev
=
"
$1
"
# "Array UUID for 1.2 and UUID for 0.9"
mdadm
-E
$dev
2>/dev/null |
grep
" UUID : "
|
head
-n1
|
sed
-e
"s|.* UUID : ||"
}
# /dev/md1
get_array_uuid_by_md
()
{
mdadm
-D
"
$1
"
2>/dev/null |
grep
"UUID : "
|
sed
-e
"s|.* UUID : ||"
}
get_device_list_by_uuid
()
{
local
UUID
=
"
$(
echo
$1
|
sed
-e
's|:||g'
)
"
blkid /dev/sd
*
2>/dev/null |
sed
-e
's|-||g'
|
grep
"/dev/sd[a-z].*: UUID=
\"
$UUID
\"
"
|
sed
-e
"s|:.*||"
}
get_md_by_uuid
()
{
local
md
for
md
in
/dev/md
*
;
do
mdadm
-D
$md
2>/dev/null |
grep
-q
"UUID :
$1
"
&&
echo
"
$md
"
&&
return
done
#ARRAY /dev/md/1 metadata=1.2 UUID=1912da86:6089954c:2aead1ca:77f06477 name=azbykar.localdomain:1
local
STRUUID
=
$(
grep
"UUID=
$1
"
/etc/mdadm.conf
)
[
-n
"
$STRUUID
"
]
&&
echo
"
$STRUUID
"
|
cut
-d
" "
-f
2
&&
return
echo
"can't grep UUID=
$1
in /etc/mdadm.conf"
>>
$0
.log
}
get_dm_status
()
{
[
-r
"
$1
"
]
||
return
mdadm
-D
$1
2>/dev/null |
grep
"State : "
|
sed
-e
"s|.*State : ||"
}
print_serno
()
{
smartctl
-i
"
$1
"
|
grep
"Serial Number: "
|
sed
-e
"s/.*Serial Number: *//g"
|
tail
-c
5
#hdparm -i "$1" | grep "SerialNo=" | sed -e "s/.*SerialNo=//g" | tail -c 5
}
hdd/raid_restore.sh
View file @
26880872
#!/bin/sh
#!/bin/sh
# TODO: mdadm --assemble --scan -v
.
$(
dirname
$0
)
/functions.sh
# device as param (/dev/sdb2)
get_array_uuid_by_device
()
{
local
dev
=
"
$1
"
# "Array UUID for 1.2 and UUID for 0.9"
mdadm
-E
$dev
|
grep
" UUID : "
|
head
-n1
|
sed
-e
"s|.* UUID : ||"
}
# /dev/md1
get_array_uuid_by_md
()
{
mdadm
-D
"
$1
"
|
grep
"UUID : "
|
sed
-e
"s|.* UUID : ||"
}
get_device_list_by_uuid
()
{
local
UUID
=
"
$(
echo
$1
|
sed
-e
's|:||g'
)
"
blkid /dev/sd
*
|
sed
-e
's|-||g'
|
grep
"/dev/sd[a-z].*: UUID=
\"
$UUID
\"
"
|
sed
-e
"s|:.*||"
}
get_md_by_uuid
()
{
local
md
for
md
in
/dev/md
*
;
do
mdadm
-D
$md
|
grep
-q
"UUID :
$1
"
&&
echo
"
$md
"
&&
return
done
#ARRAY /dev/md/1 metadata=1.2 UUID=1912da86:6089954c:2aead1ca:77f06477 name=azbykar.localdomain:1
local
STRUUID
=
$(
grep
"UUID=
$1
"
/etc/mdadm.conf
)
[
-n
"
$STRUUID
"
]
&&
echo
"
$STRUUID
"
|
cut
-d
" "
-f
2
&&
return
echo
"can't grep UUID=
$1
in /etc/mdadm.conf"
>>
$0
.log
}
get_dm_status
()
{
[
-r
"
$1
"
]
||
return
mdadm
-D
$1
|
grep
"State : "
|
sed
-e
"s|.*State : ||"
}
# TODO: mdadm --assemble --scan -v
is_hdd
()
{
# /dev/sd?
local
drive
=
"
$(
echo
"
$1
"
|
cut
-c1-8
)
"
[
-b
"
$drive
"
]
||
fatal
hdparm
-i
"
$drive
"
|
grep
-q
"Model=WDC"
}
dev_in_md
()
dev_in_md
()
{
{
...
...
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