-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·111 lines (105 loc) · 2.1 KB
/
utils.sh
File metadata and controls
executable file
·111 lines (105 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
###################################
# _______ ______ #
# |_ _\ \ / / ___| #
# | | \ \ / /\___ \ #
# | | \ V / ___) | #
# |_| \_/ |____/ #
# #
###################################
# TVS DClone Tool #
# Version 1.0 #
# By: Teske Virtual Systems #
# This tool is release under #
# GPL license, for more #
# details see license.txt file #
###################################
# http://www.teske.net.br #
###################################
SUDO="gksudo"
NO_ARGS=0
function getSudo() {
echo "Sudoed"
}
function getDiskSize() {
SIZE=`sudo fdisk -l $1 2>>/dev/null |grep $1: | awk '{print $3}'`
UNIT=`sudo fdisk -l $1 2>>/dev/null |grep $1: | awk '{print $4}' |cut -d, -f1`
if [ -z $SIZE ]
then
echo "Disco inexistente"
else
echo $SIZE $UNIT
fi
}
function getDiskPartitions() {
sudo parted $1 print |grep ^" "
}
function getDiskModel() {
sudo parted $1 print | head -n1 | cut -d: -f2
}
function getDisks() {
DISKS=""
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
do
TOUT=`sudo fdisk -l /dev/sd$i 2>>/dev/null |grep /dev/sd$i: | awk '{print $3}'`
#ls /dev/sd$i 1>> /dev/null 2>> /dev/null
#if [ $?" -eq 0 ]
if [ -z $TOUT ]
then
break
else
if [ $i = "a" ]
then
DISKS="/dev/sd$i"
else
DISKS="$DISKS,/dev/sd$i"
fi
#else
#break
fi
done
echo $DISKS
}
if [ $# -eq "$NO_ARGS" ]
then
echo "Uso: cloneutils argumento"
fi
while getopts ":sgdm" Option
do
case $Option in
s )
DISK=`echo $@ | awk '{print $2}'`
if [ -z $DISK ]
then
echo "Nenhum disco selecionado"
else
getDiskSize $DISK
fi
;;
g )
getDisks
;;
d )
DISK=`echo $@ | awk '{print $2}'`
if [ -z $DISK ]
then
echo "Nenhum disco selecionado"
else
getDiskPartitions $DISK
fi
;;
m )
DISK=`echo $@ | awk '{print $2}'`
if [ -z $DISK ]
then
echo "Nenhum disco selecionado"
else
getDiskModel $DISK
fi
;;
* )
echo $Option
;;
esac
done
#getDiskSize /dev/sda