From 9f22843b86c5acdf58150a77b38f4319a9f2884e Mon Sep 17 00:00:00 2001 From: nagutabby Date: Sun, 2 Jan 2022 09:25:05 +0900 Subject: [PATCH 1/2] Fixed the bug that can't uninstall ModemManager and install uucp in openSUSE --- arduino-linux-setup-15.sh | 392 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 arduino-linux-setup-15.sh diff --git a/arduino-linux-setup-15.sh b/arduino-linux-setup-15.sh new file mode 100644 index 0000000..e8f16da --- /dev/null +++ b/arduino-linux-setup-15.sh @@ -0,0 +1,392 @@ +#!/bin/bash +# arduino-linux-setup.sh : A simple Arduino setup script for Linux systems +# Copyright (C) 2015 Arduino Srl +# +# Author : Arturo Rinaldi +# E-mail : arty.net2@gmail.com +# Project URL : https://github.com/artynet/arduino-linux-setup +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Release v15 changelog : +# +# + Fixed the bug that can't uninstall ModemManager and install uucp in openSUSE +# +# Release v14 changelog : +# +# + Installing uucp package for different Linux distros +# + Rewriting UDEV rule for STM32 bootloader mode +# +# Release v13 changelog : +# +# + Disabling serial port HW flow +# +# Release v12 changelog : +# +# + Improving rules for DFU mode +# +# Release v11 changelog : +# +# + Fixing ModemManager removal for Fedora Core +# + Adding Atmel ICE Debugger CMSIS-DAP rule +# +# Release v10 changelog : +# +# + Adding support for Slackware +# + Changed distribution not supported message +# + Changed distribution check sort order (thanks to thenktor @github.com) +# + Small fix for ArchLinux +# +# Release v9 changelog : +# +# + Adding support for ArchLinux +# + Adding support for systemd +# + Fixing a couple of wrong kernel entries +# +# Release v8 changelog : +# +# + rules are now created in /tmp folder +# +# Release v7 changelog : +# +# + Adding project URL +# + minor bugfixing +# +# Release v6 changelog : +# +# + removing sudocheck function and control +# +# Release v5 changelog : +# +# + adding UDEV rule for stm32 DFU mode +# +# Release v4 changelog : +# +# + The rules are generated in a temporary folder +# +# + the user should run it without sudo while having its permissions +# +# Release v3 changelog : +# +# + The most common linux distros are now fully supported +# +# + now the script checks for SUDO permissions +# + +#!/bin/bash + +# if [[ $EUID != 0 ]] ; then +# echo This must be run as root! +# exit 1 +# fi + +refreshudev () { + + echo "" + echo "Restarting udev" + echo "" + + sudo udevadm control --reload-rules + sudo udevadm trigger + + if [ -d /lib/systemd/ ] + then + sudo systemctl restart systemd-udevd + else + sudo service udev restart + fi + +} + +groupsfunc () { + + echo "" + echo "******* Add User to dialout,tty, uucp, plugdev groups *******" + echo "" + + sudo groupadd tty + sudo groupadd dialout + sudo groupadd uucp + sudo groupadd plugdev + + sudo usermod -a -G tty $1 + sudo usermod -a -G dialout $1 + sudo usermod -a -G uucp $1 + sudo usermod -a -G plugdev $1 + +} + +acmrules () { + + echo "" + echo "# Setting serial port rules" + echo "" + +cat < /tmp/90-extraacl.rules + + openocdrules > /tmp/98-openocd.rules + + avrisprules > /tmp/avrisp.rules + + dfustm32rules > /tmp/40-dfuse.rules + + dfuarduino101rules > /tmp/99-arduino-101.rules + + usbgenericrules > /tmp/00-usb-permissions.rules + + hardwareflowdisable > /tmp/uucp-port + + sudo mv /tmp/*.rules /etc/udev/rules.d/ + + sudo mv /tmp/uucp-port /etc/uucp/port + + refreshudev + + echo "" + echo "*********** Please Reboot your system ************" + echo "" +fi From df5de58b06acb46bb86e5c6adc4288403f346044 Mon Sep 17 00:00:00 2001 From: nagutabby Date: Sun, 2 Jan 2022 09:48:50 +0900 Subject: [PATCH 2/2] Fixed conditional expressions --- arduino-linux-setup-15.sh | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/arduino-linux-setup-15.sh b/arduino-linux-setup-15.sh index e8f16da..f0aa3f6 100644 --- a/arduino-linux-setup-15.sh +++ b/arduino-linux-setup-15.sh @@ -278,15 +278,10 @@ removemm () { echo "******* Removing modem manager *******" echo "" - if [ -f /etc/os-release ] + if [ -f /etc/os-release ] && [[ $(sed -En 's/^NAME="(.*)"/\1/gp' /etc/os-release) =~ openSUSE ]] then #Only for openSUSE - NAME=$(sed -En 's/^NAME="(.*)"/\1/gp' /etc/os-release) - if [[ $NAME =~ openSUSE ]] - then - sudo zypper remove -y ModemManager - fi - + sudo zypper remove -y ModemManager elif [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] then #Only for Red Hat/Fedora/CentOS @@ -318,15 +313,10 @@ adduucp () { echo "******* UUCP *******" echo "" - if [ -f /etc/os-release ] + if [ -f /etc/os-release ] && [[ $(sed -En 's/^NAME="(.*)"/\1/gp' /etc/os-release) =~ openSUSE ]] then #Only for openSUSE - NAME=$(sed -En 's/^NAME="(.*)"/\1/gp' /etc/os-release) - if [[ $NAME =~ openSUSE ]] - then - sudo zypper update -y && sudo zypper in -y -n uucp - fi - + sudo zypper update -y && sudo zypper in -y -n uucp elif [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] then #Only for Red Hat/Fedora/CentOS