( Panther | 2009. 12. 06., v – 13:25 )

Kicsit hatékonyabban:


#!/bin/bash

ADOTTUSER=bela

if ! grep -q "^$ADOTTUSER:" /etc/passwd; then echo 'error: no '$ADOTTUSER' user found in "/etc/passwd"'; exit 1; fi

SFTPUSER_MAPPAJA=$(grep "^$ADOTTUSER:" /etc/passwd | cut -f6 -d: | sed 's#/$##')

if [[ -z "$SFTPUSER_MAPPAJA"  || "$SFTPUSER_MAPPAJA = / ]]; then echo "error: bad home directory"; exit 1;
elif [[ !-d "$SFTPUSER_MAPPAJA" ]]; then echo "error: no home directory for the user"; exit 1; fi