-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_check.sh
More file actions
executable file
·32 lines (25 loc) · 892 Bytes
/
Copy pathserver_check.sh
File metadata and controls
executable file
·32 lines (25 loc) · 892 Bytes
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
#!/bin/bash
# Store the service name in a variable
SERVICE_NAME="nginx"
# Ask the user if they want to check the status
read -p "Do you want to check the status of $SERVICE_NAME? (y/n): " choice
# Convert choice to lowercase to handle 'Y' or 'y'
choice=${choice,,}
if [ "$choice" = "y" ]; then
echo "Checking $SERVICE_NAME status..."
echo "--------------------------------"
# Run systemctl status
systemctl status "$SERVICE_NAME"
# Check the exit status of the systemctl command
if [ $? -eq 0 ]; then
echo "--------------------------------"
echo "Result: $SERVICE_NAME is active and running."
else
echo "--------------------------------"
echo "Result: $SERVICE_NAME is NOT active or not installed."
fi
elif [ "$choice" = "n" ]; then
echo "Skipped."
else
echo "Invalid option. Please enter 'y' or 'n'."
fi