-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.sh
59 lines (50 loc) · 1.62 KB
/
Setup.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
#!/data/data/com.termux/files/usr/bin/bash
# Create necessary folders
mkdir $PREFIX/etc/nginx/conf.d
mkdir $PREFIX/etc/nginx/sites-enabled
mkdir $PREFIX/etc/nginx/snippets
# Create and edit fastcgi-params file
cat <<EOF > $PREFIX/etc/nginx/conf.d/fastcgi-params
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;
EOF
# Create and edit default site config file
cat <<EOF > $PREFIX/etc/nginx/sites-enabled/default
server {
listen 8080 default_server;
root /data/data/com.termux/files/usr/var/www/html/public;
index index.html;
server_name localhost;
location / {
try_files \$uri /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;
}
}
EOF
# Create and edit fastcgi-php.conf file
cat <<EOF > $PREFIX/etc/nginx/snippets/fastcgi-php.conf
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
try_files \$fastcgi_script_name =404;
set \$path_info \$fastcgi_path_info;
fastcgi_param PATH_INFO \$path_info;
fastcgi_index index.php;
include fastcgi.conf;
EOF
# Replace entire server block in nginx.conf file
sed -i '/^server {/,/^}/d' $PREFIX/etc/nginx/nginx.conf
cat <<EOF >> $PREFIX/etc/nginx/nginx.conf
include conf.d/*.conf;
include sites-enabled/*;
EOF
# Install grocy
wget https://releases.grocy.info/latest
mkdir -p $PREFIX/var/www/html
unzip -q latest -d $PREFIX/var/www/html
cp $PREFIX/var/www/html/config-dist.php $PREFIX/var/www/html/data/config.php
# Enable php-fpm and nginx services
sv-enable php-fpm
sv-enable nginx