forked from Monty/GemStone_daemontools_setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy_system
94 lines (78 loc) · 2.17 KB
/
destroy_system
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
94
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "You must be root to run this"
exit
fi
echo "DANGER: This script *destroys* things, do NOT run it unless you know what you are doing."
echo "It's used to clean up unnecessary space in the GLASS Appliance before cloning it."
echo "IT MAY BREAK YOUR SYSTEM!"
echo "Continue anyway? (Y/N)"
read cont
case "$cont" in
y|Y|yes)
;;
*)
echo "Not continuing"
exit
;;
esac
# Make sure nothing is running related to GemStone
/etc/init.d/topaz stop 1 > /dev/null
/etc/init.d/statmon stop 1 > /dev/null
/etc/init.d/gemstone stop 1 > /dev/null
/etc/init.d/netldi stop 1 > /dev/null
# Reset /etc/issue to remove IP address
/etc/init.d/glass_ip_address stop
# Clear /etc/udev/rules.d/70-persistent-net.rules
cat > /etc/udev/rules.d/70-persistent-net.rules <<-EOF
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
EOF
# Quit logging
/etc/init.d/rsyslog stop
cd /
rm -f /home/glass/.bash_history
rm -rf /home/glass/.cache/*
rm -f /home/glass/.lesshist
rm -f /home/glass/.sudo_as_admin_successful
rm -f /home/glass/.viminfo
rm -f /home/glass/.vsd*
rm -f /home/glass/.Xauthority
rm -rf /home/glass/stats
rm -rf /home/glass/*log # You may have gemnetobject logs
if [[ ! -z "$GEMSTONE_LOGDIR" ]]; then
rm -f $GEMSTONE_LOGDIR/*
rm -f $GEMSTONE_LOGDIR/../locks/*
else
echo "WARNING: GEMSTONE_LOGDIR not defined."
fi
#
if [[ ! -z "$GEMSTONE_DATADIR" ]]; then
rm -f $GEMSTONE_DATADIR/tranlog*
rm -f $GEMSTONE_DATADIR/*pid
else
echo "WARNING: GEMSTONE_DATADIR not defined."
fi
# Get rid of any cached packages
apt-get clean
echo "DANGER: getting ready to remove /root and all /var/log logfiles."
echo "Continue anyway? (Y/N)"
read cont
case "$cont" in
y|Y|yes)
;;
*)
echo "Not continuing"
exit
;;
esac
# Now get really down and dirty
rm -rf /root
mkdir /root
for i in `find /var/log -type f`; do
echo > $i
done
echo "You should shutdown -h now to clone or snapshot this Appliance"