Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Admin guide

libertysoft3 edited this page May 10, 2022 · 7 revisions

Updating configuration

Override or set any example.ini setting in development.update. (Changes to section [live_config] can be applied with reddit-flush rather than reddit-restart.)

Ubuntu 14 edition

# ssh into your reddit server
$ cd ~/src/reddit/r2
$ nano development.update
$ make ini
$ sudo reddit-restart

Docker edition

# ssh into your docker host server
# find the name of your reddit_r2_data named volume, if your username is dev, it should be dev_reddit_r2_data
$ docker volume ls
# inspect the volume to find the mountpoint
$ docker volume inspect dev_reddit_r2_data
# edit the configuration file at the mountpoint with sudo, e.g.:
$ sudo nano /var/lib/docker/volumes/dev_reddit_r2_data/_data/development.update
# find the name of the reddit app container, e.g. dev_reddit_1
$ docker ps | grep _reddit
# rebuild the configuration ini files in the container
$ docker exec dev_reddit_1 bash -c 'cd /home/reddit/src/reddit/r2 && make ini'
# restart reddit app
$ docker exec dev_reddit_1 bash -c 'pkill gunicorn_paster && pkill wrap-job'
$ docker exec dev_reddit_1 bash -c 'supervisorctl start gunicorn'

Rebuilding CSS and static assets

For production environments where uncompressedJS = false.

$ cd ~/src/reddit/r2
$ ./refresh-css.sh

Or for the Docker edition:

# find the name of the reddit app container, e.g. dev_reddit_1
$ docker ps | grep _reddit
# connect to a bash shell in your running container, e.g.:
$ docker exec -it dev_reddit_1 bash
# now inside of the container, run
$ cd ~/src/reddit/r2
$ sudo -u reddit make build/mangle-buildstamp
$ sudo -u reddit make clean_css
$ sudo -u reddit make css
# restart reddit app (from shell running inside container)
$ pkill gunicorn_paster && pkill wrap-job
$ supervisorctl start gunicorn

Set the default subs

$ cd ~/src/reddit/r2
$ paster shell run.ini
# paste the following, hit enter:
from r2.models import *
srs = [Subreddit._by_name(n) for n in ("pics", "videos", "science", "technology")]
LocalizedDefaultSubreddits.set_global_srs(srs)
LocalizedFeaturedSubreddits.set_global_srs([Subreddit._by_name('pics')])
exit()

Use a custom domain

Rather than accessing the site/app at https://reddit.local you can use your own domain. Change the configuration values for domain and oauth_domain in the main configuration file, src/reddit/r2/development.update. You should also update your SSL certificate accordingly, see the next section.

Certbot/LetsEncrypt SSL Certificates

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot
$ sudo certbot certonly --manual --preferred-challenges dns -d you.net -d www.you.net -d m.you.net -d oauth.you.net
$ sudo usermod -aG ssl-cert reddit
$ sudo usermod -aG ssl-cert irc
$ sudo chown -h reddit:ssl-cert /etc/letsencrypt/live/you.net/privkey.pem
$ sudo chmod g+r /etc/letsencrypt/live/you.net/privkey.pem

Re-configure your services for your new cert:

/etc/nginx/sites-available/reddit-ssl
/etc/reddit/.lounge/config.js
/unrealircd/conf/unrealircd.conf

Renew your cert every 90 days:

$ sudo certbot renew
Clone this wiki locally