Skip to content

Commit

Permalink
Rename the deploy/ directory to run/
Browse files Browse the repository at this point in the history
  • Loading branch information
mherrmann committed Nov 14, 2023
1 parent 0f4c7f6 commit 4c4e52c
Show file tree
Hide file tree
Showing 34 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A private winget repository server written in Python. For an overview of the
project and its features, please see https://winget.pro.

If you are here, then you probably want to run winget.pro yourself. Please see
the [`deploy/`](deploy) directory for instructions.
the [`run/`](run) directory for instructions.

Do you need help or did you encounter an issue? Please
[file an issue](https://github.com/omaha-consulting/winget.pro/issues). We will
Expand Down
2 changes: 1 addition & 1 deletion bin/desk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cd "$PROJECT_DIR"
source venv/bin/activate

alias shell='python manage.py shell'
alias release="ssh [email protected] '/srv/deploy/vps/bin/git-update.sh'"
alias release="ssh [email protected] '/srv/run/vps/bin/git-update.sh'"
alias migrate="python manage.py migrate"
alias makemigrations="python manage.py makemigrations"
alias tests='python manage.py test'
Expand Down
8 changes: 4 additions & 4 deletions deploy/README.md → run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

This directory contains files for running winget.pro in various environments:

* [`local/`](local) contains files for running locally. The instructions there
are typically followed during development.
* [`local/`](local) contains files for running on your own PC. The instructions
there are typically followed during development.
* [`docker/`](docker) lets you run winget.pro via Docker. This has the benefit
that it works in all environments where Docker is available.
* [`vps/`](vps) runs winget.pro on a single Linux VPS. This imposes stricter
requirements on the environment (namely, that it is a stock Debian server
without any customizations). But it has the advantage that it is the most
direct to operate.
without any customizations). But it has the advantage that all that's
required to do maintenance is to SSH into the server.
File renamed without changes.
4 changes: 2 additions & 2 deletions deploy/docker/Dockerfile → run/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ RUN python manage.py collectstatic --noinput

EXPOSE 8000

RUN chmod +x /srv/deploy/docker/start.sh
RUN chmod +x /srv/run/docker/start.sh

CMD ["/srv/deploy/docker/start.sh"]
CMD ["/srv/run/docker/start.sh"]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
django:
build:
context: ../..
dockerfile: deploy/docker/Dockerfile
dockerfile: run/docker/Dockerfile
volumes:
- static:/srv/static
- media:/srv/media
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions deploy/vps/bin/git-update.sh → run/vps/bin/git-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cd /srv
git pull
venv/bin/pip install -U pip | grep -v "^Requirement already satisfied"
venv/bin/pip install -Ur requirements/base-full.txt | grep -v "^Requirement already satisfied"
su -c '/srv/deploy/vps/bin/manage.sh migrate | grep -v "INFO\|DEBUG"' - django
su -c '/srv/deploy/vps/bin/manage.sh collectstatic --noinput | grep -v "INFO\|DEBUG"' - django
su -c '/srv/run/vps/bin/manage.sh migrate | grep -v "INFO\|DEBUG"' - django
su -c '/srv/run/vps/bin/manage.sh collectstatic --noinput | grep -v "INFO\|DEBUG"' - django

echo `date +%H:%M:%S`': Reloading web server...'

Expand All @@ -18,4 +18,4 @@ nginx -s reload
echo `date +%H:%M:%S`': Web server reload complete.'

# Update crontab:
sed "s/\$ADMIN_EMAIL/$ADMIN_EMAIL/g" /srv/deploy/vps/conf/crontab | crontab -
sed "s/\$ADMIN_EMAIL/$ADMIN_EMAIL/g" /srv/run/vps/conf/crontab | crontab -
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion deploy/vps/conf/crontab → run/vps/conf/crontab
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAILTO=$ADMIN_EMAIL
@reboot /srv/deploy/vps/bin/init-run-dir.sh
@reboot /srv/run/vps/bin/init-run-dir.sh
# Enabled by install.sh when SSL certificates are managed by certbot:
#26 2 */7 * * cronic certbot renew
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:gunicorn]
command=/srv/deploy/vps/bin/with-bashrc.sh /srv/deploy/vps/bin/gunicorn.sh
command=/srv/run/vps/bin/with-bashrc.sh /srv/run/vps/bin/gunicorn.sh
directory=/srv
user=django
stdout_logfile=/var/log/gunicorn.log
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 18 additions & 18 deletions deploy/vps/install.sh → run/vps/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ then
log 'Cloning the repository...'
git clone -q -b ${GIT_REPO_BRANCH} git@${GIT_SERVER}:${GIT_REPO_NAME}.git /srv
else
if [ ! -d /srv/deploy ]
if [ ! -d /srv/run ]
then
log 'Error: Please place the server source code into /srv.'
exit 1
Expand All @@ -78,12 +78,12 @@ then
log 'Configuring Postfix...'
echo "$HOST_NAME" > /etc/mailname
chown postfix /etc/mailname
envsubst '$SMTP_HOST $HOST_NAME' < /srv/deploy/vps/conf/postfix/main.cf > /etc/postfix/main.cf
envsubst < /srv/deploy/vps/conf/postfix/sasl_passwd > /etc/postfix/sasl_passwd
envsubst '$SMTP_HOST $HOST_NAME' < /srv/run/vps/conf/postfix/main.cf > /etc/postfix/main.cf
envsubst < /srv/run/vps/conf/postfix/sasl_passwd > /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chmod 400 /etc/postfix/sasl_passwd
chown postfix /etc/postfix/sasl_passwd
envsubst < /srv/deploy/vps/conf/postfix/generic > /etc/postfix/generic
envsubst < /srv/run/vps/conf/postfix/generic > /etc/postfix/generic
postmap /etc/postfix/generic
chown postfix /etc/postfix/generic
/etc/init.d/postfix reload > /dev/null
Expand Down Expand Up @@ -111,9 +111,9 @@ chown django /home/django
chmod 700 /home/django

log 'Setting up bash profiles...'
ln -sf /srv/deploy/vps/conf/.bash_profile .
ln -sf /srv/deploy/vps/conf/.bash_profile /home/django
PATH='$PATH' /usr/bin/envsubst < /srv/deploy/vps/conf/django.bashrc > /home/django/.bashrc
ln -sf /srv/run/vps/conf/.bash_profile .
ln -sf /srv/run/vps/conf/.bash_profile /home/django
PATH='$PATH' /usr/bin/envsubst < /srv/run/vps/conf/django.bashrc > /home/django/.bashrc
chown django:django /home/django/.bashrc

log 'Creating data directory...'
Expand Down Expand Up @@ -142,19 +142,19 @@ log 'Installing Python dependencies...'
/srv/venv/bin/pip install -Ur /srv/requirements/base-full.txt > /dev/null

log 'Migrating database...'
su -c '/srv/deploy/vps/bin/manage.sh migrate | grep -v "INFO\|DEBUG"' - django
su -c '/srv/run/vps/bin/manage.sh migrate | grep -v "INFO\|DEBUG"' - django

log 'Collecting static files...'
su -c '/srv/deploy/vps/bin/manage.sh collectstatic --noinput | grep -v "INFO\|DEBUG"' - django
su -c '/srv/run/vps/bin/manage.sh collectstatic --noinput | grep -v "INFO\|DEBUG"' - django

log 'Initializing run/ directory...'
/srv/deploy/vps/bin/init-run-dir.sh
/srv/run/vps/bin/init-run-dir.sh

log 'Installing Supervisor...'
apt-get install supervisor -y > /dev/null

log 'Configuring Supervisor...'
ln -s /srv/deploy/vps/conf/gunicorn.conf /etc/supervisor/conf.d
ln -s /srv/run/vps/conf/gunicorn.conf /etc/supervisor/conf.d

log 'Starting services...'
supervisorctl reread > /dev/null
Expand All @@ -167,11 +167,11 @@ log 'Creating Nginx includes directory...'
mkdir /etc/nginx/includes

log 'Creating Nginx config...'
envsubst < /srv/deploy/vps/conf/nginx/server-name > /etc/nginx/includes/server-name
envsubst < /srv/run/vps/conf/nginx/server-name > /etc/nginx/includes/server-name
touch /etc/nginx/includes/ssl

log 'Applying Nginx config...'
ln -s /srv/deploy/vps/conf/nginx/nginx /etc/nginx/sites-available/django
ln -s /srv/run/vps/conf/nginx/nginx /etc/nginx/sites-available/django
ln -s /etc/nginx/sites-available/django /etc/nginx/sites-enabled/django
rm /etc/nginx/sites-enabled/default

Expand All @@ -197,23 +197,23 @@ else
fi

log 'Applying SSL config...'
ln -sf /srv/deploy/vps/conf/nginx/ssl /etc/nginx/includes/ssl
ln -sf /srv/run/vps/conf/nginx/ssl /etc/nginx/includes/ssl
service nginx restart

log "The server is now serving requests at $HOST_NAME$ALT_HOST_NAMES!"

# Now do less important things that are not required for serving requests:

log 'Setting up logrotate...'
ln -s /srv/deploy/vps/conf/logrotate /etc/logrotate.d/django
ln -s /srv/run/vps/conf/logrotate /etc/logrotate.d/django

log 'Setting up crontab...'
ln -s /srv/deploy/vps/bin/cronic /usr/bin/cronic
ln -s /srv/run/vps/bin/cronic /usr/bin/cronic
if [[ -n "$ADMIN_EMAIL" ]]
then
sed "s/\$ADMIN_EMAIL/$ADMIN_EMAIL/g" /srv/deploy/vps/conf/crontab > crontab
sed "s/\$ADMIN_EMAIL/$ADMIN_EMAIL/g" /srv/run/vps/conf/crontab > crontab
else
cp /srv/deploy/vps/conf/crontab crontab
cp /srv/run/vps/conf/crontab crontab
fi
if [[ -z "$SSL_CERTIFICATE" ]]
then
Expand Down

0 comments on commit 4c4e52c

Please sign in to comment.