-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepareDir.sh
executable file
·119 lines (93 loc) · 3.13 KB
/
prepareDir.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
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# test in arch linux only
# plz do not change this
set -e
set -o pipefail
echo "now your home dir is: ${HOME}"
#echo "${PWD}"
#defaultDIR="${PWD}/default"
#configDIR="${PWD}/etc"
PREFIX=$(sed '/^#define PREFIX/!d;s/.* //' ./etc/config.h | sed 's/\"//g')
echo "PREFIX: ${PREFIX}"
#
REAL_DFS_HOME=${HOME}/opendfs
echo "REAL_DFS_HOME: ${REAL_DFS_HOME}"
# in this step ,we need fix home dir
sed -i "s:${PREFIX}:${REAL_DFS_HOME}:" ./etc/datanode.conf
sed -i "s:${PREFIX}:${REAL_DFS_HOME}:" ./etc/namenode.conf
sed -i "s:${PREFIX}:${REAL_DFS_HOME}:" ./etc/config.h
# end
mkdir -p "${PREFIX}"
echo "now your config and disk dir:${PREFIX} , and config file will be copy to this dir"
cp -rf ./etc "${PREFIX}"
if [ -z "$PREFIX" ]; then
echo "PREFIX is empty, exit after 5s"
sleep 5
exit
fi
if [ -n "$PREFIX" ]; then
echo "" # continue
fi
# datanode
echo "now start to mk datanode dir"
dn_data_dir=$(awk -F '"' '//{a=1}a==1&&$1~/data_dir/{print $2;exit}' ./etc/datanode.conf)
echo "tip: your PREFIX in config.h should be set and should be same with prefix in the conf file"
if [ -z "$dn_data_dir" ]; then
echo "error: data_dir is empty, exit after 5s"
sleep 5
exit
fi
if [ -n "$dn_data_dir" ]; then
echo "" # continue
fi
if [[ $dn_data_dir =~ $PREFIX ]]
then
echo "now start to mkdir ${dn_data_dir}"
mkdir -p "${dn_data_dir}"
else
echo "error: your PREFIX not same whit the conf, PREFIX is ${PREFIX} while data_dir is ${dn_data_dir}"
echo "exit after 5s"
sleep 5
exit 1
fi
dn_error_log=$( awk -F '"' '//{a=1}a==1&&$1~/error_log/{print $2;exit}' ./etc/datanode.conf)
echo "mkdir ${dn_error_log%\/*}"
mkdir -p "${dn_error_log%\/*}"
dn_pid_file=$( awk -F '"' '//{a=1}a==1&&$1~/pid_file/{print $2;exit}' ./etc/datanode.conf)
echo "mkdir ${dn_pid_file%\/*}"
mkdir -p "${dn_pid_file%\/*}"
dn_coredump_dir=$(awk -F '"' '//{a=1}a==1&&$1~/coredump_dir/{print $2;exit}' ./etc/datanode.conf)
echo "mkdir ${dn_coredump_dir}"
mkdir -p "${dn_coredump_dir}"
#if [ ! -d testgrid ];then
# mkdir testgrid
#else
# echo dir exist
#fi
# namenode
echo "now start to mk namenode dir"
nn_editlog_dir=$(awk -F '"' '//{a=1}a==1&&$1~/editlog_dir/{print $2;exit}' ./etc/namenode.conf)
if [[ $nn_editlog_dir =~ $PREFIX ]]
then
echo "now start to mkdir ${nn_editlog_dir}"
mkdir -p "${nn_editlog_dir}"
else
echo "error: your PREFIX not same whit the conf, PREFIX is ${PREFIX} while data_dir is ${nn_editlog_dir}"
echo "exit after 5s"
sleep 5
exit 1
fi
nn_fsimage_dir=$( awk -F '"' '//{a=1}a==1&&$1~/fsimage_dir/{print $2;exit}' ./etc/namenode.conf)
echo "mkdir ${nn_fsimage_dir}"
mkdir -p "${nn_fsimage_dir}"
nn_error_log=$( awk -F '"' '//{a=1}a==1&&$1~/error_log/{print $2;exit}' ./etc/namenode.conf)
echo "mkdir ${nn_error_log%\/*}"
mkdir -p "${nn_error_log%\/*}"
nn_pid_file=$( awk -F '"' '//{a=1}a==1&&$1~/pid_file/{print $2;exit}' ./etc/namenode.conf)
echo "mkdir ${nn_pid_file%\/*}"
mkdir -p "${nn_pid_file%\/*}"
nn_coredump_dir=$(awk -F '"' '//{a=1}a==1&&$1~/coredump_dir/{print $2;exit}' ./etc/namenode.conf)
echo "mkdir ${nn_coredump_dir}"
mkdir -p "${nn_coredump_dir}"
echo "successful, you have create all dir"
exit 0