Random initial image password

This commit is contained in:
Bob Mottram 2015-11-23 15:04:05 +00:00
parent a4aca5ddbc
commit 2294979689
1 changed files with 15 additions and 7 deletions

View File

@ -186,16 +186,16 @@ admin_user_sudo() {
create_generic_image() { create_generic_image() {
if [[ $GENERIC_IMAGE == "no" ]]; then if [[ $GENERIC_IMAGE == "no" ]]; then
return return
fi fi
# Don't install any configuration. This will be a base system # Don't install any configuration. This will be a base system
CONFIG_FILENAME= CONFIG_FILENAME=
# The presence of this file indicates that the initial # The presence of this file indicates that the initial
# setup has not yet been completed # setup has not yet been completed
touch $rootdir/home/$MY_USERNAME/.initial_setup touch $rootdir/home/$MY_USERNAME/.initial_setup
touch $rootdir/home/root/.bashrc touch $rootdir/home/root/.bashrc
cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
# initial setup of the system # initial setup of the system
if [ -f ~/.initial_setup ]; then if [ -f ~/.initial_setup ]; then
clear clear
@ -213,7 +213,7 @@ if [ -f ~/.initial_setup ]; then
echo '' echo ''
NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)" NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
echo "${USER}:${NEW_USER_PASSWORD}"|chpasswd echo "${NEW_USER_PASSWORD}" > ~/login.txt
echo " $NEW_USER_PASSWORD" echo " $NEW_USER_PASSWORD"
echo '' echo ''
@ -226,11 +226,19 @@ if [ -f ~/.initial_setup ]; then
fi fi
EOF EOF
cat >> $rootdir/home/root/.bashrc <<EOF cat >> $rootdir/home/root/.bashrc <<EOF
# initial setup of the system # initial setup of the system
if [ -f ~/.initial_setup ]; then if [ -f ~/.initial_setup ]; then
EOF
echo -n " echo \"${MY_USERNAME}:" >> /home/root/.bashrc
echo -n '$(cat /home/' >> /home/root/.bashrc
echo "${MY_USERNAME}/login.txt)\"|chpasswd" >> /home/root/.bashrc
cat >> $rootdir/home/root/.bashrc <<EOF
freedombone menuconfig freedombone menuconfig
rm ~/.initial_setup rm ~/.initial_setup
EOF
echo " shred -zu /home/${MY_USERNAME}/login.txt" >> $rootdir/home/root/.bashrc
cat >> $rootdir/home/root/.bashrc <<EOF
fi fi
EOF EOF
} }