blob: 1ef417fcbca34ea6b8d25fd7c10168fa4d2af674 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/bin/bash
# Luke's all singing, all dancing, Gentoo Portage @world update script
# ====== EDIT VARIABLES BELOW HERE ======
# Portage temporary directory to be passed to "rm -r", if you would like it cleared afterwards (e.g. "/tmp/portage/*")
PORTAGE_TEMP="/var/tmp/portage/*"
# Services that are safe to restart if they have deleted files open (e.g. "apache2 sshd vixie-cron")
SAFE_SERVICES="cupsd lvmetad ntpd smartd sshd tor syslog-ng vixie-cron webmin"
# ====== EDIT VARIABLES ABOVE HERE ======
# Handle arguments
while test $# -gt 0
do
case "$1" in
--skip-update) export SKIP_UPDATE="true" # In case we don't want to do the actual "emerge --update"
;;
--skip-depclean) export SKIP_DEPCLEAN="true" # In case we don't want to do an "emerge --depclean"
;;
--skip-preserved-rebuild) export SKIP_PRESERVED_REBUILD="true" # In case we don't want to do an "emerge @preserved-rebuild"
;;
--*) echo "bad argument '$1'" ; exit 1
;;
*) echo "unexpected argument '$1'" ; exit 1
;;
esac
shift
done
# Sync the Portage tree
echo 'emerge --sync'
emerge --sync || exit 1
# Do a @world update, unless skipped
if [ -z ${SKIP_UPDATE+x} ]; then
echo 'emerge --keep-going -av --update --newuse --deep --with-bdeps=y @world'
emerge --keep-going -av --update --newuse --deep --with-bdeps=y @world || exit 1
fi
# Remove unnecessary dependencies, unless skipped
if [ -z ${SKIP_DEPCLEAN+x} ]; then
echo 'emerge -av --depclean'
emerge -av --depclean || exit 1
fi
# Rebuild any packages known to be built against old/missing packages, unless skipped
if [ -z ${SKIP_PRESERVED_REBUILD+x} ]; then
echo 'emerge -av --keep-going @preserved-rebuild'
emerge -av --keep-going @preserved-rebuild || exit 1
fi
# Search for any remaining packages built against old/missing packages
echo 'revdep-rebuild -p'
revdep-rebuild -- -av || exit 1
# Restart any defined safe-to-restart services that have open but deleted files
DELETED=$(lsof -n | grep "DEL\|deleted")
for service in ${SAFE_SERVICES[@]}; do
echo "$DELETED" | grep -Eq "^$service\s+[0-9]"
if [ "$?" -eq 0 ]; then
echo "/etc/init.d/$service restart"
/etc/init.d/"$service" restart || exit 1
fi
done
# Print any remaining processes that have open but deleted files
echo 'lsof -n | grep "DEL\|deleted" | less'
echo "$(echo -e 'These things might need manually restarting afterwards due to having open files:\n' && lsof -n | grep DEL)" | less || exit 1
# Clean up /etc/portage/package.*
echo 'portpeek -arq'
portpeek -arq || exit 1
# Remove distfiles not owned by any installed package
echo 'eclean-dist --destructive'
eclean-dist --destructive || exit 1
# Clear Portage's temporary directory, as defined above
echo 'rm -r '"$PORTAGE_TEMP"
#rm -r "$PORTAGE_TEMP" || exit 1
echo "Would do rm -r $PORTAGE_TEMP here, do not have the balls yet due to rm -ring a variable" || exit 1
# Print disk space
echo 'df -H'
df -H || exit 1
# Print an SSH warning
echo -e '\nAll done! If sshd was restarted, now would be a good time to verify you can SSH in to this machine...'
|