remove match, add ipstart
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
		
					parent
					
						
							
								6959074b57
							
						
					
				
			
			
				commit
				
					
						43516af78a
					
				
			
		
					 2 changed files with 9 additions and 7 deletions
				
			
		
							
								
								
									
										0
									
								
								linux/archive-configs.sh
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								linux/archive-configs.sh
									
										
									
									
									
										
										
										Normal file → Executable file
									
								
							| 
						 | 
					@ -1,9 +1,13 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# Nico Schottelius
 | 
				
			||||||
 | 
					# Generate dhcpd.conf from CSV file
 | 
				
			||||||
 | 
					# Usage: mac-adresses-csv-to-dhcpd.sh a dryad 192.168.54. 0 2 ./08-12180\ MAC\ Adressen.csv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sep=';'
 | 
					sep=';'
 | 
				
			||||||
name='dryad'
 | 
					name='dryad'
 | 
				
			||||||
hostname="$1"; shift
 | 
					hostname="$1"; shift
 | 
				
			||||||
ipnbase="$1"; shift
 | 
					ipnbase="$1"; shift
 | 
				
			||||||
 | 
					ipstart="$1"; shift
 | 
				
			||||||
field="$1"; shift
 | 
					field="$1"; shift
 | 
				
			||||||
file="$1"; shift
 | 
					file="$1"; shift
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,13 +28,11 @@ awk "-F$sep" 'BEGIN {
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
   /^S-09/
 | 
					   /^S-09/ {
 | 
				
			||||||
   {
 | 
					 | 
				
			||||||
      mac = mac2dp($field);
 | 
					      mac = mac2dp($field);
 | 
				
			||||||
      print \
 | 
					      print "      host " hostname hc " {\n" \
 | 
				
			||||||
         "      host " hostname hc " {\n" \
 | 
					 | 
				
			||||||
         "         hardware ethernet " mac ";\n" \
 | 
					         "         hardware ethernet " mac ";\n" \
 | 
				
			||||||
         "         fixed-address " ipnbase hc ";\n" \
 | 
					         "         fixed-address " ipnbase (ipstart+hc) ";\n" \
 | 
				
			||||||
         "      }";
 | 
					         "      }\n";
 | 
				
			||||||
      hc++;
 | 
					      hc++;
 | 
				
			||||||
   }' ipnbase="$ipnbase" field="$field" hostname="$hostname" < "$file" 
 | 
					   }' ipnbase="$ipnbase" field="$field" ipstart="$ipstart" hostname="$hostname" < "$file" 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue