-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·41 lines (36 loc) · 907 Bytes
/
setup.sh
File metadata and controls
executable file
·41 lines (36 loc) · 907 Bytes
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
#!/bin/bash
CMDLN_ARGS="$@" # Command line arguments for this script
export CMDLN_ARGS
# Run this script as root if not already.
chk_root () {
if [ ! $( id -u ) -eq 0 ]; then
echo "Please run as root"
exit 0
# echo "Please enter root's password."
# exec su -c "${0} ${CMDLN_ARGS}" # Call this prog as root
# exit ${?} # sice we're 'execing' above, we wont reach this exit
# unless something goes wrong.
fi
}
chk_root
[ "$#" -lt 2 ] && echo "Usage: bash setup (number of disks) (size of one disk MB)" && exit 0
fusermount -u mountdir
rm file0*.img
rm -r rootdir
rm -r mountdir
mkdir rootdir
mkdir mountdir
for((i=1;i<$1+1;i=i+1))
do
losetup -d /dev/loop$i
dd if=/dev/zero of=file0$i.img bs=1M count=$2
losetup /dev/loop$i file0$i.img
done
rm raid_health
touch raid_health
for((i=0;i<$1;i=i+1))
do
echo "0" >>raid_health
done
rm raid_metadata
touch raid_metadata