-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache-quote.sh
156 lines (116 loc) · 3.15 KB
/
apache-quote.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Simple script which might help you to install and manage your apache web server or even create your first webpage
# Pss ! Here you can learn some funny polish quotes !
# This script is supposed to work only on Ubuntu :(
# Some of the functions might be run only by sudoers
function banner() {
echo ""
echo ""
echo "-----------------------------------------------------------------"
echo ""
echo " WELCOME IN APACHE FRIEND "
echo ""
echo "-----------------------------------------------------------------"
echo ""
echo ""
}
red=`tput setaf 1`
green=`tput setaf 2`
blue=`tput setaf 3`
function menu() {
echo ""
echo "-----------------------------------------------------------------"
echo ""
echo " MENU "
echo ""
echo "-----------------------------------------------------------------"
echo ""
echo "Co wybierasz?"
select y in ReposUpdate InstallApache StartApache StopApache StatusApache SelectQuote MakeYourWebPage Quit
do
case $y in
"ReposUpdate")
reposUpdate
;;
"InstallApache") installApache ;;
"StartApache") restartApache ;;
"SelectQuote") selectQuote ;;
"StopApache") stopApache ;;
"StatusApache") statusApache ;;
"SelectQuote") selectQuote ;;
"MakeYourWebPage") makeWebPage ;;
"Quit") exit ;;
*) failMsg ;;
esac
break
done
}
function reposUpdate() {
echo ""
echo "${red}Your repositories will be updated, so you will be sure to have actual repos. "
echo ""
sudo apt-get update
}
function installApache() {
echo ""
echo "${green}Now, we will install Apache Server as long as it hasn't been yet installed "
echo ""
reposUpdate
sudo apt-get install apache2
successMsg
}
function restartApache() {
echo ""
echo "${blue}Now, we will start Apache if it is running "
echo ""
sudo kill -9 $(sudo lsof -t -i:8000) 2> /dev/null
sudo service apache2 start -y 2>/dev/null
}
function stopApache() {
echo ""
echo "Now, we will stop apache service"
sudo service apache2 stop -y
}
function statusApache() {
echo ""
echo "Now, we will check the status of th eapache service. "]
echo ""
sudo service apache2 status
}
function selectQuote() {
echo ""
echo "Now, we will replace our home page with some interesting quote :) "
echo ""
html=".html"
myres=`shuf -i 1-9 -n 1`
result="$myres${html}"
cp html/"$result" ../../../var/www/html/index.html
restartApache
successMsg
}
function makeWebPage(){
echo ""
echo "Now, we will create our own webpage :) "
echo "To do this, please create html file and copy it to html directory, then run this script again and select this option "
echo ""
result=`ls html -1 -t | head -1`
echo "Current loaded file is ..."
echo "$result"
sudo cp html/"$result" ../../../var/www/html/index.html
restartApache
}
function successMsg(){
echo ""
echo "Congrats ! You have succesfully updated your own webpage !"
echo ""
echo "If you want to visit it now, please type in your browser: 127.0.0.1:80 "
echo ""
}
function failMsg(){
echo ""
echo "Something went terribly wrong, please check your configuration, but now exiting ..."
echo ""
exit 1
}
banner
menu