Skip to content

Instantly share code, notes, and snippets.

@DrEVILish
Last active April 20, 2024 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrEVILish/ce8a2bf9ca81c8f09ed5508e0480c856 to your computer and use it in GitHub Desktop.
Save DrEVILish/ce8a2bf9ca81c8f09ed5508e0480c856 to your computer and use it in GitHub Desktop.
#!/bin/bash
apt-get update
apt-get install -y jq git bind9 curl dnsutils nginx-full inotify-tools
git clone https://github.com/lancachenet/ubuntu-nginx
cp -r -a ubuntu-nginx/overlay/* /
chmod 777 /opt/nginx/startnginx.sh
rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
mkdir -p /etc/nginx/sites-enabled/
mkdir -p /etc/nginx/stream-enabled/
for SITE in /etc/nginx/sites-available/*; do [ -e "$SITE" ] || continue; ln -s $SITE /etc/nginx/sites-enabled/`basename $SITE`; done
for SITE in /etc/nginx/stream-available/*; do [ -e "$SITE" ] || continue; ln -s $SITE /etc/nginx/stream-enabled/`basename $SITE`; done
mkdir -p /var/www/html
chmod 777 /var/www/html /var/lib/nginx
chmod -R 777 /var/log/nginx
chmod -R 755 /hooks /init
chmod 755 /var/www
chmod -R 666 /etc/nginx/sites-* /etc/nginx/conf.d/* /etc/nginx/stream.d/* /etc/nginx/stream-*
cat <<EOF > /etc/environment
## See the "Settings" section in README.md for more details
## Set this to true if you're using a load balancer, or set it to false if you're using seperate IPs for each service.
## If you're using monolithic (the default), leave this set to true
USE_GENERIC_CACHE=true
## IP addresses that the lancache monolithic instance is reachable on
## Specify one or more IPs, space separated - these will be used when resolving DNS hostnames through lancachenet-dns. Multiple IPs can improve cache priming performance for some services (e.g. Steam)
## Note: This setting only affects DNS, monolithic and sniproxy will still bind to all IPs by default
LANCACHE_IP=192.168.10.114
## IP address on the host that the DNS server should bind to
DNS_BIND_IP=192.168.10.114
## DNS Resolution for forwarded DNS lookups
UPSTREAM_DNS="8.8.8.8 8.8.4.4"
## Storage path for the cached data
## Note that by default, this will be a folder relative to the docker-compose.yml file
CACHE_ROOT=./lancache
## Change this to customise the size of the disk cache (default 2000g)
## If you have more storage, you'll likely want to increase this
## The cache server will prune content on a least-recently-used basis if it
## starts approaching this limit.
## Set this to a little bit less than your actual available space
CACHE_DISK_SIZE=2000g
## Change this to allow sufficient index memory for the nginx cache manager (default 500m)
## We recommend 250m of index memory per 1TB of CACHE_DISK_SIZE
CACHE_INDEX_SIZE=500m
## Change this to limit the maximum age of cached content (default 3650d)
CACHE_MAX_AGE=3650d
## Set the timezone for the docker containers, useful for correct timestamps on logs (default Europe/London)
## Formatted as tz database names. Example: Europe/Oslo or America/Los_Angeles
TZ=Europe/London
########################
STEAMCACHE_DNS_VERSION=1
ENABLE_DNSSEC_VALIDATION=false
LANCACHE_DNSDOMAIN=cache.lancache.net
CACHE_DOMAINS_REPO=https://github.com/uklans/cache-domains.git
CACHE_DOMAINS_BRANCH=master
GENERICCACHE_VERSION=2
CACHE_MODE=monolithic
WEBUSER=www-data
CACHE_SLICE_SIZE=1m
BEAT_TIME=1h
LOGFILE_RETENTION=3560
NGINX_WORKER_PROCESSES=auto
NGINX_LOG_FORMAT=cachelog
EOF
git clone https://github.com/lancachenet/monolithic
git clone https://github.com/lancachenet/lancache-dns
cp -r -a monolithic/overlay/* /
cp -r -a lancache-dns/overlay/* /
rm /etc/nginx/sites-enabled/* /etc/nginx/stream-enabled/*
rm /etc/nginx/conf.d/gzip.conf
chmod 754 /var/log/tallylog
id -u www-data &> /dev/null || adduser --system --home /var/www/ --no-create-home --shell /bin/false --group --disabled-login www-data
chmod 755 /scripts/*
mkdir -m 755 -p /data/cache
mkdir -m 755 -p /data/info
mkdir -m 755 -p /data/logs
mkdir -m 755 -p /tmp/nginx/
chown -R www-data:www-data /data/
mkdir -p /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/10_cache.conf /etc/nginx/sites-enabled/10_generic.conf
ln -s /etc/nginx/sites-available/20_upstream.conf /etc/nginx/sites-enabled/20_upstream.conf
ln -s /etc/nginx/stream-available/10_sni.conf /etc/nginx/stream-enabled/10_sni.conf
mkdir -m 755 -p /data/cachedomains
mkdir -m 755 -p /tmp/nginx
git clone --depth=1 --no-single-branch https://github.com/uklans/cache-domains/ /data/cachedomains
mkdir -p /var/cache/bind /var/log/named
chown bind:bind /var/cache/bind /var/log/named
git clone --depth=1 --no-single-branch https://github.com/uklans/cache-domains/ /opt/cache-domains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment