-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlazy-install.sh
139 lines (129 loc) · 5.69 KB
/
lazy-install.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
#!/bin/bash
clear
if [ "$EUID" -ne 0 ]; then
echo "Please run Lazy Script as root"
exit
fi
clear
echo -e '\n'
echo '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
echo '+ +'
echo '+ _| |-| |_|_|_|_|_ _| |_ +'
echo '+ _| _| |_ _| _| |_ +'
echo '+ _| _|_|_|_||_ _| |_|_|_| +'
echo '+ _| _| |_ _| |_| +'
echo '+ _|_|_|_| _| |_ _|_|_|_|_| |_| +'
echo '+ +'
echo '+ +'
echo '+ Lazy Web Control Panel +'
echo '+ version : 1.0.0 +'
echo '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
echo -e "\n\n"
echo -n "Do you wish to continue? [Y/n]: "
read continue
case $continue in
n* | N*) exit ;;
esac
################################################################################
# setup passwor
PASSWORD=$(openssl rand -base64 14)
USERNAME='admin'
DB_PASSWORD=$(openssl rand -base64 14)
################################################################################
# Welcome and instructions
echo "It will take a few minits to complate all the installation "
sleep 5
################################################################################
# update repo
sudo apt-get upadate
sudo apt-get upgrade -y
################################################################################
#PHP7.4 PPA
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/apache2 -y
sudo add-apt-repository ppa:ondrej/php -y
################################################################################
#Update the repositories
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y php7.4
################################################################################
#Apache, Php, MySQL and required packages installation
sudo apt-get -y install apache2 php7.4 libapache2-mod-php7.4 php7.4-mcrypt php7.4-curl php7.4-mysql php7.4-gd php7.4-cli php7.4-dev mysql-client php7.4-xml php7.4-zip -y
pear install File_Archive
#this is another package
sudo pecl install mcrypt-1.0.2
sudo apt-get install libapache2-mod-php7.4 -y
sudo apt-get install php7.4-mbstring -y
################################################################################
#The following commands set the MySQL root password to MYPASSWORD123 when you install the mysql-server package.
#Genarate password
DB_PASSWORD=$(openssl rand -base64 16)
PASSWORD=$(openssl rand -base64 16)
sudo debconf-set-selections <<<'mysql-server mysql-server/root_password password '${DB_PASSWORD}
sudo debconf-set-selections <<<'mysql-server mysql-server/root_password_again password '${DB_PASSWORD}
################################################################################
# install mysql server
sudo apt-get -y install mysql-server
################################################################################
#Restart all the installed services to verify that everything is installed properly
printf "\n"
service apache2 restart && service mysql restart >/dev/null
################################################################################
#configure virtual host for lazy
printf "\n"
php -v
################################################################################
# check for error
if [ $? -ne 0 ]; then
printf "Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)"
else
#configure v host for lazy ip:3000
ip_add=($(hostname -I))
declare -p ip_add
mkdir /var/www/lazy/
chmod 777 /var/www/lazy/
mkdir /var/www/lazy/logs/
chmod 777 /var/www/lazy/logs/
echo '
#configure v host for lazy ip:3000
Listen '${ip_add[0]}':3000
<VirtualHost '${ip_add[0]}':3000>
DocumentRoot "/var/www/lazy/"
ErrorLog /var/www/lazy/logs/error.log
</VirtualHost>' >'/etc/apache2/sites-available/lazy.conf'
sudo a2ensite lazy
systemctl reload apache2
sudo service apache2 restart
printf "\n"
echo "
<?php
// this is main config page for lazy
define('USERNAME','admin');
define('PASSWORD','"${PASSWORD}"');
define('LAZY_FM_PATH','/var/www/html/');
define('BACKUP_DIR','/var/www/lazy/backup/');" >"config.php"
cp -r * /var/www/lazy
mkdir /var/www/lazy/backup
chown www-data -R /var/www/lazy/backup
chmod 755 /var/www/lazy/backup
chown www-data -R /var/www/html
chown www-data -R /var/www/lazy/phpMyAdmin/tmp
chmod 755 /var/www/lazy/phpMyAdmin/tmp
sudo crontab -l 2 > cron_bkp
sudo echo "0 18 * * * php /var/www/lazy/functions/Backup.php" >> cron_bkp
sudo crontab cron_bkp
sudo rm cron_bkp
clear
printf "#################################################################\n"
printf "# \n"
printf "# Lazy Panel Is Installed Successfully \n"
printf "# \n"
printf "# server - http://${ip_add[0]}:3000 \n"
printf "# username - admin \n"
printf "# Password - $PASSWORD \n"
printf "# MySql User - root \n"
printf "# MySql Password - $DB_PASSWORD \n"
printf "# \n"
printf "#################################################################\n"
fi