-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_apache.sh
executable file
·54 lines (47 loc) · 1.52 KB
/
start_apache.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
#!/bin/bash
# Define a function to print error messages
PrintError() {
tput setaf 1 # Set text color to red
#tput setab 7 # Set background color to white
tput bold # Set text to bold
echo -e "\e[47mError: $1\e[0m\e[K\n"
#tput setab 0
tput sgr0 # Reset text and background colors, and remove bold
}
FLAVOR=$(uname -s)
LSB_RELEASE=$(command -v lsb_release 2> /dev/null)
echo "FLAVOR: $FLAVOR"
echo "LSB_RELEASE: $LSB_RELEASE"
if [ "$FLAVOR" = "Linux" ]; then
if [ -n "$LSB_RELEASE" ]; then
DISTRIBUTION=$(lsb_release -si | sed 's/Linux//')
else
DISTRIBUTUTION="Other"
fi
echo "DISTRIBUTION: $DISTRIBUTION"
case "$DISTRIBUTION" in
"Manjaro" | "ManjaroLinux")
if ! command -v httpd -v &>/dev/null; then
PrintError "Apache is not found on Manjaro."
echo "To install Apache, run: sudo pacman -S apache"
else
httpd -v
sudo systemctl start httpd.service
fi
;;
"Ubuntu" | "Debian")
if ! command -v apache2 &>/dev/null; then
PrintError "Apache is not found on Ubuntu/Debian."
echo -e "To install Apache, run: sudo apt-get install apache2"
echo
else
sudo service apache2 start
fi
;;
*)
PrintError "Unsupported distribution: $DISTRIBUTION"
;;
esac
else
PrintError "Unsupported operating system: $FLAVOR"
fi