update to remove machine-id
This commit is contained in:
21
vm-dehydrate
21
vm-dehydrate
@@ -7,26 +7,30 @@
|
|||||||
echo "Removing openssh-server's host keys..."
|
echo "Removing openssh-server's host keys..."
|
||||||
rm -vf /etc/ssh/ssh_host_*
|
rm -vf /etc/ssh/ssh_host_*
|
||||||
cat /dev/null > /etc/rc.local
|
cat /dev/null > /etc/rc.local
|
||||||
cat << EOF >> /etc/rc.local
|
cat << 'EOL' | sudo tee /etc/rc.local
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
#
|
#
|
||||||
# rc.local
|
# rc.local
|
||||||
#
|
#
|
||||||
# This script is executed at the end of each multiuser runlevel.
|
# This script is executed at the end of each multiuser runlevel.
|
||||||
# Make sure that the script will "exit 0" on success or any other
|
# Make sure that the script will "" on success or any other
|
||||||
# value on error.
|
# value on error.
|
||||||
#
|
#
|
||||||
# In order to enable or disable this script just change the execution
|
# In order to enable or disable this script just change the execution
|
||||||
# bits.
|
# bits.
|
||||||
#
|
#
|
||||||
# By default this script does nothing.
|
# By default this script does nothing.
|
||||||
|
# dynamically create hostname (optional)
|
||||||
rm -vf /root/vm-dehydrate > /dev/null
|
if hostname | grep localhost; then
|
||||||
|
hostnamectl set-hostname "$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')"
|
||||||
dpkg-reconfigure openssh-server > /dev/null
|
fi
|
||||||
|
test -f /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
|
||||||
|
if [ ! -f /etc/machine-id ]
|
||||||
|
then
|
||||||
|
/usr/bin/systemd-machine-id-setup
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
EOF
|
EOL
|
||||||
|
|
||||||
echo "Cleaning up /var/mail..."
|
echo "Cleaning up /var/mail..."
|
||||||
rm -vf /var/mail/*
|
rm -vf /var/mail/*
|
||||||
@@ -61,6 +65,7 @@ find /var/log -type f -exec truncate -s0 \{\} \;
|
|||||||
echo "Compacting drive..."
|
echo "Compacting drive..."
|
||||||
dd if=/dev/zero of=EMPTY bs=1M > /dev/null
|
dd if=/dev/zero of=EMPTY bs=1M > /dev/null
|
||||||
rm -vf /root/EMPTY
|
rm -vf /root/EMPTY
|
||||||
|
fstrim -av
|
||||||
|
|
||||||
echo "Clearing bash history..."
|
echo "Clearing bash history..."
|
||||||
cat /dev/null > /root/.bash_history
|
cat /dev/null > /root/.bash_history
|
||||||
|
|||||||
Reference in New Issue
Block a user