Skip to content

Commit dd70955

Browse files
committed
Add the ability to ignore individual disks when outputting
1 parent c3ff36e commit dd70955

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

install

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ else
1818
then
1919
echo
2020
source configure
21+
echo
2122
fi
2223
fi
2324

24-
exit 0;
25-
2625
# Check dependencies
2726
if [[ -z $(command -v whiptail) ]]
2827
then

mnt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function getConfigSection() {
88
grep -A64 -Ex "^\[$1\]$" ~/.config/mnt/config.ini | grep -Ex "^[^#;].*=.*$" | sed "s/ *= */=/g"
99
else
1010
grep -A64 -Ex "^\[$1\]$" ~/.config/mnt/config.ini |
11-
grep -B64 -Ex "^\[[^${1:0:1}].*\]$" | grep -Ex "^[^#;].*=.*$" |
11+
grep -B64 -Ex "^\[[^${1:0:1}].*\]$" -m1 | grep -Ex "^[^#;].*=.*$" |
1212
sed "s/ *= */=/g"
1313
fi
1414
}
@@ -19,6 +19,7 @@ IFS=$'\n' # Only new-line charachter is separator
1919

2020
declare -A assoc # Associative array with parts labels
2121
declare -A parts # Array with disks parts
22+
declare ignore # Array with ignored disks
2223

2324
# Create or touch config file
2425
mkdir ~/.config/mnt/ -p # Create config directory if it doesn't exists
@@ -27,11 +28,23 @@ touch ~/.config/mnt/config.ini # Create config file if it doesn't exists
2728
# Get associations for part labels
2829
for var in $(getConfigSection associations)
2930
do
30-
name1=$(echo $var | awk -F '=' '{print $1}')
31-
name2=$(echo $var | awk -F '=' '{print $2}')
31+
label1=$(echo $var | awk -F '=' '{print $1}')
32+
label2=$(echo $var | awk -F '=' '{print $2}')
3233

3334
# Make asociations
34-
assoc[$name1]=$name2
35+
assoc[$label1]=$label2
36+
done
37+
38+
# Get list of ignored disks
39+
for var in $(getConfigSection display)
40+
do
41+
label=$(echo $var | awk -F '=' '{print $1}')
42+
state=$(echo $var | awk -F '=' '{print $2}')
43+
44+
if [[ $state == "OFF" ]]
45+
then
46+
ignore+=($label)
47+
fi
3548
done
3649

3750
# Get /dev/name and label of parts
@@ -40,7 +53,10 @@ do
4053
dev=$(echo $var | awk '{print $1}')
4154
label=$(echo $var | awk '{$1=""; print $0}' | sed -r 's/^ *| *$//g')
4255

43-
parts[$label]=$dev
56+
if [[ ${ignore[*]} != *$label* ]]
57+
then
58+
parts[$label]=$dev
59+
fi
4460
done
4561

4662
# Get the list of disks in the required form

0 commit comments

Comments
 (0)