026db5144c32e781251e00726b62c858f3b9dbdc
[hashcat.git] / tools / deps.sh
1 #!/bin/bash
2 # Author: Gabriele Gristina <matrix@hashcat.net>
3 # Revision: 1.03
4
5 ## global vars
6 DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip opencl-headers ocl-icd-libopencl1"
7 DEPS_AMD_DEV="ocl-icd-opencl-dev"
8 DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip gdk_linux_amd64_352_55_release.run"
9
10 ## enter the deps directory
11 cur_directory=$(dirname ${0})
12 script_directory=$(cd ${cur_directory} && pwd -P)
13 deps_dir=${script_directory}/../deps
14
15 mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
16 cd ${deps_dir}
17
18 ## cleanup the directories under the 'deps' folder
19 rm -rf {adl-sdk*,nvidia-gdk,R352-developer} && \
20 mkdir -p {tmp,adl-sdk,nvidia-gdk,R352-developer} && \
21 cd tmp/
22
23 if [ $? -ne 0 ]; then
24 echo "! Cannot create deps directories."
25 exit 1
26 fi
27
28 ## check dependencies
29 i=0
30 for d in ${DOWNLOAD_DEPS}; do
31 if [ ! -f "${d}" ]; then
32 echo "! ${d} not found."
33 ((i++))
34 fi
35 done
36
37 if [ ${i} -gt 0 ]; then
38 echo "! Please manually download all the above dependencies to the deps/tmp/ directory"
39 exit 1
40 fi
41
42 ## installing needed packages
43 for pkg in ${DEPS}; do
44
45 # check if the package is already installed
46 dpkg -s ${pkg} &>/dev/null
47 if [ $? -ne 0 ]; then
48 ## root check
49 if [ $(id -u) -ne 0 ]; then
50 echo "! Must be root to install the required package '${pkg}' with apt-get"
51 exit 1
52 fi
53
54 apt-get -y install ${pkg}
55 if [ $? -ne 0 ]; then
56 echo "! failed to install ${pkg}"
57 exit 1
58 fi
59 fi
60 done
61
62 ## extract ADL SDK
63 unzip ADL_SDK8.zip -d ${deps_dir}/adl-sdk-8
64 ret=$?
65
66 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
67 echo "! failed to extract ADL SDK"
68 exit 1
69 fi
70
71 rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-8 ${deps_dir}/adl-sdk
72
73 if [ $? -ne 0 ]; then
74 echo "! failed to setup ADL SDK link"
75 exit 1
76 fi
77
78 ## extract NVAPI
79 unzip R352-developer.zip -d ${deps_dir}
80 ret=$?
81
82 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
83 echo "! failed to extract NVAPI"
84 exit 1
85 fi
86
87 ## install NVIDIA GPU Deployment Kit
88 chmod +x gdk_linux_amd64_352_55_release.run && \
89 ./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
90
91 if [ $? -ne 0 ]; then
92 echo "! failed to install NVIDIA GPU Deployment Kit"
93 exit 1
94 fi
95
96 ## check if libOpenCL.so is available (and if not install DEPS_AMD_DEV)
97
98 ls /usr/lib/*/libOpenCL.so &> /dev/null
99
100 if [ $? -ne 0 ]; then
101 ## root check
102 if [ $(id -u) -ne 0 ]; then
103 echo "! Must be root to install '${DEPS_AMD_DEV}'"
104 exit 1
105 fi
106
107 apt-get -y install ${DEPS_AMD_DEV}
108 if [ $? -ne 0 ]; then
109 echo "! failed to install ${DEPS_AMD_DEV}"
110 exit 1
111 fi
112 fi
113
114 echo "> oclHashcat dependencies have been resolved."