-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_start_service_gui.sh
90 lines (76 loc) · 2.42 KB
/
enable_start_service_gui.sh
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
#!/bin/bash
# Define colors for output
GREEN="\033[0;32m"
RED="\033[0;31m"
TEXTRESET="\033[0m"
# Check if dialog is installed
if ! command -v dialog &>/dev/null; then
echo -e "${RED}Dialog is not installed. Please install it to use this script.${TEXTRESET}"
exit 1
fi
# Function to show an infobox message with a title
show_infobox() {
dialog --title "Checking installed services" --infobox "$1" 5 70
sleep 2
}
# Function to check if a package is installed
check_package_installed() {
local package_name="$1"
if dnf list installed "$package_name" &>/dev/null; then
return 0
else
return 1
fi
}
# Function to enable and start a service
enable_and_start_service() {
local service_name="$1"
show_infobox "Enabling $service_name service to start on boot..."
sudo systemctl enable "$service_name"
show_infobox "Starting $service_name service..."
sudo systemctl start "$service_name"
if systemctl is-active --quiet "$service_name"; then
show_infobox "$service_name service is running."
else
show_infobox "$service_name service failed to start."
fi
}
# Display a starting banner with a title
dialog --title "Checking activated services" --infobox "Enabling and Starting services..." 5 70
sleep 3
# Main script execution
for service in netdata webmin ntopng suricata filebeat kibana elasticsearch; do
if check_package_installed "$service"; then
enable_and_start_service "$service"
else
show_infobox "$service is not installed. Skipping..."
fi
done
# Special handling for bind
if check_package_installed "bind"; then
enable_and_start_service "named"
else
show_infobox "bind is not installed. Skipping..."
fi
# Special handling for Cockpit
if check_package_installed "cockpit"; then
enable_and_start_service "cockpit.socket"
else
show_infobox "cockpit is not installed. Skipping..."
fi
# Special handling for Kea
if check_package_installed "isc-kea-dhcp4"; then
enable_and_start_service "kea-dhcp4"
else
show_infobox "isc-kea-dhcp4 is not installed. Skipping..."
fi
# Special handling for Kea DDNS
if check_package_installed "isc-kea-dhcp-ddns"; then
enable_and_start_service "kea-dhcp-ddns"
else
show_infobox "isc-kea-dhcp-ddns is not installed. Skipping..."
fi
if check_package_installed "ddclient"; then
show_infobox "ddclient is installed. Please manually configure it for your DDNS requirements."
sleep 3
fi