# install the aoe-specific udev rules from udev.txt into # the system's udev configuration # global me := $[basename $0] # find udev.conf, often /etc/udev/udev.conf # (or environment can specify where to find udev.conf) # if test -z $conf { if test -r /etc/udev/udev.conf { global conf := '/etc/udev/udev.conf' } else { global conf := $[find /etc -type f -name udev.conf !2 > /dev/null] if test -z $conf || test ! -r $conf { echo "$me Error: no udev.conf found" !1 > !2 exit 1 } } } # find the directory where udev rules are stored, often # /etc/udev/rules.d # global rules_d := $[sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf] if test -z $rules_d { global rules_d := '/etc/udev/rules.d' } if test ! -d $rules_d { echo "$me Error: cannot find udev rules directory" !1 > !2 exit 1 } sh -xc "cp $[dirname $0]/udev.txt $rules_d/60-aoe.rules" (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:me) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(basename)} {($ VSub_Number "$0")})]) left_token: spids: [12 16] ) ) } spids: [10] ) ] spids: [10] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-z)} {(DQ ($ VSub_Name "$conf"))}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-r)} {(/etc/udev/udev.conf)}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:conf) op: Equal rhs: {(/etc/udev/udev.conf)} spids: [55] ) ] spids: [55] ) ] spids: [-1 52] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:conf) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(find)} {(/etc)} {(-type)} {(f)} {(-name)} {(udev.conf)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [77] ) ] ) ] ) left_token: spids: [64 80] ) ) } spids: [62] ) ] spids: [62] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(test)} {(-z)} {(DQ ($ VSub_Name "$conf"))}) (C {(test)} {(KW_Bang "!")} {(-r)} {(DQ ($ VSub_Name "$conf"))}) ] op_id: Op_DPipe ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$me") (" Error: no udev.conf found"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:1 arg_word:{(2)} spids:[117])] ) (C {(exit)} {(1)}) ] spids: [-1 107] ) ] spids: [-1 126] ) ] spids: [59 129] ) ] spids: [-1 40] ) ] spids: [-1 131] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rules_d) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(sed)} {(-n)} {(SQ <"/^udev_rules=/{ s!udev_rules=!!; s!\\\"!!g; p; }">)} {($ VSub_Name "$conf")} ) ] ) left_token: spids: [145 155] ) ) } spids: [143] ) ] spids: [143] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-z)} {(DQ ($ VSub_Name "$rules_d"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rules_d) op: Equal rhs: {(/etc/udev/rules.d)} spids: [173] ) ] spids: [173] ) ] spids: [-1 170] ) ] spids: [-1 176] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-d)} {(DQ ($ VSub_Name "$rules_d"))}) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$me") (" Error: cannot find udev rules directory"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:1 arg_word:{(2)} spids:[201])] ) (C {(exit)} {(1)}) ] spids: [-1 191] ) ] spids: [-1 209] ) (C {(sh)} {(-xc)} { (DQ ("cp ") (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [217 221] ) ("/udev.txt ") ($ VSub_Name "$rules_d") (/60-aoe.rules) ) } ) ] )