-
Notifications
You must be signed in to change notification settings - Fork 397
/
deployfabric.sh
executable file
·94 lines (77 loc) · 2.58 KB
/
deployfabric.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
#!/bin/bash
# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
# ------------------------------------------------------------
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
FabricDataRoot=""
FabricBinRoot=/opt/microsoft/servicefabric/bin
ClusterManifest=""
InfraManifest=""
for i in "$@"
do
case $i in
-fdr=*|--fabricdataroot=*)
FabricDataRoot="${i#*=}"
;;
-cm=*|--clustermanifest=*)
ClusterManifest="${i#*=}"
;;
-im=*|--inframanifest=*)
InfraManifest="${i#*=}"
;;
*)
echo Error: Unknown option passed in
exit 1
;;
esac
done
# Remove trailing slash
FabricDataRoot=$(echo $FabricDataRoot | sed 's:/*$::')
echo FabricDataRoot = ${FabricDataRoot}
echo FabricBinRoot = ${FabricBinRoot}
echo ClusterManifest = ${ClusterManifest}
echo InfraManifest = ${InfraManifest}
if [ "" = "$FabricDataRoot" ]; then
echo FabricDataRoot is invalid. Please provide a valid path
exit 1
fi
if [ "" = "$ClusterManifest" ]; then
echo ClusterManifest path is invalid. Please provide a valid path
exit 1
fi
FabricCodePath=${FabricBinRoot}/Fabric/Fabric.Code
FabricLogRoot=${FabricDataRoot}/log
echo "Setting environment for FabricDeployer to run"
if [ ! -d /etc/servicefabric ]; then
mkdir /etc/servicefabric
fi
echo -n ${FabricDataRoot} > /etc/servicefabric/FabricDataRoot
echo -n ${FabricDataRoot}/log > /etc/servicefabric/FabricLogRoot
echo -n ${FabricBinRoot} > /etc/servicefabric/FabricBinRoot
echo -n ${FabricCodePath} > /etc/servicefabric/FabricCodePath
export LD_LIBRARY_PATH=${FabricCodePath}
mkdir -p ${FabricLogRoot}/Traces
echo Running FabricDeployer on ${ClusterManifest}
if [ "" = "$InfraManifest" ]; then
${FabricCodePath}/FabricDeployer.sh /operation:Create /fabricBinRoot:${FabricBinRoot} /fabricDataRoot:${FabricDataRoot} /cm:${ClusterManifest}
else
${FabricCodePath}/FabricDeployer.sh /operation:Create /fabricBinRoot:${FabricBinRoot} /fabricDataRoot:${FabricDataRoot} /cm:${ClusterManifest} /im:${InfraManifest}
fi
if [ $? != 0 ]; then
echo Error: FabricDeployer.exe failed
exit 1
fi
echo Setting sfuser as owner for FabricDataRoot
chown -R sfuser:sfuser ${FabricDataRoot} || exit 1
echo Setting sfuser as owner of FabricBinRoot
chown -R sfuser:sfuser ${FabricBinRoot} || exit 1
echo Enable service fabric service
systemctl enable servicefabric
if [ $? != 0 ]; then
echo Error: Failed to enable servicefabric daemon
exit 1
fi