I am trying to create a Bash script that will run on system startup and modify the permissions for a number of ttyA ports. I'm unsure how to go about this and was wondering if I could get some help.
My current code is:
#!/bin/bash
TTYA=$ ls /dev/ttyA11
echo $TTYA
echo 'outside'
if [[ $$TTYA == 'ttyA11' ]]
then
echo 'inside'
chmod g+rw /dev/ttyA*
fi
Output:
$ sudo ./rc.serial
/dev/ttyA11
outside
Unfortunately this method does not work due to the if
statement not being true. I'm unsure if I've correctly told my variable to check for ttyA11
.
plugdev
group instead? – Arkadiusz Drabczyk Oct 12 '20 at 10:56plugdev
, but I do know myttyA
ports need to be assigned to thedialout
group. – user427317 Oct 12 '20 at 11:04dialout
group of course. – Arkadiusz Drabczyk Oct 12 '20 at 11:04chmod g+rw /dev/ttyA*
andchgrp dialout /dev/ttyA*
in a bash script that I will run during system startup. I'm certain there's an efficient way to do this that my current listed method. But I'm new to Bash scripting and only have a very tiny amount of knowledge on this – user427317 Oct 12 '20 at 11:07/dev/ttyA11
exists? – Arkadiusz Drabczyk Oct 12 '20 at 11:09ttyA11
port is loaded by a driver every time the system loads however it has the wrong permissions and group set. So to combat this I would like to make a script file that updates the permissions and group accordingly when the system starts up. I don't want to keep updating the permissions manually every time I restart my machine basically. Hope this helps? – user427317 Oct 12 '20 at 11:13udev
rule to set the group aan mode when the device is loaded - see for example Allow non-root user to read/write /dev files – steeldriver Oct 12 '20 at 13:08