#!/bin/sh

set -e

case "$1" in
    configure)
        getent passwd |
        while IFS=: read username x uid gid gecos home shell
        do
                if [ "$uid" -lt 1000 ]; then
                        continue
                fi
                if [ ! -d "$home" -o "$username" = "root" -o "$username" = "nobody" -o "$username" = "oem" ]; then
                        continue
                fi
                for file in "Lenovo_Limited_Warranty.pdf" "Software_Product_License_Agreement.pdf" "Generic_Safety_and_Compliance_Notices.pdf"; do
                    if [ ! -L "$home/$file" ]; then
                        sudo -Hu "$username" cp -P /etc/skel/$file "$home"
                    fi
                done
                if [ -L "$home/Open_Source_Information.pdf"  ]; then
                    sudo -Hu "$username" rm -f "$home/Open_Source_Information.pdf"
                fi
        done
    ;;
esac

#DEBHELPER#

exit 0
