#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

PRIMARY_INTERFACE=$(ip route show default scope global | awk 'NR==1 {print $5}')
IP_ADDRESS=$(ip -o -4 a show $PRIMARY_INTERFACE | awk 'BEGIN {FS = "[ /]+"} ; {print $4}')

if [ ! -f /var/local/password ]
then

  # Generate password in format WORD.Number.WORD
  echo $(shuf -n 1 /var/local/places.txt).$(echo $RANDOM | cut -c-2).$(shuf -n 1 /var/local/places.txt) > /var/local/password
  echo "root:$(cat /var/local/password)" | chpasswd
fi

PASSWORD=$(cat /var/local/password)


echo \
"                --- Welcome to the PuppetLabs <%= @hostname.capitalize -%> VM ---

<%= @login_message %>


For the best experience please log in via SSH

    IP: $IP_ADDRESS
    username: root
    password: $PASSWORD

Your password was randomly generated from international place names
It is stored in /var/local/password and will continue to appear on this screen

To reset password, run the command: reset_password.rb
" > /etc/issue

# Disable the floppy driver
rmmod floppy

/root/.ssh_keygen.sh &

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

PRIMARY_INTERFACE=$(ip route show default scope global | awk 'NR==1 {print $5}')
IP_ADDRESS=$(ip -o -4 a show $PRIMARY_INTERFACE | awk 'BEGIN {FS = "[ /]+"} ; {print $4}')

if [ ! -s /var/local/password ]
then

  # Generate password in format WORD.Number.WORD
  echo $(shuf -n 1 /var/local/places.txt).$(echo $RANDOM | cut -c-2).$(shuf -n 1 /var/local/places.txt) > /var/local/password
  echo "root:$(cat /var/local/password)" | chpasswd
fi

PASSWORD=$(cat /var/local/password)


echo \
"                --- Welcome to the PuppetLabs <%= @hostname.capitalize -%> VM ---

<%= @login_message %>


For the best experience please log in via SSH

    IP: $IP_ADDRESS
    username: root
    password: $PASSWORD

Your password was randomly generated from international place names
It is stored in /var/local/password and will continue to appear on this screen

To reset password, run the command: reset_password.rb
" > /etc/issue

# Disable the floppy driver
rmmod floppy

/root/.ssh_keygen.sh &

Check if password files is empty
Check if password files is empty
