#!/bin/bash # Installing dependencies sudo apt install -y git nginx fcgiwrap cgit # Git ## Creating and setting up user sudo adduser git ## Setting up ssh mkdir .ssh && chmod 700 .ssh echo "DONT FORGET TO ADD YOUR SSH KEYS TO ~/.ssh/authorized_keys AND CHMOD 600 IT" ## Configuring git sudo mkdir -p /srv/git sudo -H chown git:git /srv/git/ # Cgit sudo -H cp -rf cgitrc /etc/ sudo -H cp -rf cgit /usr/share/ # Nginx sudo -H mkdir -p /etc/nginx/certs sudo -H cp -rf nginx/ /etc/ sudo -H ln -s /etc/nginx/sites-available/server /etc/nginx/sites-enabled/server sudo -H sed -i s:"$(grep access_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf sudo -H sed -i s:"$(grep error_log /etc/nginx/nginx.conf | awk '{print $2}' )":\/dev\/null\;:g /etc/nginx/nginx.conf # SSL openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") sudo mv localhost.* /etc/nginx/certs # Restarting services sudo -H systemctl restart nginx sudo -H systemctl enable nginx