-
Notifications
You must be signed in to change notification settings - Fork 12
/
OCSTemplateCentos.sh
190 lines (171 loc) · 6.51 KB
/
OCSTemplateCentos.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
#Initializing var
if [[ "$USER" != 'root' ]]; then
echo "Run this script with root privileges."
exit
fi
if [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then
OS=centos
RCLOCAL='/etc/rc.d/rc.local'
chmod +x /etc/rc.d/rc.local
else
echo "This script installer only works on Centos system."
exit
fi
#Requirement
yum -y update && yum -y install curl
# Checking Status
MYIP=$(curl -4 icanhazip.com)
# go to root
cd
#Start Installing
clear
echo ""
echo ""
echo ""
echo "Configure Database OCS Panel Name"
echo "(Make sure the database name contains no spaces, symbols, or special characters.)"
read -p "Database Name : " -e -i OCSShigeno NamaDatabase
echo "Input MySQL Password:"
echo "(Use different Password for your database, dont use VPS password.)"
read -p "Database Password: " -e -i shigeno PasswordDatabase
echo ""
echo "All questions have been answered."
read -n1 -r -p "Press any key to continue ..."
#Set Repo
cd
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
rpm -Uvh remi-release-6.rpm
if [ "$OS" == "x86_64" ]; then
wget https://raw.githubusercontent.com/shigeno143/OCSPanelCentos6/master/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
else
wget https://raw.githubusercontent.com/shigeno143/OCSPanelCentos6/master/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.i686.rpm
fi
sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo
sed -i -e "/^\[remi\]/,/^\[.*\]/ s|^\(enabled[ \t]*=[ \t]*0\\)|enabled=1|" /etc/yum.repos.d/remi.repo
rm -f *.rpm
# update
yum -y update
yum -y groupinstall 'Development Tools' && yum -y install cmake && yum -y install expect-devel
#Install MySQL & Create Database
yum -y install mysql-server
chown -R mysql:mysql /var/lib/mysql/
chmod -R 755 /var/lib/mysql/
chkconfig mysqld on
service mysqld start
#mysql_secure_installation
so1=$(expect -c "
spawn mysql_secure_installation; sleep 3
expect \"\"; sleep 3; send \"\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"$PasswordDatabase\r\"
expect \"\"; sleep 3; send \"$PasswordDatabase\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect eof; ")
echo "$so1"
#\r
#Y
#pass
#pass
#Y
#Y
#Y
#Y
so2=$(expect -c "
spawn mysql -u root -p; sleep 3
expect \"\"; sleep 3; send \"$PasswordDatabase\r\"
expect \"\"; sleep 3; send \"CREATE DATABASE IF NOT EXISTS $NamaDatabase;EXIT;\r\"
expect eof; ")
echo "$so2"
#pass
#CREATE DATABASE IF NOT EXISTS OCS_PANEL;EXIT;
#Install Webserver
yum -y install nginx php php-fpm php-cli php-mysql php-mcrypt
rm -f /usr/share/nginx/html/index.html
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
mv /etc/nginx/conf.d/vps.conf /etc/nginx/conf.d/vps.conf.backup
wget -O /etc/nginx/nginx.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-centos6/nginx.conf"
wget -O /etc/nginx/conf.d/vps.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-centos6/vps.conf"
sed -i 's/www-data/nginx/g' /etc/nginx/nginx.conf
sed -i 's/apache/nginx/g' /etc/php-fpm.d/www.conf
sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sed -i 's/;session.save_path = "/tmp"/session.save_path = "/tmp"/g' /etc/php.ini
useradd -m vps && mkdir -p /home/vps/public_html
rm -f /home/vps/public_html/index.html && echo "<?php phpinfo() ?>" > /home/vps/public_html/info.php
chown -R nginx:nginx /home/vps/public_html
chown nginx:nginx /var/lib/php/session
chmod -R +rw /home/vps/public_html
chmod -R +rw /home/vps/public_html/*
chmod -R +rx /home/vps
chkconfig nginx on
chkconfig php-fpm on
service php-fpm restart
service nginx restart
#Install zip shigeno Script
yum -y install zip unzip
cd /home/vps/public_html
wget https://raw.githubusercontent.com/shigeno143/OCSPanelCentos6/master/ShigenoOCSTemplate.zip
unzip ShigenoOCSTemplate.zip
rm -f ShigenoOCSTemplate.zip
chown -R nginx:nginx /home/vps/public_html
chmod -R +rw /home/vps/public_html
chmod 777 /home/vps/public_html/config
chmod 777 /home/vps/public_html/config/inc.php
chmod 777 /home/vps/public_html/config/route.php
# OCS Panel Configuration
clear
echo "Configuration on VPS is done!"
echo "Now you have to configure OCS Panel through your browser!"
echo "Open Your Browser, go to http://$MYIP:85"
echo "Input the details of your Database"
echo "-----"
echo "Database:"
echo "- Database Host: localhost"
echo "- Database Name: $NamaDatabase"
echo "- Database User: root"
echo "- Database Pass: $PasswordDatabase"
echo ""
echo "Admin Login:"
echo "- Username: (Username of the OCS admin you like)"
echo "- Password: (password for OCS Admin Panel)"
echo "- Re-Enter Password: (Re-enter password)"
echo ""
echo "Press the Install button on the OCS Panel, and wait for the installation to complete."
echo "If you installed via browser, back to putty/juicessh, and then press [ENTER]!"
sleep 3
echo ""
read -p "If the above step has been done, please Press [Enter] key to continue... "
echo ""
#Delete Folder Install
rm -fR /home/vps/public_html/installation
#Delete History
cd
rm -f /root/.bash_history && history -c
rm -f /etc/sistem/secure/panel.sh
echo "unset HISTFILE" >> /etc/profile
# info
clear
echo ""
echo "--------------------------------------------------------------------------------"| tee -a log-install-ocspanel.txt
echo "Installing OCS Panel successfully done!" | tee -a log-install-ocspanel.txt
echo "Please login to your OCS Panels" | tee -a log-install-ocspanel.txt
echo "URL: http://$MYIP:85/" | tee -a log-install-ocspanel.txt
echo "Username: (Use the username you have input in the browser)" | tee -a log-install-ocspanel.txt
echo "Password: (Use the password you have input in the browser)" | tee -a log-install-ocspanel.txt
echo "" | tee -a log-install-ocspanel.txt
echo "Installatin Log: /root/log-install-ocspanel.txt" | tee -a log-install-ocspanel.txt
echo "--------------------------------------------------------------------------------"| tee -a log-install-ocspanel.txt
echo "Copyright https://www.HostingTermurah.net" | tee -a log-install-ocspanel.txt
echo "Script Created By Steven Indarto(fb.com/stevenindarto2)" | tee -a log-install-ocspanel.txt
echo "Modified by shigeno" | tee -a log-install-ocspanel.txt
echo "--------------------------------------------------------------------------------"| tee -a log-install-ocspanel.txt
echo ""
echo ""
cd