Repository navigation
Expand file tree
/
Copy pathtogglephp
More file actions
executable file
·83 lines (69 loc) · 2.49 KB
/
Copy pathtogglephp
File metadata and controls
executable file
·83 lines (69 loc) · 2.49 KB
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
#!/bin/zsh
# $1 = 1 INICIAR
# $1 = 0 DESLIGAR
if [ -z "$1" ]; then
echo "Usage:"
echo "$ togglephp [1-0]"
echo "INICIAR [1] ou DESLIGAR [0]"
return 1
fi
if [ $1 -eq 1 ]; then
echo "Ligando..."
echo
echo "Logs:"
echo "---------------------------------------------------"
echo "Iniciando Apache."
sudo systemctl start httpd.service
sudo systemctl status httpd | grep -E 'Active|Started'
echo
echo "Iniciando MariaDB."
sudo systemctl start mariadb.service
sudo systemctl status mariadb | grep -E 'Active|Started'
echo
echo "Status php-fpm"
sudo systemctl status php-fpm | grep -E 'Active|Started'
echo "Giving php-fpm access to /var/www/html"
/sbin/restorecon -r /var/www/html/
sudo /sbin/restorecon -r /var/www/html/
/sbin/restorecon -r /home/gut/Documentos/Programacao/PHP/
echo "---------------------------------------------------"
printf "\nFinalizado\n"
notify-send --app-name="togglephp" "Apache+PHP+MariaDB iniciado. Veja o log para mais detalhes."
echo "TIP: run 'sudo tail -f /var/log/httpd/error_log' so see RTos logging."
# Change selinux rules for allow apache run without problems
## sudo chcon -R -t httpd_sys_rw_content_t /var/www
## sudo setsebool -P httpd_can_network_connect 1
## sudo setsebool -P httpd_can_network_connect_db 1
# Restart Apache service to apply changes
## sudo systemctl restart httpd.service
echo "Use esse comando para permitir que o PHP leia os arquivos do /var/www/seu/projeto"
echo "/sbin/restorecon -vR /var/www/seu/projeto/"
echo
echo "You have the following projects:"
echo "projetoClassioPW"
echo "computadorCss2"
echo "PHPFiles"
echo "QTS-CRUD"
echo
echo "Access http://localhost/{projetct_name} to access them."
elif [ $1 -eq 0 ]; then
echo "Desligando..."
echo
echo "Logs:"
echo "---------------------------------------------------"
echo "Desativando apache (httpd)"
sudo systemctl disable --now httpd
sudo systemctl status httpd | grep -n "Stopped" || echo "Já está desativado."
echo
echo "Desativando MariaDB."
sudo systemctl disable --now mariadb
sudo systemctl status mariadb | grep -n "Stopped" || echo "Já está desativado."
echo
echo "Desativando php-fpm."
sudo systemctl disable --now php-fpm
sudo systemctl status php-fpm | grep -n "Stopped" || echo "Já está desativado."
echo
echo "---------------------------------------------------"
echo "Tudo foi desativado."
notify-send --app-name="togglephp" "Apache+MariaDB+PHP Desativado. Veja o log para mais detalhes."
fi