-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-env.sh
executable file
·46 lines (34 loc) · 1.19 KB
/
setup-env.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
40
41
42
43
44
45
46
#!/bin/sh
# Variables
DIRECTORY=~/temporary/
ZFS_POOL_NAME=zfs_pool
ENCRYPTED_POOL_NAME=encrypted_pool
ARCHIVE_POOL_NAME=archive_pool
ZFS_POOL_FILE=${DIRECTORY}${ZFS_POOL_NAME}
ENCRYPTED_POOL_FILE=${DIRECTORY}${ENCRYPTED_POOL_NAME}
ARCHIVE_POOL_FILE=${DIRECTORY}${ARCHIVE_POOL_NAME}
# Processes
if [ $# -ne 1 ]; then
echo "Specify the argument of 'create' or 'destroy.'"
exit 1
fi
if [ ${1} = 'create' ]; then
echo "Creating files..."
mkdir -p ${DIRECTORY}
dd if=/dev/zero of=${ZFS_POOL_FILE} bs=64M count=1
dd if=/dev/zero of=${ENCRYPTED_POOL_FILE} bs=64M count=1
dd if=/dev/zero of=${ARCHIVE_POOL_FILE} bs=64M count=1
echo "Creating ZFS pools..."
sudo zpool create ${ZFS_POOL_NAME} `readlink -f ${ZFS_POOL_FILE}`
sudo zpool create ${ENCRYPTED_POOL_NAME} `readlink -f ${ENCRYPTED_POOL_FILE}`
sudo zpool create ${ARCHIVE_POOL_NAME} `readlink -f ${ARCHIVE_POOL_FILE}`
elif [ ${1} = 'destroy' ]; then
echo "Destroy ZFS pools..."
sudo zpool destroy ${ZFS_POOL_NAME}
sudo zpool destroy ${ENCRYPTED_POOL_NAME}
sudo zpool destroy ${ARCHIVE_POOL_NAME}
rm -r ${DIRECTORY}
else
echo "Specify 'create' or 'destroy' as the argument."
exit 1
fi