Code:
#!/bin/sh
# 1.0 Patch mercurial, this is only needed when downloading from etherlab-hg source with mercurial.
# search for hg config file in your /c drive : $ hg config --debug
# enable qpush in config file by adding :
# [extensions]
# mq =
rm -rf /etc/mercurial/hgrc
cp /usr/share/ethercat/install_script/hgrc /etc/mercurial/
# 2.0 Install ethercat ==> https://github.com/grotius-cnc/ethercat-hg/releases/tag/1.2
# 2.1 Build .deb packages, if it trows an error, check if your kernel header files are present.
#/usr/share/ethercat/ethercat_source/etherlabmaster/dpkg-buildpackage
# 2.2 Install .deb packages located in /usr/share/ethercat/ethercat_source/
dpkg -i /usr/share/ethercat/ethercat/etherlabmaster_1.5.2+20190904hg33b922p8ea394-1_amd64.deb
# 2.3 Delete previous installed ethercat file by step #2 at /etc/default/ethercat.
rm /etc/default/ethercat
echo "Remove ethercat file in /etc/default/ethercat"
# 2.4 Copy blanco ethercat file to /etc/default/
cp /usr/share/ethercat/install_script/ethercat /etc/default/
# 2.5 Append text "mac-adres" to blanco ethercat file.
echo MASTER0_DEVICE="$(cat /sys/class/net/enp0s25/address)" >> /etc/default/ethercat
echo ".. Retrieved MAC adres : $(cat /sys/class/net/enp0s25/address)"
echo ".. .. Appending MAC adres to last line of ethercat file /etc/default/"
# 2.6 Changing priveleges to /etc/udev/rules.d/00-ethercat.rules
# Set the file permissions
chmod go+rwx /etc/udev/rules.d/99-ethercat.rules
# Add new priveleges
echo "KERNEL=="\"EtherCAT[0-9]*\"", MODE="\"777\"", GROUP=""\"ethercat\"" > /etc/udev/rules.d/99-ethercat.rules
# /dev/EtherCAT0
#chmod go+rwx /dev/EtherCAT0
# 3.0 Install linuxcnc-ethercat from source
# be sure libexpat1-dev is installed
make -C /usr/share/ethercat/linuxcnc_ethercat/
echo "Compiling the linuxcnc-ethercat lcec driver"
# 3.1 Copy "lcec.so" to /usr/lib/linuxcnc/modules/
cp /usr/share/ethercat/linuxcnc_ethercat/src/lcec.so /usr/lib/linuxcnc/modules/
# 3.2 Add rights to lcec_conf
chmod 777 /usr/share/ethercat/linuxcnc_ethercat/src/lcec_conf
# 4.0 Ethercat bus not started, try again :
# 4.1 Update ethercat config
update-ethercat-config
# 4.2 Start ethercat bus without rebooting
systemctl restart systemd-modules-load.service