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..."
|
||||
rm -vf /etc/ssh/ssh_host_*
|
||||
cat /dev/null > /etc/rc.local
|
||||
cat << EOF >> /etc/rc.local
|
||||
cat << 'EOL' | sudo tee /etc/rc.local
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# In order to enable or disable this script just change the execution
|
||||
# bits.
|
||||
#
|
||||
# By default this script does nothing.
|
||||
|
||||
rm -vf /root/vm-dehydrate > /dev/null
|
||||
|
||||
dpkg-reconfigure openssh-server > /dev/null
|
||||
|
||||
# dynamically create hostname (optional)
|
||||
if hostname | grep localhost; then
|
||||
hostnamectl set-hostname "$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')"
|
||||
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
|
||||
EOF
|
||||
EOL
|
||||
|
||||
echo "Cleaning up /var/mail..."
|
||||
rm -vf /var/mail/*
|
||||
@@ -61,6 +65,7 @@ find /var/log -type f -exec truncate -s0 \{\} \;
|
||||
echo "Compacting drive..."
|
||||
dd if=/dev/zero of=EMPTY bs=1M > /dev/null
|
||||
rm -vf /root/EMPTY
|
||||
fstrim -av
|
||||
|
||||
echo "Clearing bash history..."
|
||||
cat /dev/null > /root/.bash_history
|
||||
|
||||
Reference in New Issue
Block a user