Last active
June 1, 2023 19:26
-
-
Save JeanElsner/908af1ccceeccabf1df1103b49c10708 to your computer and use it in GitHub Desktop.
Ethercat install script for Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
master0_device="94:c6:91:ae:d1:f5" | |
device_modules="generic" | |
sudo apt-get install -y git cmake build-essential autoconf libtool kmod | |
git clone https://gitlab.com/etherlab.org/ethercat.git | |
cd ethercat | |
git checkout stable-1.5 | |
chmod +x bootstrap | |
./bootstrap | |
./configure --disable-8139too --with-linux-dir=/usr/src/linux-headers-$(uname -r) | |
make modules | |
sudo make modules_install install | |
sudo depmod | |
echo "Adding ethercat group..." | |
sudo groupadd ethercat | |
sudo usermod -aG ethercat $(id -un) | |
echo "Updating ethercat.conf..." | |
sudo sed -i "s/\(MASTER0_DEVICE=\).*/\1\"$master0_device\"/" "/etc/ethercat.conf" | |
sudo sed -i "s/\(DEVICE_MODULES=\).*/\1\"$device_modules\"/" "/etc/ethercat.conf" | |
sudo cp /etc/ethercat.conf /usr/local/etc/ethercat.conf | |
limits_path="/etc/security/limits.conf" | |
limits=" | |
@ethercat soft rtprio 99 | |
@ethercat soft priority 99 | |
@ethercat soft memlock 102400 | |
@ethercat hard rtprio 99 | |
@ethercat hard priority 99 | |
@ethercat hard memlock 102400" | |
echo "Adding ethercat group to limits.conf..." | |
if grep -qF "@ethercat" "$limits_path"; then | |
echo "limits.conf already contains ethercat group." | |
else | |
echo "$limits" | sudo tee -a "$limits_path" >/dev/null | |
fi | |
echo "Setting device access permissions..." | |
sudo sh -c 'echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0660\", GROUP=\"ethercat\" > /lib/udev/rules.d/99-EtherCAT.rules' | |
echo "Registering libraries with dynamic linker..." | |
sudo sh -c 'echo /usr/local/lib > /etc/ld.so.conf.d/etherlab.conf' | |
sudo ldconfig | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment