Changeset 810


Ignore:
Timestamp:
07/19/10 18:36:52 (22 months ago)
Author:
tschmitt
Message:
  • Skript update-logins.sh hinzugefügt, aktualisiert die Logindaten unter /var/cache/linuxmuster/logins.
  • wimport.sh:
    • remove_account(): Computeraccount-Check ergänzt, damit keine gleichlautenden Useraccounts entfernt

werden (schließt #137).

  • verbesserte Workstationsdatenüberprüfung (schließt #269).
Location:
main/linuxmuster-base/tags/1.5.3.3
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/linuxmuster-base/tags/1.5.3.3/debian/changelog

    r809 r810  
     1linuxmuster-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 
    113linuxmuster-base (1.5.3.3-etch6) etch; urgency=low 
    214 
  • main/linuxmuster-base/tags/1.5.3.3/share/scripts/helperfunctions.sh

    • Property svn:keywords changed from Id Rev to Id
    r778 r810  
    55# GPL v3 
    66# 
    7 # 06.07.2010  
     7# $Id$ 
    88# 
    99 
     
    874874# check valid string without special characters 
    875875check_string() { 
    876   if (expr match "$1" '\([a-zA-Z0-9_\-]\+$\)') &> /dev/null; then 
     876  if (expr match "$1" '\([a-zA-Z0-9\_\-]\+$\)') &> /dev/null; then 
    877877    return 0 
    878878  else 
  • main/linuxmuster-base/tags/1.5.3.3/share/scripts/wimport.sh

    • Property svn:keywords changed from Id Rev to Id
    r761 r810  
    22# 
    33# Thomas Schmitt <schmitt@lmz-bw.de> 
    4 # 19.11.2008 
     4# $Id$ 
    55# 
    6 # GPL v2 
     6# GPL v3 
    77# 
    88 
     
    6868 # check if hostname exists already as a user account 
    6969 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!" 
    7171  echo 
    7272  return 1 
    7373 fi 
    7474 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!" 
    7676  echo 
    7777  return 1 
    7878 fi 
    7979 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!" 
    8181  echo 
    8282  return 1 
    8383 fi 
    8484 if [ -e "$SOPHOMORIXLOCK" ]; then 
    85   echo "Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 
     85  echo "  > Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 
    8686  return 1 
    8787 fi 
     
    9494 fi 
    9595 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!" 
    9797  return 1 
    9898 fi 
     
    120120# remove workstation and machine accounts 
    121121remove_account() { 
     122 if ! check_account $hostname; then 
     123  echo "  > Fatal! $hostname is no computer account! Not removing!" 
     124  return 1 
     125 fi 
    122126 if [ -e "$SOPHOMORIXLOCK" ]; then 
    123   echo "Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 
     127  echo "  > Fatal! Sophomorix lockfile $SOPHOMORIXLOCK detected!" 
    124128  return 1 
    125129 fi 
     
    209213 
    210214 
    211 # Check if workstation data file is empty 
     215# filter out bad workstation data 
     216touch $WDATATMP 
    212217if [ -s "$WIMPORTDATA" ]; then 
    213218 
    214219 # create a clean workstation data file 
     220 RC_LINE=0 
    215221 echo "Checking workstation data:" 
    216222 while read line; do 
    217223 
     224  # skip comment lines 
    218225  [ "${line:0:1}" = "#" ] && continue 
    219226 
    220   # strip spaces from $line 
     227  # strip spaces and skip empty lines 
    221228  line=${line// /} 
     229  [ -z "$line" ] && continue 
    222230 
    223231  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 
    225238 
    226239  hostname=`echo $line | awk -F\; '{ print $2 }'` 
    227240  tolower $hostname 
    228241  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 
    230248 
    231249  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 
    233256 
    234257  mac=`echo $line | awk -F\; '{ print $4 }'` 
    235258  toupper $mac 
    236259  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 
    238266 
    239267  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 
    241274 
    242275  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 
    244281 
    245282  echo "$room;$hostname;$hostgroup;$mac;$ip;$internmask;1;1;1;1;$pxe" >> $WDATATMP 
    246283 
    247284 done <$WIMPORTDATA 
     285 
     286fi 
     287 
     288# check for repeated hostnames, macs and ips 
     289if [ -s "$WDATATMP" ]; then 
    248290 
    249291 # check hostnames 
    250292 hostnames=`awk -F\; '{ print $2 }' $WDATATMP` 
    251293 for i in $hostnames; do 
    252   validhostname "$i" || exitmsg "Hostname $i does not comply with RFC 952!" 
    253294  check_unique "$i" "$hostnames" || exitmsg "Hostname $i is not unique!" 
    254295 done 
     
    257298 macs=`awk -F\; '{ print $4 }' $WDATATMP` 
    258299 for i in $macs; do 
    259   validmac $i || exitmsg "Invalid MAC address: $i!" 
    260300  check_unique "$i" "$macs" || exitmsg "MAC address $i is not unique!" 
    261301 done 
     
    264304 ips=`awk -F\; '{ print $5 }' $WDATATMP` 
    265305 for i in $ips; do 
    266   validip $i || exitmsg "Invalid IP address: $i!" 
    267306  check_unique "$i" "$ips" || exitmsg "IP address $i is not unique!" 
    268307 done 
    269308 
    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 
     309fi 
     310 
     311# evaluate workstation data checks 
     312[ "$RC_LINE" = "0" -a -s "$WDATATMP" ] && echo "  * Workstation data are Ok! :-)" 
     313if [ "$RC_LINE" != "0" ]; then 
     314 RC=1 
     315 echo "  > Workstation data with errors! :-(" 
     316fi 
     317[ -s "$WDATATMP" ] || echo "  * No valid workstation data found! Skipping workstation import!" 
     318 
    278319echo 
    279320 
     
    291332 
    292333# Check if workstation data file is empty 
    293 if [ -s "$WIMPORTDATA" ]; then 
     334if [ -s "$WDATATMP" ]; then 
    294335 
    295336 # write configuration files and create host accounts 
     
    331372  else 
    332373   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}$!" 
    334375    RC=1 
    335376    continue 
     
    448489 
    449490  hostname=${i##*/} 
    450   if ! grep -qw $hostname $WDATATMP; then 
     491  if ! awk -F\; '{ print "X"$2"X" }' $WDATATMP | grep -q X${hostname}X; then 
    451492   FOUND=1 
    452493   remove_account ; RC_LINE="$?" 
    453494   [ $RC_LINE -eq 0 ] || RC=1 
    454    if [ -z "$HOSTS_REMOVED" ]; then 
    455     HOSTS_REMOVED=$hostname 
    456    else 
    457     HOSTS_REMOVED="$HOSTS_REMOVED $hostname" 
    458    fi 
    459  
    460495   if grep -v ^# $PRINTERS | grep -qw $hostname; then 
    461496    remove_printeraccess $hostname ; RC_LINE="$?" 
     
    480515for room in $rooms; do 
    481516 
    482  if ! grep -qw $room $WDATATMP; then 
     517 if ! awk -F\; '{ print "X"$1"X" }' $WDATATMP | grep -q X${room}X; then 
    483518  FOUND=1 
    484519  echo -n "  * Removing room: $room ... " 
Note: See TracChangeset for help on using the changeset viewer.