-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripting1.sh
More file actions
executable file
·107 lines (93 loc) · 1.41 KB
/
scripting1.sh
File metadata and controls
executable file
·107 lines (93 loc) · 1.41 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
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# file commenting.sh
# brief Our First Script with commenting for the file and functions
# author bilbo.baggins
# lecture 5.1 comments
# date 7/8/2020
#title
title="Scripting 1"
#functions
#Checks to see if user is root
isroot()
{
if [ "$(id -u)" != "0" ]; then
cat << EOF
Must run in root.
EOF
exit
fi
}
#Basic System Information
systeminfo()
{
DISTRIBUTION=$(lsb_release -a)
KERNELVERSION=$(uname -a)
CPUARCHITECTURE=$(lscpu | awk '/Architecture/ {print}')
cat << EOF
Linux Distribution:
$DISTRIBUTION
Kernel Version:
$KERNELVERSION
$CPUARCHITECTURE
EOF
}
#Gets the system's IP address
networkinfo()
{
IPADDRESS=$(hostname -I)
cat << EOF
IP Address:$IPADDRESS
EOF
}
#Gets the amount of available storage space
storagespace()
{
STORAGESPACE=$(df -h -l)
cat<<EOF
Free Storage Space:
$STORAGESPACE
EOF
}
#Checks disk information
diskinfo()
{
DISKINFO=$(lsblk)
cat<<EOF
Disk Information:
$DISKINFO
EOF
}
#Gets all users on this system
getusers()
{
USERS=$(cat /etc/passwd | grep bash | cut -d ":" -f 1 | sort)
cat<<EOF
All Users In Order:
$USERS
EOF
}
#Gets the current date and time
dateandtime()
{
DATEANDTIME=$(date)
cat<<EOF
Date and Time:$DATEANDTIME
EOF
}
#Gets current user
getcurrentuser()
{
CURRENTUSER=$(whoami)
cat<<EOF
Current User:$CURRENTUSER
EOF
}
isroot
echo "Welcome to CSI230: " $title
systeminfo
storagespace
diskinfo
getusers
networkinfo
dateandtime
getcurrentuser