astrXbian/www/boris/install.sh

84 lines
3.0 KiB
Bash
Raw Normal View History

2021-03-15 17:16:52 +01:00
#!/bin/bash
########################################################################
# Author: boris
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $(which apache2) ]] && echo "Apache est installé. Le plugin nécessite nginx. EXIT" && exit 1
[[ $(netstat -tan | grep ':10111 ') ]] && echo "Serveur web existant sur port 10111. Installation manuelle recommandée... EXIT" && exit 1
########################################################################
## INSTALL nginx + php + mariadb + ...
sudo apt-get update -y
sudo apt-get install mariadb-server nginx python3-certbot-nginx certbot ssl-cert php-imap php-cli php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-gettext php-mysql php-fpm -y
#######################################################################
## CREATE symlinks for ~/.zen/www/swarm & me
mkdir -p ~/.zen/astrXbian/www/boris && cd ~/.zen/astrXbian/www/boris
2021-03-15 17:16:52 +01:00
ln -s ../ipfs_swarm swarm
ln -s ../ipfs me
########################################################################
## CREATE site config file
printf "
server {
listen 10111 default_server;
listen [::]:10111 default_server;
root " | sudo tee /etc/nginx/sites-available/tube.copylaradio.com
2021-03-15 17:16:52 +01:00
printf root /home/$YOU/.zen/astrXbian/www/boris | sudo tee -a /etc/nginx/sites-available/tube.copylaradio.com
2021-03-15 17:16:52 +01:00
printf ";
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name tube.copylaradio.com;
2021-03-15 17:16:52 +01:00
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files \$uri \$uri/ =404;
}
index index.php;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
location /ipfs {
proxy_pass http://127.0.0.1:8181;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /ipns {
proxy_pass http://127.0.0.1:8181;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
2021-03-15 17:16:52 +01:00
}
" | sudo tee -a /etc/nginx/sites-available/tube.copylaradio.com
########################################################################
## ACTIVATE sites-available/tube.copylaradio.com
cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/tube.copylaradio.com tube.copylaradio.com