-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathinstaller.sh
188 lines (150 loc) · 5.29 KB
/
installer.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
exec 2>/dev/null
#COLORES
green='\033[1;32m'
red='\e[;31m'
endcolor='\033[0m'
install_library='\033[1;31m'
PWD=`pwd`
#LIBRERIAS
xampp_blackstone=`ls /opt/BlackStone/xampp_installer/xampp-installer.run`
xampp_installed=`ls /opt/lampp/xampp`
blackstone_installed=`ls /opt/lampp/htdocs/BlackStone`
bbdd_installed=`ls $PWD/xampp_installer/db_installed.txt`
python3_installed=`which python3`
created_icon=`ls /usr/share/applications/blackstone.desktop`
chmod 777 /opt/blackstone/xampp_installer/icon/blackstone.png
chmod 777 /opt/blackstone/xampp_installer/icon/blackstone.desktop
echo ""
echo "▄▄▄▄· ▄▄▌ ▄▄▄· ▄▄· ▄ •▄ .▄▄ · ▄▄▄▄▄ ▐ ▄ ▄▄▄ . "
echo "▐█ ▀█▪██• ▐█ ▀█ ▐█ ▌▪█▌▄▌▪▐█ ▀. •██ ▪ •█▌▐█▀▄.▀· "
echo "▐█▀▀█▄██▪ ▄█▀▀█ ██ ▄▄▐▀▀▄·▄▀▀▀█▄ ▐█.▪ ▄█▀▄ ▐█▐▐▌▐▀▀▪▄ "
echo "██▄▪▐█▐█▌▐▌▐█ ▪▐▌▐███▌▐█.█▌▐█▄▪▐█ ▐█▌·▐█▌.▐▌██▐█▌▐█▄▄▌ "
echo "·▀▀▀▀ .▀▀▀ ▀ ▀ ·▀▀▀ ·▀ ▀ ▀▀▀▀ ▀▀▀ ▀█▄▀▪▀▀ █▪ ▀▀▀ "
echo ""
echo "Created by Joan Moya (Aka. MicroJoan)"
sleep 3
echo " "
echo " "
echo "Checking components for BLACKSTONE"
echo "==================================="
echo ""
sleep 0.5
#Check as ROOT
if ! [ $(id -u) = 0 ];
then
echo ""
echo " ${red} EXECUTE AS ROOT!! ${endcolor}"
exit
fi
#Check xampp installer binarie
if [ -z $xampp_blackstone ] #si xampp_installed es vacío..
then
echo "XAMP INSTALLER ${red} KO ${endcolor}"
echo ""
sleep 1
echo "Downloading Xampp installer on BlackStone..."
echo ""
wget https://github.com/micro-joan/BlackStone/releases/download/installer/xampp-installer.run -P /opt/BlackStone/xampp_installer &
pid_descarga=$!
while kill -0 $pid_descarga 2>/dev/null; do
sleep 1
done # Continuar con la siguiente acción después de que la descarga haya finalizado
else
echo "XAMPP INSTALLER ${green} OK ${endcolor}"
fi
sleep 1
#Check xampp
if [ -z $xampp_installed ] #si xampp_installed es vacío..
then
echo "XAMP ${red} KO ${endcolor}"
echo ""
sleep 1
echo "Installing Xampp..."
echo ""
chmod 777 /opt/BlackStone/xampp_installer/xampp-installer.run
chmod +x /opt/BlackStone/xampp_installer/xampp-installer.run & ./xampp_installer/xampp-installer.run
clear
else
echo "XAMPP ${green} OK ${endcolor}"
fi
sudo /opt/lampp/lampp start
sleep 1
#Check blackstone
if [ -z $blackstone_installed ] #si blackstone_installed es vacío..
then
echo ""
echo "${red} Installing BlackStone core${endcolor}"
echo ""
sleep 1
chmod /opt/lampp/htdocs
cp -r BlackStone/ /opt/lampp/htdocs #copiamos todos los archivos al nuevo directorio
chmod -R 777 /opt/lampp/htdocs/BlackStone/
sleep 1
else
echo "BlackStone core ${green} OK ${endcolor}"
fi
sleep 1
echo "Installing DB on BlackStone..."
sleep 1
# Configuración de la base de datos
DB_USER="root"
DB_PASS=""
DB_NAME="blackstone"
# Ruta del archivo SQL a importar
PWD=`pwd`
SQL_FILE="blackstone.sql"
ROUTE_FILE="$PWD/xampp_installer/$SQL_FILE"
# Comando para importar el archivo SQL en la base de datos
/opt/lampp/bin/mysql -u${USER} -e "CREATE DATABASE $DB_NAME;"
/opt/lampp/bin/mysql -u${USER} $DB_NAME < $ROUTE_FILE
echo ""
echo "¡Database is installed now!"
sleep 2
clear
/opt/lampp/xampp restart > /dev/null
#Check DB installed
if [ -z $bbdd_installed ] #si bbdd_installed es vacío..
then
echo "Database ${red} not installed ${endcolor}"
echo ""
sleep 1
echo "Installing DB on BlackStone..."
sleep 1
# Configuración de la base de datos
DB_USER="root"
DB_PASS=""
DB_NAME="blackstone"
# Ruta del archivo SQL a importar
PWD=`pwd`
SQL_FILE="blackstone.sql"
ROUTE_FILE="$PWD/xampp_installer/$SQL_FILE"
# Comando para importar el archivo SQL en la base de datos
/opt/lampp/bin/mysql -u${USER} -e "DROP DATABASE $DB_NAME;"
/opt/lampp/bin/mysql -u${USER} -e "CREATE DATABASE $DB_NAME;"
/opt/lampp/bin/mysql -u${USER} $DB_NAME < $ROUTE_FILE
sleep 2
# echo "database installed" > xampp_installer/db_installed.txt #creamos archivo para verificar que se ha instalado la db
echo ""
clear
echo ""
echo "¡Database is installed now!"
sleep 2
clear
else
echo "BlackStone DB ${green} OK ${endcolor}"
fi
sleep 1
#creamos alias en sistema
cp /opt/BlackStone/xampp_installer/icon/blackstone /usr/local/bin/blackstone
chmod +x /usr/local/bin/blackstone
#copiamos el icono en sistema
cp /opt/BlackStone/xampp_installer/icon/blackstone.desktop /usr/share/applications/blackstone.desktop
chmod +x /usr/share/applications/blackstone.desktop
#configuramos arranque desde alias/icono
chmod +x /opt/BlackStone/xampp_installer/icon/simple_launch.sh
echo " "
echo "Launching BlackStone..."
echo ""
sleep2
xdg-open "http://localhost/BlackStone/"
exit