-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (97 loc) · 2.77 KB
/
install.sh
File metadata and controls
executable file
·113 lines (97 loc) · 2.77 KB
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
#!/usr/bin/env bash
VERBOSE=""
NOUPDATE=""
NOXORG=""
NOCUSTOM=""
function usage
{
echo "Usage: install.sh [-v|--verbose] [-h|--help] [--noupdate]"
echo " -v | --verbose : output verbose"
echo " -h | --help : Print this help"
echo " --noupdate : Don't run apt-get update"
echo " --noxorg : Don't replace xorg"
echo " --nocustom : Don't use custom target"
}
function parse_args
{
local _ARGS=()
while [ "$1" ]
do
case "$1" in
"-v" | "--verbose" )
VERBOSE=1
;;
"-h" | "--help")
usage
exit 0
;;
"--noupdate" )
NOUPDATE=1
;;
"--noxorg" )
NOXORG=1
;;
"--nocustom" )
NOCUSTOM=1
;;
esac
shift
done
set -- "${args[@]}"
start_install
exit 0
}
function start_install
{
if [[ $EUID -ne 0 ]]; then
printf "This script must be run as root\n"
exit 1
fi
#Install jq (bash json parser) library
if [ -z "${NOUPDATE}" ]; then
apt-get update
fi
apt install -y jq
#Install opencl-headers for testing
apt install -y opencl-headers
#Put script in opt
printf "Create gputweak executable\n"
WORKDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
mkdir -p /opt/gputweak
cp -r ${WORKDIR}/* /opt/gputweak
rm -rf /usr/bin/gputweak
ln -s /opt/gputweak/gputweak /usr/bin/gputweak
#Build AMDGPU OPENCL device detector
if [[ -z "/opt/gputweak/amdgpu-devices.c" ]]; then
/usr/bin/wget https://laanwj.github.io/assets/2016/05/06/opencl-ubuntu1604/devices.c -O /opt/gputweak/amdgpu-devices.c
fi
/usr/bin/gcc /opt/gputweak/amdgpu-devices.c -o /opt/gputweak/amdgpu-devices -O2 /opt/amdgpu-pro/lib/x86_64-linux-gnu/libOpenCL.so
#Setup main xorg.conf
if [ -z "${NOXORG}" ]; then
printf "Setup xorg.conf\n"
if [[ ! -z "/etc/X11/xorg.conf" ]]; then
NOW=$(date +%s)
chattr -i /etc/X11/xorg.conf
cp /etc/X11/xorg.conf "/etc/X11/xorg.conf.${NOW}"
fi
cp /opt/gputweak/config/xorg.conf /etc/X11/xorg.conf
chattr +i /etc/X11/xorg.conf
fi
#Enable systemd custom target startup
printf "Setup systemd startup script\n"
systemctl disable gputweak.service
cp ${WORKDIR}/config/systemd/* /etc/systemd/system
if [ -z "${NOCUSTOM}" ]; then
rm -f /etc/systemd/system/default.target
ln -s /etc/systemd/system/custom.target /etc/systemd/system/default.target
fi
systemctl enable gputweak.service
systemctl daemon-reload
printf "Setup done\n"
}
function main
{
parse_args "$@"
exit 0
}
main "$@"