Skip to content

Commit

Permalink
fix: #12 ubuntu does not load new modules
Browse files Browse the repository at this point in the history
  • Loading branch information
atar-axis committed Mar 2, 2018
1 parent 427913e commit 40266c3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
71 changes: 71 additions & 0 deletions out/x86_64/4.13.0-21-generic/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -x

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi

hid_xpadneo=$(modinfo -n hid-xpadneo 2> /dev/null)
hid=$(modinfo -n hid 2> /dev/null)
bluetooth=$(modinfo -n bluetooth 2> /dev/null)

extramodules="/lib/modules/"$(uname -r)"/extramodules/"


sudo [ ! -d "$extramodules"_bak ] && sudo mkdir --parents $extramodules

# install xpadneo

if [ "$hid_xpadneo" == "" ]
then
echo "** install xpadneo"
sudo cp -f ./hid-xpadneo.ko "$extramodules"
else
echo "** replace xpadneo"
sudo [ ! -f "$hid_xpadneo"_bak ] && sudo mv "$hid_xpadneo" "$hid_xpadneo"_bak
sudo cp -f ./hid-xpadneo.ko $(dirname "$hid_xpadneo")
fi

# install hid

if [ "$hid" == "" ]
then
echo "** install hid"
sudo cp -f ./hid.ko "$extramodules"
else
echo "** replace hid"
sudo [ ! -f "$hid"_bak ] && sudo mv "$hid" "$hid"_bak
sudo cp -f ./hid.ko $(dirname "$hid")
fi

# install bluetooth

if [ "$bluetooth" == "" ]
then
echo "** install bluetooth"
sudo cp -f ./bluetooth.ko "$extramodules"
else
echo "** replace bluetooth"
sudo [ ! -f "$bluetooth"_bak ] && sudo mv "$bluetooth" "$bluetooth"_bak
sudo cp -f ./bluetooth.ko $(dirname "$bluetooth")
fi


sudo depmod

sudo modprobe hid-xpadneo
sudo modprobe hid
sudo modprobe bluetooth


if [[ $(crc32 $hid) != $(crc32 ./hid.ko) \
|| $(crc32 $bluetooth) != $(crc32 ./bluetooth.ko) \
|| $(crc32 $hid_xpadneo) != $(crc32 ./hid-xpadneo.ko) ]]
then
echo something went wrong, files checksums are not correct
exit 1
else
echo "* installed/replaced successfully"
fi;
11 changes: 7 additions & 4 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ else
sudo cp -f ./hid.ko $(dirname "$hid")
fi

# install bluetoot
# install bluetooth
if [ "$bluetooth" == "" ]
then
echo "** install bluetooth"
Expand All @@ -61,18 +61,21 @@ if [[ $(crc32 $hid) != $(crc32 ./hid.ko) \
|| $(crc32 $bluetooth) != $(crc32 ./bluetooth.ko) \
|| $(crc32 $hid_xpadneo) != $(crc32 ./hid-xpadneo.ko) ]]
then
echo something went wrong, files checksums are not correct
echo something went wrong, checksums are not correct
exit 1
else
echo "* installed/replaced successfully"
fi;

# Update initram on Ubuntu
# Update initramfs on Ubuntu
if [[ "$(uname -v | grep -o Ubuntu)" != "" ]]
then
# fix for non-working mouse after update-initramfs
# TODO: use patch instead of append it blind
sudo /bin/bash -c "echo 'hid' >> /etc/initramfs-tools/modules"
sudo /bin/bash -c "echo 'usbhid' >> /etc/initramfs-tools/modules"
sudo /bin/bash -c "echo 'hid_generic' >> /etc/initramfs-tools/modules"
sudo /bin/bash -c "echo 'ohci_pci' >> /etc/initramfs-tools/modules"
sudo update-initramfs -u
# update initramfs (reload hid.ko and bluetooth.ko to ram at startup)
sudo update-initramfs -u -k all
fi;

0 comments on commit 40266c3

Please sign in to comment.