-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabcheck0.bash
More file actions
97 lines (88 loc) · 2.5 KB
/
Copy pathlabcheck0.bash
File metadata and controls
97 lines (88 loc) · 2.5 KB
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
95
96
97
#!/bin/bash
# OPS335 Lab 0 configuration check
# Written by: Peter Callaghan
# Last Modified: 10 May. '18
# This script runs a series of commands to show the current configuration of the machine it is run on
# Run it as root on each of your machines, and attach the output to the lab submission.
#check if history was updated
command=`tail -1 ~/.bash_history`
if [ "$command" != "history -a" ]
then
echo "Make sure you run history -a before running this script, otherwise your recent commands will not be present in the .bash_history file" >&2
exit 1
fi
if [ `getenforce` != "Enforcing" ]
then
echo "SELinux is not currently enforcing on this machine. Turn it back on, and do not turn it off again." >&2
exit 2
fi
if [ "$(echo $HOSTNAME | grep "^vm" )" == "" ]
then
if [ `mount | grep '/var/lib/libvirt/images' | wc -l` -ne 1 ]
then
echo "You don't seem to have a separate filesystem for /var/lib/libvirt/images" >&2
exit 5
else
if [ `df | grep /var/lib/libvirt/images | awk '{print $2;}'` -lt 80000000 ]
then
echo "Your /var/lib/libvirt/images filesystem is smaller than 80GB, that's too small." >&2
exit 6
else
echo "Your /var/lib/libvirt/images filesystem seems to be OK." >&2
filesystem=`df | grep /var/lib/libvirt/images | cut -d' ' -f1`
uuid=`blkid $filesystem | sed -r 's/^.*UUID="([-a-zA-Z0-9]+)".*$/\1/'`
fi
fi
else
filesystem=`df | grep centos-root | cut -d' ' -f1`
uuid=`blkid $filesystem | sed -r 's/^.*UUID="([-a-zA-Z0-9]+)".*$/\1/'`
fi
if [ "`systemctl is-active iptables`" != "active" ]
then
if [ "`systemctl is-active firewalld`" == "active" ]
then
echo "This machine should be running iptables, not firewalld." >&2
else
echo "This machine does not have a running firewall. Turn iptables on, and do not turn it off again." >&2
fi
exit 3
fi
date
echo
echo "hostname:"`hostname`
echo
echo "SELinux status:"`getenforce`
echo
echo release:`uname -r`
echo
echo "UUID:$uuid"
echo
if [ "$(echo $HOSTNAME | grep "^vm" )" == "" ]
then
echo "Users"
grep home /etc/passwd
echo
echo "libvirtd:"`systemctl is-active libvirtd`
echo "libvirtd:"`systemctl is-enabled libvirtd`
echo
fi
echo "Boot sessions"
last | grep "system boot" | sed -r 's/[[:space:]]+/ /g'
echo
echo "Commands as root"
cat ~/.bash_history
echo
for each in $(ls /home | grep -v "lost+found")
do
if [ -d /home/$each ]
then
echo "Commands as $each"
cat /home/$each/.bash_history
echo
else
echo "Extra files found in /home: " $each
fi
done
echo
echo crontab
crontab -l 2>/dev/null | sed -e '/^$/ d' -e '/^#/ d'