Commit 8ef40ec5 authored by Michiel de Jong's avatar Michiel de Jong

add nginx-gitpuller

parent 5ae80497
......@@ -21,12 +21,13 @@ vagrant up
```
Wait for the provisioning to finish (~5mins), and go to your browser: https://indiehosters.dev
If the process fails, for instance due to network problems, you can retry by running `vagrant provision`.
### If you want to add another nginx instance apart from indiehosters.dev:
```bash
vagrant ssh
sh /data/indiehosters/scripts/activate-user.sh example.dev nginx
sudo sh /data/indiehosters/scripts/activate-user.sh example.dev nginx https://github.com/indiehosters/website-static.git
```
Check https://example.dev in your bowser!
......
#!/bin/bash
cd /data/per-user/$USER/nginx/data/www-content && git pull
#!/bin/bash
if [ ! -d "/data/per-user/$USER/nginx/data" ]; then
mkdir -p /data/per-user/$USER/nginx/data/www-content
echo Hello $USER > /data/per-user/$USER/nginx/data/www-content/index.html
if [ ! -e "/data/per-user/$USER/nginx/data/www-content/index.html" ]; then
if [ -e "/data/per-user/$USER/nginx/data/git-url.txt" ]; then
git clone `cat /data/per-user/$USER/nginx/data/git-url.txt` /data/per-user/$USER/nginx/data/www-content
else
mkdir -p /data/per-user/$USER/nginx/data/www-content
echo Hello $USER > /data/per-user/$USER/nginx/data/www-content/index.html
fi
fi
#!/bin/bash -eux
# mkdir -p /data/per-user/$1/nginx/data
# if [ -e /data/per-user/$1/nginx/data/www-content ]; then
# cd /data/per-user/$1/nginx/data/www-content; git pull --rebase
# else
# git clone $3 /data/per-user/$1/nginx/data/www-content
# fi
if [ $# -ge 2 ]; then
DOMAIN=$1
IMAGE=$2
else
echo "Usage: sh /data/indiehosters/scripts/activate-user domain image [gitrepo]"
exit 1
fi
mkdir -p /data/per-user/$DOMAIN/nginx/data
if [ $# -ge 3 ]; then
GITREPO=$3
echo $GITREPO > /data/per-user/$DOMAIN/nginx/data/git-url.txt
fi
# Start service for new site (and create the user)
systemctl enable $2@$1.service
systemctl start $2@$1.service
# Start service for new site (and create the user). This will also enable the git puller.
systemctl enable $IMAGE@$DOMAIN.service
systemctl start $IMAGE@$DOMAIN.service
[Path]
PathExists=/data/per-user/%i/nginx/data/git-url.txt
[Unit]
Description=nginx git puller
# Dependency ordering
Before=nginx@%i.service
[Service]
Environment=USER=%i
ExecStart=/data/indiehosters/importers/nginx-updater.sh
[Install]
WantedBy=nginx@%i.service
[Unit]
Description=Run git puller every 10 minutes
[Timer]
OnUnitActiveSec=10min
[Install]
WantedBy=timers.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment