Blob Blame History Raw
#!/bin/bash
# Author: Iain Douglas <centos@1n6.org.uk>

echo "Running $0"
echo "*****************************************************************"
echo "Note: The original /etc/passwd and /etc/shadow files are saved to"
echo "directory /var/tmp/pwunconv".
echo "*****************************************************************"

cleanup(){
echo "Reverting files to original state"
[[ -d /var/tmp/pwunconv ]] && cp /var/tmp/pwunconv/* /etc 
t_CheckExitStatus $?
}

# check that /etc/passwd and /etc/shadow exist before continuing.
[[ -e /etc/passwd && -e /etc/shadow ]] || { t_Log "FAIL: missing source file"; exit $FAIL; }

mkdir -p /var/tmp/pwunconv || { t_Log "FAIL: Unable to create directory to save  source files in "; exit $FAIL; }
cp /etc/passwd /etc/shadow /var/tmp/pwunconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; }
trap cleanup EXIT
echo "Running pwunconv"
pwunconv
t_CheckExitStatus $?