From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Buesch Date: Sun, 23 Jan 2005 11:01:34 +0000 Subject: [udev] Script to convert old permissions files Message-Id: <200501231201.39305.mbuesch@freenet.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="nextPart1459148.Syn6Vf3kOW" List-Id: To: linux-hotplug@vger.kernel.org --nextPart1459148.Syn6Vf3kOW Content-Type: multipart/mixed; boundary="Boundary-01=_OQ48BrBJuP/5uR/" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_OQ48BrBJuP/5uR/ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I wrote a small script to convert my old /etc/udev/permissions.d files to the new /etc/udev/rules.d format. I did many improvements, suggested by Kay, so I hope it will work in any situation, now. Do anything what you want with it. Please CC: me, if you want to reply to this mail, as I'm not subscribed to linux-hotplug-devel. Thanks. =2D-=20 Regards Michael Buesch [ http://www.tuxsoft.de.vu ] --Boundary-01=_OQ48BrBJuP/5uR/ Content-Type: application/x-shellscript; name="udevpermconv.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="udevpermconv.sh" #!/bin/bash # # convert old udev permissions.d file to the new rules.d format. # revision 2 # # Written by Michael Buesch # This is released into the Public Domain. # perm_file="$1" function processLine { local line="$1" if [ -z "$line" ]; then echo return 1 fi if [ "`echo $line | cut -b1`" = "#" ]; then # comment echo "$line" return 2 fi local i= local kern_name= local owner= local group= local mode= for ((i = 1; i <= 4; i++)); do local tmp="`echo $line | cut -d: -f $i`" if [ $i -eq 1 ]; then kern_name="$tmp" elif [ $i -eq 2 ]; then owner="$tmp" elif [ $i -eq 3 ]; then group="$tmp" elif [ $i -eq 4 ]; then mode="$tmp" fi done if [ -z "$kern_name" ]; then echo "Malformed line: \"$line\"" >&2 return 3 fi local need_rule="no" local out="KERNEL=\"$kern_name\"" local kern_name_len="`echo $kern_name | wc -c`" kern_name_len="`expr $kern_name_len + 9`" local num_tabs="`expr 32 - $kern_name_len`" num_tabs="`expr $num_tabs / 8`" while [ $num_tabs -gt 0 ]; do out="${out}\t" num_tabs="`expr $num_tabs - 1`" done if [ -n "$owner" ] && [ "$owner" != "root" ]; then out="${out}, OWNER=\"$owner\"" need_rule="yes" fi if [ -n "$group" ] && [ "$group" != "root" ]; then out="${out}, GROUP=\"$group\"" need_rule="yes" fi if [ -n "$mode" ] && [ "$mode" != "0600" ] && [ "$mode" != "600" ]; then out="${out}, MODE=\"$mode\"" need_rule="yes" fi if [ "$need_rule" = "no" ]; then echo "Do not need a rule for: \"$line\" (It's udev default permissions)" >&2 return 4 fi echo -e "$out" return 0 } function processInput { echo "Converting udev permissions file. This can take a while..." >&2 cat $perm_file | \ while read line; do processLine "$line" done echo "done." >&2 } if ! [ -r "$perm_file" ]; then echo "Could not read input file" >&2 echo "Usage: $0 old_permission_file > new_rules_file" >&2 exit 1 fi processInput exit 0 --Boundary-01=_OQ48BrBJuP/5uR/-- --nextPart1459148.Syn6Vf3kOW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBB84QTFGK1OIvVOP4RAk1iAKDI00y6jSrvRIEGQ4abnke5KVfvaACgwAKj 8kB+WC8hOhNLErla1AeDs6E= =uw8C -----END PGP SIGNATURE----- --nextPart1459148.Syn6Vf3kOW-- ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel