-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenable_programmer_access
More file actions
executable file
·60 lines (60 loc) · 1.98 KB
/
Copy pathenable_programmer_access
File metadata and controls
executable file
·60 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
rules="90-atmel.rules"
rules_path="-" # no $rules found
if [ -e ./$rules ] # check if $rules is in ./
then
rules_path="./"
fi
if [ ${rules_path} = "-" ]
then
echo "Error, File ${rules} not found, no entry in /etc/udev/rules.d/ !"
else # now we know the relative path to the $rules file and check for same
rdiffs=1
if [ -e /etc/udev/rules.d/${rules} ]
then # there is a file with same name in /etc/udev/rules.d/
diff ${rules_path}${rules} /etc/udev/rules.d/${rules} > /dev/null
rdiffs=$?
fi
if [ ${rdiffs} -ne 0 ]
then # copy is required, files are not the same
sudo cp ${rules_path}${rules} /etc/udev/rules.d/${rules}
if [ $? -eq 0 ]
then
sudo udevadm control --reload-rules
if [ $? -eq 0 ]
then
echo "New ${rules} file in /etc/udev/rules.d/ is activated now!"
else
echo "Could not activate the new ${rules} file in /etc/udev/rules.d, please reboot you system!"
fi
else
echo "Error, File ${rules} is not copied to /etc/udev/ruled.d/ !"
fi
else
echo "Identical file ${rules} already is at /etc/udev/rules.d/ , no action required."
fi
fi
groups | grep -e plugdev > /dev/null
plug_mem=$?
groups | grep -e dialout > /dev/null
dial_mem=$?
if [ ${plug_mem} -eq 0 ] && [ ${dial_mem} -eq 0 ]
then
echo "User ${USER} is already member of the groups 'dialout' and 'plugdev', no action required."
else # you are not member of both groups, dialout and plugdev !
# make shure, that the groups plugdev and dialout exist
sudo groupadd -f plugdev
sudo groupadd -f dialout
# add this user to the groups plugdev and dialout
sudo usermod -a -G dialout,plugdev ${USER}
if [ $? -eq 0 ]
then
echo "The user ${USER} is added to the groups 'dialout' and 'plugdev'!"
else
echo "Error, could not add user ${USER} to the groups 'dialout' and 'plugdev', please try it otherwise!"
fi
fi
# Finally we list the USB-serial devices of your system with registered identification
echo " "
echo "List of USB-serial devices at your system:"
ls -l /dev/serial/by-id/* | cut -c41-