Changeset 810
- Timestamp:
- 07/19/10 18:36:52 (22 months ago)
- Location:
- main/linuxmuster-base/tags/1.5.3.3
- Files:
-
- 1 added
- 3 edited
-
debian/changelog (modified) (1 diff)
-
share/scripts/helperfunctions.sh (modified) (2 diffs, 1 prop)
-
share/scripts/update-logins.sh (added)
-
share/scripts/wimport.sh (modified) (11 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
main/linuxmuster-base/tags/1.5.3.3/debian/changelog
r809 r810 1 linuxmuster-base (1.5.3.3-etch7) etch; urgency=low 2 3 * added bash script "update-logins.sh" to be able to update the cached logins 4 in /var/cache/linuxmuster/logins (#202). 5 * wimport.sh: 6 - remove_account(): added check for computer account so that user accounts 7 identical to the hostname were not removed (finally closes #137). 8 - improved workstations data checks (closes #269). 9 * helperfunctions.sh, check_string(): fixed unescaped underscore. 10 11 -- Thomas Schmitt <schmitt@lmz-bw.de> Mon, 19 Jul 2010 18:31:17 +0200 12 1 13 linuxmuster-base (1.5.3.3-etch6) etch; urgency=low 2 14 -
main/linuxmuster-base/tags/1.5.3.3/share/scripts/helperfunctions.sh
- Property svn:keywords changed from Id Rev to Id
r778 r810 5 5 # GPL v3 6 6 # 7 # 06.07.20107 # $Id$ 8 8 # 9 9 … … 874 874 # check valid string without special characters 875 875 check_string() { 876 if (expr match "$1" '\([a-zA-Z0-9 _\-]\+$\)') &> /dev/null; then876 if (expr match "$1" '\([a-zA-Z0-9\_\-]\+$\)') &> /dev/null; then 877 877 return 0 878 878 else -
main/linuxmuster-base/tags/1.5.3.3/share/scripts/wimport.sh
- Property svn:keywords changed from Id Rev to Id
r761 r810 2 2 # 3 3 # Thomas Schmitt <schmitt@lmz-bw.de> 4 # 19.11.20084 # $Id$ 5 5 # 6 # GPL v 26 # GPL v3 7 7 # 8 8 … … 68 68 # check if hostname exists already as a user account 69 69 if echo "$ACCOUNTS_LDAP" | grep -qw "$hostname"; then 70 echo " *ERROR: $hostname is already a ldap user account! Skipping!"70 echo " > ERROR: $hostname is already a ldap user account! Skipping!" 71 71 echo 72 72 return 1 73 73 fi 74 74 if echo "$ACCOUNTS_DB" | grep -qw "$hostname"; then 75 echo " *ERROR: $hostname is already a postgresql user account! Skipping!"75 echo " > ERROR: $hostname is already a postgresql user account! Skipping!" 76 76 echo 77 77 return 1 78 78 fi 79 79 if grep -q ^"${hostname}"\: /etc/passwd; then 80 echo " *ERROR: $hostname is already a system account! Skipping!"80 echo " > ERROR: $hostname is already a system account! Skipping!" 81 81 echo 82 82 return 1 83 83 fi 84 84 if [ -e "$SOPHOMORIXLOCK" ]; then 85 echo " Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!"85 echo " > Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 86 86 return 1 87 87 fi … … 94 94 fi 95 95 if ! sophomorix-passwd -u $hostname --pass $HOST_PASSWORD 2>> $TMPLOG 1>> $TMPLOG; then 96 echo " *Error: Cannot set password for $hostname!"96 echo " > Error: Cannot set password for $hostname!" 97 97 return 1 98 98 fi … … 120 120 # remove workstation and machine accounts 121 121 remove_account() { 122 if ! check_account $hostname; then 123 echo " > Fatal! $hostname is no computer account! Not removing!" 124 return 1 125 fi 122 126 if [ -e "$SOPHOMORIXLOCK" ]; then 123 echo " Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!"127 echo " > Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 124 128 return 1 125 129 fi … … 209 213 210 214 211 # Check if workstation data file is empty 215 # filter out bad workstation data 216 touch $WDATATMP 212 217 if [ -s "$WIMPORTDATA" ]; then 213 218 214 219 # create a clean workstation data file 220 RC_LINE=0 215 221 echo "Checking workstation data:" 216 222 while read line; do 217 223 224 # skip comment lines 218 225 [ "${line:0:1}" = "#" ] && continue 219 226 220 # strip spaces from $line227 # strip spaces and skip empty lines 221 228 line=${line// /} 229 [ -z "$line" ] && continue 222 230 223 231 room=`echo $line | awk -F\; '{ print $1 }'` 224 [ -z "$room" ] && continue 232 if ! validname "$room"; then 233 [ -z "$room" ] && room="<empty>" 234 echo " > $room is no valid room name! Skipping." 235 RC_LINE=1 236 continue 237 fi 225 238 226 239 hostname=`echo $line | awk -F\; '{ print $2 }'` 227 240 tolower $hostname 228 241 hostname=$RET 229 [ -z "$hostname" ] && continue 242 if ! validhostname "$hostname"; then 243 [ -z "$hostname" ] && hostname="<empty>" 244 echo " > $hostname is no valid hostname! Skipping." 245 RC_LINE=1 246 continue 247 fi 230 248 231 249 hostgroup=`echo $line | awk -F\; '{ print $3 }'` 232 [ -z "$hostgroup" ] && continue 250 if ! validname "$hostgroup"; then 251 [ -z "$hostgroup" ] && hostgroup="<empty>" 252 echo " > $hostgroup is no valid group name! Skipping $hostname." 253 RC_LINE=1 254 continue 255 fi 233 256 234 257 mac=`echo $line | awk -F\; '{ print $4 }'` 235 258 toupper $mac 236 259 mac=$RET 237 [ -z "$mac" ] && continue 260 if ! validmac "$mac"; then 261 [ -z "$mac" ] && mac="<empty>" 262 echo " > $mac is no valid mac address! Skipping $hostname." 263 RC_LINE=1 264 continue 265 fi 238 266 239 267 ip=`echo $line | awk -F\; '{ print $5 }'` 240 [ -z "$ip" ] && continue 268 if ! validip "$ip"; then 269 [ -z "$ip" ] && ip="<empty>" 270 echo " > $ip is no valid ip address! Skipping $hostname." 271 RC_LINE=1 272 continue 273 fi 241 274 242 275 pxe=`echo $line | awk -F\; '{ print $11 }'` 243 [ -z "$pxe" ] && continue 276 if [ -z "$pxe" ]; then 277 echo " > PXE-Flag is not set! Skipping $hostname." 278 RC_LINE=1 279 continue 280 fi 244 281 245 282 echo "$room;$hostname;$hostgroup;$mac;$ip;$internmask;1;1;1;1;$pxe" >> $WDATATMP 246 283 247 284 done <$WIMPORTDATA 285 286 fi 287 288 # check for repeated hostnames, macs and ips 289 if [ -s "$WDATATMP" ]; then 248 290 249 291 # check hostnames 250 292 hostnames=`awk -F\; '{ print $2 }' $WDATATMP` 251 293 for i in $hostnames; do 252 validhostname "$i" || exitmsg "Hostname $i does not comply with RFC 952!"253 294 check_unique "$i" "$hostnames" || exitmsg "Hostname $i is not unique!" 254 295 done … … 257 298 macs=`awk -F\; '{ print $4 }' $WDATATMP` 258 299 for i in $macs; do 259 validmac $i || exitmsg "Invalid MAC address: $i!"260 300 check_unique "$i" "$macs" || exitmsg "MAC address $i is not unique!" 261 301 done … … 264 304 ips=`awk -F\; '{ print $5 }' $WDATATMP` 265 305 for i in $ips; do 266 validip $i || exitmsg "Invalid IP address: $i!"267 306 check_unique "$i" "$ips" || exitmsg "IP address $i is not unique!" 268 307 done 269 308 270 echo " * Workstation data are Ok! :-)" 271 272 else 273 274 touch $WDATATMP 275 echo " * No workstation data found! Skipping workstation import!" 276 277 fi 309 fi 310 311 # evaluate workstation data checks 312 [ "$RC_LINE" = "0" -a -s "$WDATATMP" ] && echo " * Workstation data are Ok! :-)" 313 if [ "$RC_LINE" != "0" ]; then 314 RC=1 315 echo " > Workstation data with errors! :-(" 316 fi 317 [ -s "$WDATATMP" ] || echo " * No valid workstation data found! Skipping workstation import!" 318 278 319 echo 279 320 … … 291 332 292 333 # Check if workstation data file is empty 293 if [ -s "$W IMPORTDATA" ]; then334 if [ -s "$WDATATMP" ]; then 294 335 295 336 # write configuration files and create host accounts … … 331 372 else 332 373 if ! sophomorix-passwd --force -u ${hostname}$ --pass $MACHINE_PASSWORD 2>> $TMPLOG 1>> $TMPLOG; then 333 echo " *Error: Cannot set machine password for ${hostname}$!"374 echo " > Error: Cannot set machine password for ${hostname}$!" 334 375 RC=1 335 376 continue … … 448 489 449 490 hostname=${i##*/} 450 if ! grep -qw $hostname $WDATATMP; then491 if ! awk -F\; '{ print "X"$2"X" }' $WDATATMP | grep -q X${hostname}X; then 451 492 FOUND=1 452 493 remove_account ; RC_LINE="$?" 453 494 [ $RC_LINE -eq 0 ] || RC=1 454 if [ -z "$HOSTS_REMOVED" ]; then455 HOSTS_REMOVED=$hostname456 else457 HOSTS_REMOVED="$HOSTS_REMOVED $hostname"458 fi459 460 495 if grep -v ^# $PRINTERS | grep -qw $hostname; then 461 496 remove_printeraccess $hostname ; RC_LINE="$?" … … 480 515 for room in $rooms; do 481 516 482 if ! grep -qw $room $WDATATMP; then517 if ! awk -F\; '{ print "X"$1"X" }' $WDATATMP | grep -q X${room}X; then 483 518 FOUND=1 484 519 echo -n " * Removing room: $room ... "
Note: See TracChangeset
for help on using the changeset viewer.
