forked from katharostech/docker_lizardfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·109 lines (97 loc) · 4.04 KB
/
configure.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
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
#!/bin/bash
# Configure LizardFS master
if [ "$1" = "master" ]; then
# Copy the empty metadata file to /var/lib/mfs if it does not exist
if [ ! -e /var/lib/mfs/metadata.mfs ]; then
cp /metadata.mfs.empty /var/lib/mfs/metadata.mfs
fi
# Add config for mfsmaster.cfg
# For each vairable that starts with `MFSMASTER_`, remove the
# prefix and add the value to the `mfsmaster.cfg` file.
rm -f /etc/mfs/mfsmaster.cfg # We remove the config file to reset config
configs=${!MFSMASTER_*}
for var in $configs; do
config_name=${var#*_}
echo "${config_name} = ${!var}" >> /etc/mfs/mfsmaster.cfg
done
if [ "$2" = "ha" ]; then
# Add lines for lizardfs-uraft.cfg
# For each variable that starts with `LIZARDFS_URAFT_`, add the value
# to `lizardfs-uraft.cfg` file.
rm -f /etc/mfs/lizardfs-uraft.cfg # We remove the config file to reset config
configs=${!LIZARDFS_URAFT_*}
for var in $configs; do
config_name=${var#*_*_}
if [ `echo $config_name | grep 'URAFT_NODE_ADDRESS_[0-9]*'` ]; then
# Allow setting multiple values for URAFT_NODE_ADRESS
echo "URAFT_NODE_ADDRESS = ${!var}" >> /etc/mfs/lizardfs-uraft.cfg
else
# For all other settings just set the value normally
echo "${config_name} = ${!var}" >> /etc/mfs/lizardfs-uraft.cfg
fi
done
fi
# Add lines for mfsexports.cfg
# For each variable that starts with `MFSEXPORTS_`, add the value
# to `mfsexports.cfg` file.
rm -f /etc/mfs/mfsexports.cfg # We remove the config file to reset config
configs=${!MFSEXPORTS_*}
for var in $configs; do
echo "${!var}" >> /etc/mfs/mfsexports.cfg
done
# Add lines for mfsgoals.cfg
# For each variable that starts with `MFSGOALS_`, add the value
# to `mfsexports.cfg` file.
rm -f /etc/mfs/mfsgoals.cfg # We remove the config file to reset config
configs=${!MFSGOALS_*}
for var in $configs; do
echo "${!var}" >> /etc/mfs/mfsgoals.cfg
done
# Add lines for mfstopology.cfg
# For each variable that starts with `MFSTOPOLOGY_`, add the value
# to `mfsexports.cfg` file.
rm -f /etc/mfs/mfstopology.cfg # We remove the config file to reset config
configs=${!MFSTOPOLOGY_*}
for var in $configs; do
echo "${!var}" >> /etc/mfs/mfstopology.cfg
done
# Configure LizardFS Metalogger
elif [ "$1" = "metalogger" ]; then
# Add config for mfsmetalogger.cfg
# For each vairable that starts with `MFSMETALOGGER_`, remove the
# prefix and add the value to the `mfsmaster.cfg` file.
rm -f /etc/mfs/mfsmetalogger.cfg # We remove the config file to reset config
configs=${!MFSMETALOGGER_*}
for var in $configs; do
config_name=${var#*_}
echo "${config_name} = ${!var}" >> /etc/mfs/mfsmetalogger.cfg
done
# Configure LizardFS Chunkserver
elif [ "$1" = "chunkserver" ]; then
# Add config for mfschunkserver.cfg
# For each vairable that starts with `MFSCHUNKSERVER_`, remove the
# prefix and add the value to the `mfsmaster.cfg` file.
rm -f /etc/mfs/mfschunkserver.cfg # We remove the config file to reset config
configs=${!MFSCHUNKSERVER_*}
for var in $configs; do
config_name=${var#*_}
echo "${config_name} = ${!var}" >> /etc/mfs/mfschunkserver.cfg
done
# Add lines for mfshdd.cfg
# For each variable that starts with `MFSHDD_`, add the value
# to `mfsexports.cfg` file.
rm -f /etc/mfs/mfshdd.cfg # We remove the config file to reset config
configs=${!MFSHDD_*}
for var in $configs; do
# Add line to config
echo "${!var}" >> /etc/mfs/mfshdd.cfg
# Make sure dir exists and owner is correct if not prefixed with a `*`
# to indicate that the drive should be evacuated.
if [ ! $(echo ${!var} | grep '^\*.*') ]; then
mkdir -p ${!var}
chown -R mfs:mfs ${!var}
fi
done
fi
# Ensure proper ownership of the /var/lib/mfs directory
chown -R mfs:mfs /var/lib/mfs