I've put this script in /etc/init.d, when some user changes password, this script updates it on another file data.txt, It is working fine, but when i shut down my computer it was not doing so showing ubutnu screen at shutting down, n when i shut down it manually it automatically restarts itself,
By removing this script and commenting outer while loop, computer can easily be shut down.
Here is my code
while inotifywait -e attrib /etc/shadow; do
#edit user
while IFS=: read -r f1 f2
do
user=$(sudo grep "$f1" /etc/shadow | cut -d':' -f 1);
pwd=$(sudo grep "$f1" /etc/shadow | cut -d':' -f 2);
if [ "$f2" != "$pwd" ]; then
#echo "changed";
#search for password, and repalce it with new one
sed -i 's@'$f2'@'$pwd'@' $file;
#upload file data.txt to server
fi
done < $file
#end edit user
done
Please tell me what I'm doing wrong?