-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaxonomia.sh
126 lines (121 loc) · 7.85 KB
/
taxonomia.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
120
121
122
123
124
125
126
#!bin/bash
############################################################################################################
############################################################################################################
########## Content: Shell Script to create taxonomy on HDFS ############################
########## Author: Jorge Quintana ############################
########## Date: January, 10th 2017 ############################
########## Contact: [email protected] ############################
############################################################################################################
############################################################################################################
############################################################################################################
############################################################################################################
########### ############################
########### Building the taxonomy needed to the migration process and external ############################
########### ############################
############################################################################################################
############################################################################################################
############################################################################################################
########### ############################
########### The root of the taxonomy is the folder for Colombia ############################
########### From here all the areas are defined and the sanatas ############################
########### files are migrated to their folders ############################
########### ############################
########### The different areas of the taxonomy are the following ############################
########### ############################
########### ############################
################### 1. colombia/landing #####################################
################### 2. colombia/staging #####################################
########### ############################
########### Also, these two areas have different folders inside such as ############################
########### ############################
########### ############################
################### 1.1 colombia/landing/sanatas #####################################
################### 1.1.1 colombia/landing/sanatas/.... #####################################
################### 2.1 colombia/staging #####################################
################### 2.1.1 colombia/staging/.... #####################################
########### ############################
########### The taxonomy creation process designed with this script ############################
########### is only related to /colombia/landing/ folder ############################
########### ############################
############################################################################################################
############################################################################################################
############################################################################################################
############################################################################################################
############################################################################################################
######### ##########################
######### We create the folders in HDFS specified before but previously ##########################
######### validating the existence of these folders and the result of creation ##########################
######### ##########################
############################################################################################################
############################################################################################################
hdfs dfs -test -e /colombia
if [ $? != 0 ]; then
echo "Creating /colombia Directory"
hdfs dfs -mkdir -p /colombia
if [ $? == 0 ]; then
echo "Directory /colombia created succesfully!"
echo "Creating /colombia/landing directory"
hdfs dfs -mkdir -p /colombia/landing
if [ $? == 0 ]; then
echo "Directory /colombia/landing created successfully!"
echo "Creating /colombia/landing/sanatas directory"
hdfs dfs -mkdir -p /colombia/landing/sanatas
if [ $? == 0 ]; then
echo "Directory /colombia/landing/sanatas created successfully!"
else
echo "Directory /colombia/landing/sanatas could not be created!"
exit 1
fi
else
echo "Directory /colombia/landing could not be created!"
fi
else
echo "Directory /colombia could not be created!"
exit 1
fi
else
echo "Directory /colombia is already created!"
hdfs dfs -test -e /colombia/landing
if [ $? != 0 ]; then
echo "Creating /colombia/landing directory"
hdfs dfs -mkdir -p /colombia/landing
if [ $? == 0 ]; then
echo "Directory /colombia/landing created successfully!"
echo "Creating /colombia/landing/sanatas directory"
hdfs dfs -mkdir -p /colombia/landing/sanatas
if [ $? == 0 ]; then
echo "Directory /colombia/landing/sanatas created successfully!"
else
echo "Directory /colombia/landing/sanatas could not be created!"
exit 1
fi
else
echo "Directory /colombia/landing could not be created!"
exit 1
fi
else
echo "Directory /colombia/landing is already created!"
hdfs dfs -test -e /colombia/landing/sanatas
if [ $? != 0 ]; then
echo "Creating /colombia/landing/sanatas directory"
hdfs dfs -mkdir -p /colombia/landing/sanatas
if [ $? == 0 ]; then
echo "Directory /colombia/landing/sanatas created successfully!"
else
echo "Directory /colombia/landing/sanatas could not be created!"
exit 1
fi
else
echo "Directory /colombia/landing/sanatas is already created!"
fi
fi
fi
return 0
###########################################################################################################
###########################################################################################################
####### ##########
####### Finally, if the creation process was successful return a 0 to the main shell to validate ##########
####### the result of the process and continue with the next execution ##########
####### ##########
###########################################################################################################
###########################################################################################################