-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsetup_fresh_env.sh
executable file
·136 lines (117 loc) · 3.5 KB
/
setup_fresh_env.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
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
# Get absolute folder for this script
callerFolderPath="`cd "${BASH_SOURCE[0]%/*}"; pwd -P`/" # Command to get the absolute path
# Include config file extension
. "${callerFolderPath}extend_config_file.sh"
setupSubmodules()
{
echo -n "Fetching submodules... "
local log=$(git submodule update --init --recursive 2>&1)
if [ $? -ne 0 ];
then
echo "failed!"
echo ""
echo "Error log:"
echo $log
exit 1
fi
echo "done"
}
setupSparkleHelper()
{
local sparkleHelperFolder="${callerFolderPath}3rdparty/sparkleHelper/"
local sparkleHelperScriptsFolder="${sparkleHelperFolder}scripts/"
local resourcesFolder="${callerFolderPath}resources"
# Call setup_fresh_env.sh from SparkleHelper
${sparkleHelperScriptsFolder}setup_fresh_env.sh "${params['identity']}"
# Generate DSA keys
${sparkleHelperScriptsFolder}generate_dsa_keys.sh "${resourcesFolder}"
}
setupPCap()
{
getOS osName
if [[ $osName == "win" ]];
then
local wpcapInstallFolder="3rdparty/avdecc/externals/3rdparty/winpcap"
if [[ ! -d "${wpcapInstallFolder}/Include" || ! -d "${wpcapInstallFolder}/Lib" ]];
then
echo -n "Downloading WinPcap Developer's Pack... "
local result
result=$(which wget 2>&1)
if [ $? -ne 0 ];
then
echo "failed, wget not found (see ${wpcapInstallFolder}/README.me for manually installation instructions)"
else
local wpcapOutputFile="_WpdPack.zip"
rm -f "$wpcapOutputFile"
local log=$("$result" https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip -O "$wpcapOutputFile" 2>&1)
if [ $? -ne 0 ];
then
echo "failed!"
echo ""
echo "Error log:"
echo $log
rm -f "$wpcapOutputFile"
exit 1
fi
echo "done"
echo -n "Installing WinPcap Developer's Pack... "
result=$(which unzip 2>&1)
if [ $? -ne 0 ];
then
echo "failed, unzip not found (see ${wpcapInstallFolder}/README.me for manually installation instructions)"
rm -f "$wpcapOutputFile"
else
local wpcapOutputFolder="_WpdPack"
rm -rf "$wpcapOutputFolder"
local log=$("$result" -d "$wpcapOutputFolder" "$wpcapOutputFile" 2>&1)
if [ $? -ne 0 ];
then
echo "failed!"
echo ""
echo "Error log:"
echo $log
rm -f "$wpcapOutputFile"
rm -rf "$wpcapOutputFolder"
exit 1
fi
mv "${wpcapOutputFolder}/WpdPack/Include" "${wpcapInstallFolder}/"
mv "${wpcapOutputFolder}/WpdPack/Lib" "${wpcapInstallFolder}/"
rm -f "$wpcapOutputFile"
rm -rf "$wpcapOutputFolder"
echo "done"
fi
fi
fi
fi
echo "done"
}
configFile=".hive_config"
if [ ! -f "${configFile}" ]; then
echo "ERROR: You must create and configure a ${configFile} file before running this script:"
echo "Copy ${configFile}.sample file to ${configFile} then edit it to your needs."
exit 1
fi
setupSubmodules
# Include utils functions
. "${callerFolderPath}3rdparty/avdecc/scripts/bashUtils/utils.sh"
# Include config file functions
. "${callerFolderPath}3rdparty/avdecc/scripts/bashUtils/load_config_file.sh"
# Load config file
loadConfigFile
if [ "x${params["use_sparkle"]}" == "xtrue" ]; then
# Setup Sparkle
setupSparkleHelper
else
# Generate empty DSA keys for non-Sparkle builds
if [ ! -f "${callerFolderPath}resources/dsa_pub.pem" ]; then
echo -n "Generating empty DSA keys... "
echo "Sparkle disabled, this is an empty DSA Key. Remove this file when enabling Sparkle" > "${callerFolderPath}resources/dsa_pub.pem"
echo "done"
fi
fi
# Setup PCap
setupPCap
echo "DO NOT REMOVE THIS FILE" > ".initialized"
echo "All done!"
exit 0