summaryrefslogtreecommitdiff
path: root/cgit/deploy
blob: e2fbe92cae4af8e1356b2767d27b0ec2f5517404 (plain)
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
#!/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