yayponies-ipfs/install.sh
Daniil Gentili 3b2cfb815e Final
2019-04-22 11:00:10 +00:00

64 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
echo "Deploying YayPonies IPFS Mirror"
echo ""
which ipfs &> /dev/null || { echo "Install ipfs, first: https://docs.ipfs.io/introduction/install/" && exit 1; }
echo "This script has only been tested on Debian Jessie and Ubuntu Trusty"
echo "It will install a new IPFS mirror on a newly deployed system"
echo "It SHOULD NOT BE USED ON MULTIPLE SITE CONFIGURATION"
echo "IT SHOULD ALSO NOT BE USED IF PORT 8808 IS UNAVAILABLE"
echo ""
echo "This will install nginx from your distribution repository"
echo "set configuration, cron task"
echo "and finally start your mirror"
echo ""
echo "This program is distributed WITHOUT ANY WARRANTY"
read -n1 -r -p "Press space or enter to continue, any other keys to cancel..." key
if [ "$key" = '' ]; then
echo ""
echo "OK, Starting..."
else
echo ""
echo "OK, Cancelling..."
exit 1
fi
sudo service nginx stop
sudo rm -rf /etc/nginx/sites-enabled/default
sudo rm -rf /etc/nginx/conf.d/default
HTTP=" server {\n
listen 8808 default_server;\n
listen [::]:8808 default_server;\n
server_name localhost;\n
ssi on;\n
root $PWD/ypmirror;\n
error_page 404 /sorry/404.php;\n
error_page 403 /sorry/403.php;\n
autoindex off;\n
location / {\n
index index.php index.html index.htm;\n
error_page 404 /sorry/404.php;\n
error_page 403 /sorry/403.php;\n
}\n
location ~ \.php$ {\n
types { text/html php; }\n
} \n
}"
echo -e $HTTP > yp.conf
sudo mv yp.conf /etc/nginx/conf.d/yp.conf
sudo service nginx start
sudo cp script.sh /usr/bin/yayponies-update.sh
yayponies-update.sh $PWD localhost:8808
crontab -l > /tmp/yayponies-cron
sed -i '/yayponies-update/d' /tmp/yayponies-cron
echo "*/10 * * * * /usr/bin/yayponies-update.sh $PWD localhost:8808" >> /tmp/yayponies-cron
crontab /tmp/yayponies-cron
rm /tmp/yayponies-cron