ruby-rewrite-proxy/installer.sh

102 lines
2.7 KiB
Bash

#!/bin/bash
set -e
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
# Install Ruby, Nginx, and Git
if [[ $OS == *"CentOS"* ]] || [[ $OS == *"Fedora"* ]]; then
sudo yum install -y ruby nginx git
elif [[ $OS == *"Arch"* ]]; then
sudo pacman -Syu --noconfirm ruby nginx git
elif [[ $OS == *"Debian"* ]] || [[ $OS == *"Ubuntu"* ]] || [[ $OS == *"Raspbian"* ]]; then
sudo apt-get update
sudo apt-get install -y ruby nginx git
else
echo "Unsupported operating system: $OS"
exit 1
fi
# install ruby dep dep webriccc
if ! gem list webrick -i > /dev/null; then
echo "Installing webrick..."
gem install webrick
fi
echo "enablin dat nginx and starting dat mf"
sudo systemctl enable nginx
sudo systemctl start nginx
# Make a directory in the current user's home folder called 'ruby-proxy'
if [ -d ~/ruby-proxy ]; then
echo "gurl that directory already exists you wanna delete it?"
read -p "you wanna yeetus feetus deletus? y/n " answer
if [ "$answer" == "y" ]; then
echo "deleting your life jk jk deleting the directory"
rm -rf ~/ruby-proxy
else
echo "go bad bitch i guess"
exit
fi
else
echo "creating da directory ruby-proxy"
mkdir ~/ruby-proxy
fi
# clone program git into fodler ... maybe add option to skip this lol
if [ ! -d ~/ruby-proxy/ruby-rewrite-proxy ]; then
echo "commiting piracy and downloading da hackz"
git clone https://adastra7.net/git/crt/ruby-rewrite-proxy.git ~/ruby-proxy
fi
# goofy ah ask user to set nginx proxy stuff
read -p "Enter the sexy server_name (the URL from which you will access the Website): " server_name
if [ ! -f /etc/nginx/sites-available/ruby-proxy ]; then
echo "breaking nginx cutely"
sudo tee /etc/nginx/sites-available/ruby-proxy > /dev/null <<EOF
resolver 8.8.8.8;
server {
listen 80;
server_name $server_name;
location / {
proxy_pass http://localhost:8000/;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_ssl_server_name on;
proxy_ssl_verify off;
}
location /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
location /robots.txt {
return 200 "User-agent: *\nDisallow: /";
access_log off;
log_not_found off;
}
}
EOF
fi
# enable the disfunction of being braindead i wanna die die die
if [ ! -f /etc/nginx/sites-enabled/ruby-proxy ]; then
echo "Enabling the site..."
sudo ln -s /etc/nginx/sites-available/ruby-proxy /etc/nginx/sites-enabled/
fi
# Reload Nginx to apply the changes
echo "seeing if nginx breaks"
sudo systemctl reload nginx
echo "The script has completed. Please commit arson on tbz now"