-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
preinstall.sh
executable file
·40 lines (36 loc) · 1.58 KB
/
preinstall.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
#!/bin/bash
# Title : preinstall.sh
# Description : This script will create a udev symlink for a Bluetooth Remote
# Author : shbatm
# Date : 2021-01-09
# Version : 0.0.2
# Usage : ./preinstall.sh
# Notes : This script assumes you are using an Amazon Fire TV Remote.
# : any bluetooth device can be used, but you must change the
# : name in the 99-btremote.rules file to match the device.
# : To find the name, connect the device via the desktop and run
# : either "udevadm info -a -p $(udevadm info -q path -n
# : /dev/input/event0) | grep ATTRS{name}" or
# : "cat /proc/bus/input/devices" to get the Name to use.
#==============================================================================
echo "Check for required Debian packages"
PACKAGE_BUILDESSENTIAL="build-essential"
if [ $(dpkg-query -W -f='${Status}' $PACKAGE_BUILDESSENTIAL 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo " Install $PACKAGE_BUILDESSENTIAL"
sudo apt update
sudo apt install -y $PACKAGE_BUILDESSENTIAL
else
echo " $PACKAGE_BUILDESSENTIAL is already installed."
fi
PACKAGE_UDEV="libudev-dev"
if [ $(dpkg-query -W -f='${Status}' $PACKAGE_UDEV 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo " Install $PACKAGE_UDEV"
sudo apt update
sudo apt install -y $PACKAGE_UDEV
else
echo " $PACKAGE_UDEV is already installed."
fi
echo "Copy the udev rules file to the correct location"
sudo cp 99-btremote.rules /etc/udev/rules.d/
echo "Reload the udev rules"
sudo udevadm control -R