-
Notifications
You must be signed in to change notification settings - Fork 26
/
core.sh
138 lines (129 loc) · 4.07 KB
/
core.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
134
135
136
#!/bin/sh
cyan='\e[1;37;44m'
red='\e[1;31m'
endColor='\e[0m'
datetime=$(date +%Y%m%d%H%M%S)
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
####################################################################
# Get System Info
####################################################################
shootProfile(){
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "${OS}" == "windowsnt" ]; then
OS=windows
elif [ "${OS}" == "darwin" ]; then
OS=mac
else
OS=`uname`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
if [ -f /etc/lsb-release ] ; then
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
}
shootProfile
#echo "OS: $OS"
#echo "DIST: $DIST"
#echo "PSUEDONAME: $PSUEDONAME"
#echo "REV: $REV"
#echo "DistroBasedOn: $DistroBasedOn"
#echo "KERNEL: $KERNEL"
#echo "MACH: $MACH"
#echo "========"
####################################################################
# Print Menu
####################################################################
printMenu(){
if [[ "$user" = "" || "$passwd" = "" || "$port" = "" ]]; then
echo -e "$red Error: USER, PASS AND PORT ARE REQUIRED, PLEASE SET THEM IN CONFIG FILE $endColor"
echo ""
echo ""
exit 1
fi
clear
echo -e "$cyan Fast and Easy Web Server Installation $endColor"
echo "Choose an option writing its number and press enter:"
echo -e "\t1) Create a user"
echo -e "\t2) Create users profile (color in bash)"
echo -e "\t3) Update and Install (Apache, PHP, MySQL, SQLite, Django, Subversion)"
echo -e "\t4) Configurating SSH and IPTABLES"
echo -e "\t5) Configure and securitizing Apache"
echo -e "\t6) Configure and securitizing MySQL"
echo -e "\t7) Create SVN & TRAC repos"
echo -e "\t8) Create a Mail Server"
echo -e "\t9) Create a cron backup (mysql, apache, trac & svn)"
echo -e "\t10) Set DNS and to add Google Apps MX records (Only SliceHost.com)"
echo -e "\t11) Install Trac and its Plugins"
echo -e "\t12) I do not know, exit!"
#echo -e "\t13) Create VirtualHosts"
read option;
while [[ $option -gt 12 || ! $(echo $option | grep '^[1-9]$') ]]
do
printMenu
done
runOption
}
####################################################################
# Run an Option
####################################################################
runOption(){
case $option in
1) createUser;;
2) profileUser;;
3) updateInstall;;
4) sshIptables;;
5) secureApache;;
6) secureMySQL;;
7) tracsvn;;
8) mailServer;;
9) cronBackup;;
10) set_dns;;
11) InstallTrac;;
12) exit
# 13) CreateVirtualHosts;;
esac
echo "Press any Key to continue"
read x
printMenu
}