-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
39 lines (36 loc) · 913 Bytes
/
config.sh
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
#!/bin/sh
usage() {
echo "Usage: ${0} -d <device> -f <fstype> -l <label>"
echo "Example: ${0} -d /dev/sdd -f brtfs -l USB_RSYNC_A"
echo
}
xerr=""
while getopts "hf:l:d:" option; do
case $option in
h) #display help
usage
exit;;
f) # fstype
xfstype=$OPTARG;;
l) # label
xlabel=$OPTARG;;
d) # device id
xdevice=$OPTARG;;
\?) #error
xerr="true";;
esac
done
shift $((OPTIND-1))
if [ -z "${xfstype}" ] || [ -z "${xlabel}" ] || [ -z "${xdevice}" ]; then
usage;
else
if [ -z "${xerr}" ]; then
uuid=$(lsblk ${xdevice} -f|grep crypto_LUKS|awk '{print $4}');
echo "#!/bin/bash"
echo
echo "MOUNTPOINT=\"/mnt/${xlabel}\"";
echo "UUID=\"${uuid}\"";
echo "DEV_MAPPER_NAME=\"${xlabel}\"";
echo "FSTYPE=\"${xfstype}\"";
fi
fi