fai-config/scripts/DEBIAN/10-rootpw

19 lines
440 B
Bash
Executable File

#! /bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# set root password
if [ -n "$ROOTPW" ]; then
$ROOTCMD chpasswd --encrypted <<< "root:${ROOTPW}"
elif [ -n "$username" ]; then
$ROOTCMD usermod -L root
# enable sudo for user
ainsl /etc/sudoers "$username ALL = ALL"
if [ ! -f $target/usr/bin/sudo ]; then
echo "WARNING. Package sudo is not installed"
fi
fi
exit $error