Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
02040d8c
Commit
02040d8c
authored
Feb 19, 2022
by
Antoine Kaufmann
Browse files
images: simplify cleanup script
parent
7caee4b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
25 deletions
+3
-25
images/scripts/cleanup.sh
images/scripts/cleanup.sh
+3
-25
No files found.
images/scripts/cleanup.sh
View file @
02040d8c
#!/bin/bash -eux
#!/bin/bash -eux
# Make sure udev does not block our network - http://6.ptmc.org/?p=164
# Cleaning up leftover dhcp leases
echo
"==> Cleaning up udev rules"
rm
-f
/var/lib/dhcp3/
*
/var/lib/dhcp/
*
rm
-rf
/dev/.udev/
rm
/lib/udev/rules.d/75-persistent-net-generator.rules
echo
"==> Cleaning up leftover dhcp leases"
# Ubuntu 10.04
if
[
-d
"/var/lib/dhcp3"
]
;
then
rm
/var/lib/dhcp3/
*
fi
# Ubuntu 12.04 & 14.04
if
[
-d
"/var/lib/dhcp"
]
;
then
rm
/var/lib/dhcp/
*
fi
# Add delay to prevent "vagrant reload" from failing
echo
"pre-up sleep 2"
>>
/etc/network/interfaces
echo
"==> Cleaning up tmp"
rm
-rf
/tmp/
*
rm
-rf
/tmp/
*
# Cleanup apt cache
# Cleanup apt cache
...
@@ -26,12 +10,6 @@ apt-get -y autoremove --purge
...
@@ -26,12 +10,6 @@ apt-get -y autoremove --purge
apt-get
-y
clean
apt-get
-y
clean
apt-get
-y
autoclean
apt-get
-y
autoclean
echo
"==> Installed packages"
dpkg
--get-selections
|
grep
-v
deinstall
DISK_USAGE_BEFORE_CLEANUP
=
$(
df
-h
)
# Remove Bash history
unset
HISTFILE
unset
HISTFILE
rm
-f
/root/.bash_history
rm
-f
/root/.bash_history
rm
-f
/home/ubuntu/.bash_history
rm
-f
/home/ubuntu/.bash_history
...
@@ -39,7 +17,7 @@ rm -f /home/ubuntu/.bash_history
...
@@ -39,7 +17,7 @@ rm -f /home/ubuntu/.bash_history
# Clean up log files
# Clean up log files
find /var/log
-type
f |
while
read
f
;
do
echo
-ne
''
>
"
${
f
}
"
;
done
;
find /var/log
-type
f |
while
read
f
;
do
echo
-ne
''
>
"
${
f
}
"
;
done
;
echo
"==>
Clearing last login information
"
#
Clearing last login information
>
/var/log/lastlog
>
/var/log/lastlog
>
/var/log/wtmp
>
/var/log/wtmp
>
/var/log/btmp
>
/var/log/btmp
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment