-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·79 lines (61 loc) · 1.65 KB
/
install.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
#!/bin/bash
executable=linux-id
function handle() {
if [ $? -ne 0 ]; then
echo "$1"
exit 1
fi
}
function make_executable() {
go build -o $executable
handle "Failed to build executable"
chmod +x $executable
handle "Failed to make executable"
sudo cp $executable /usr/local/bin
handle "Failed to copy executable"
$executable -h
handle "Failed to run executable"
}
function autostart() {
if [ ! -d /etc/systemd ]; then
echo "systemd is not present, exiting"
exit 1
fi
cat <<EOF >>/home/$USER/.config/autostart/linux-id.desktop
[Desktop Entry]
Exec=/usr/local/bin/linux-id
Icon=
Name=linux-id
Path=
Terminal=False
Type=Application
EOF
handle "Failed to add uhid to udev rules"
}
function check_prereqs() {
if [ ! -d /sys/class/tpm/tpm0 ]; then
echo "TPM is not present, make sure to enable it in BIOS/UEFI"
exit 1
fi
if ! command -v go &>/dev/null; then
echo "Go is not installed, please install it"
exit 1
fi
if ! command -v pinentry &>/dev/null; then
echo "Pinentry is not installed, please install it"
exit 1
fi
}
check_prereqs
if [ ! -f /usr/local/bin/$executable ]; then
make_executable
else
echo "Executable already exists, skipping"
fi
sudo usermod -aG tss $USER
handle "Failed to add a user to tss group, check privileges and if tss group exists"
echo uhid | sudo tee /etc/modules-load.d/uhid.conf
handle "Failed to add uhid to modules"
echo 'KERNEL=="uhid", SUBSYSTEM=="misc", GROUP="users", MODE="0660"' | sudo tee /etc/udev/rules.d/70-uhid.rules
autostart
echo "Installation successful, now reboot"