Initial changes to integrate new portal
This commit is contained in:
parent
c4ffbb00e2
commit
0fa18af48e
18 changed files with 311 additions and 221 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# Using udev to mount newly attached usb drives doesn't work.
|
||||
# https://unix.stackexchange.com/a/507150/223286
|
||||
# So, we depend on udisks to mount the disk. *Then* we want to
|
||||
# to setup the symlink and lighttpd config with our script.
|
||||
# to setup the symlink.
|
||||
# We can run the script immediately because it waits for the disk
|
||||
# to be mounted.
|
||||
|
||||
|
|
|
|||
14
ansible/templates/butterbox-dendrite.service.j2
Normal file
14
ansible/templates/butterbox-dendrite.service.j2
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Dendrite Service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User={{ butter_user }}
|
||||
ExecStart=/home/{{ butter_user }}/dendrite/bin/dendrite --config /home/{{ butter_user }}/dendrite/butterbox-dendrite.conf -really-enable-open-registration
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
14
ansible/templates/butterbox-portal.service.j2
Normal file
14
ansible/templates/butterbox-portal.service.j2
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Portal Service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User={{ butter_user }}
|
||||
ExecStart=/bin/bash -c 'source /home/{{ butter_user }}/portal_env/bin/activate && cd /home/{{ butter_user }}/butter-portal && flask --app butter-portal.py run'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
22
ansible/templates/nginx-config.j2
Normal file
22
ansible/templates/nginx-config.j2
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name {{ butter_name }}.local;
|
||||
|
||||
location ^~ /chat {
|
||||
alias /var/www/html/chat;
|
||||
}
|
||||
|
||||
location ^~ /raspap {
|
||||
alias /var/www/html/raspap;
|
||||
}
|
||||
|
||||
location ^~ /_matrix {
|
||||
proxy_pass http://localhost:8008;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5000;
|
||||
}
|
||||
|
||||
}
|
||||
48
ansible/templates/on-usb-drive-mounted.sh.j2
Normal file
48
ansible/templates/on-usb-drive-mounted.sh.j2
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run by udev when a USB drive is inserted
|
||||
# usage: /usr/bin/on-usb-drive-mounted.sh /media/%k
|
||||
|
||||
# If the drive inserted contains a directory named "butter",
|
||||
# symlink it to /media/usb-butter
|
||||
device="$1"
|
||||
|
||||
# The device might not be mounted yet, so wait for it.
|
||||
usb_mount_path=""
|
||||
for ((i=0; i<10; i++)); do
|
||||
usb_mount_path=$(findmnt -n -o TARGET --source "$device")
|
||||
if [ -n "$usb_mount_path" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# findmnt will briefly return 1, so don't set e until we're done with it.
|
||||
set -e
|
||||
|
||||
if [ -z "$usb_mount_path" ]; then
|
||||
echo "Device $device is not mounted"
|
||||
exit 1
|
||||
else
|
||||
echo "Device $device mounted to: $usb_mount_path"
|
||||
fi
|
||||
|
||||
butter_dir="$usb_mount_path"
|
||||
served_dir="/media/usb-butter"
|
||||
|
||||
# make directory butter_dir world readable
|
||||
sudo chmod -R a+rx "$butter_dir"
|
||||
sudo chmod -R a+rx "/media/root/"
|
||||
|
||||
if [ -d "$butter_dir" ]; then
|
||||
# Delete served_dir if it exists
|
||||
if [ -L "$served_dir" ]; then
|
||||
sudo rm "$served_dir"
|
||||
fi
|
||||
echo "Linking $butter_dir to $served_dir"
|
||||
ln -sf "$butter_dir" "$served_dir"
|
||||
sudo chown -R {{ butter_user }}:{{ butter_user }} $served_dir
|
||||
else
|
||||
echo "No butter directory $butter_dir found on $device"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue