In the Stockholm Student Housing (SSSB), the laundry rooms are booked through a website. The website is slow, and the booking process is cumbersome. This project aims to simplify the booking process by automatically scraping the website and sending calendar invites to the users, allowing them to book the laundry room directly from their calendar.
Monthly View | Daily View | Laundry Time | Website Booking |
---|---|---|---|
⚠️ This project is badly packaged: The deployment process is very ad-hoc for my purposes. It will probably not work out of the box for you.
Create a new project in the Google Developer Console.
Add the credentials as a credentials.json
in the root directory.
Set the ROOT_URL
variable in src/constants.ts
, which is used to generate the calendar invite links back to your web server.
Add the following values to a .env
file in the root directory:
HTTP_USERNAME=MY_USERNAME
HTTP_PASSWORD=MY_PASSWORD
SQLITE_FILE=./db.sqlite
The HTTP username and password is used with HTTP Basic Auth to protect the laundry booking page.
Create a new Google account to use as an invite sender. This account will be used to send invites to the users.
export const USERS: User[] = [
{
rentalId: "1234-5678-910",
preferedGroups: [42, 43, 44, 45, 46, 47, 48],
mainEmail: "google.calendar.inviter.email@gmail.com",
inviteEmails: ["this.is.your.email@gmail.com", "and.your.roommates@gmail.com"],
lookahead: 5, // How many weeks to look ahead
}
]
Run yarn update <user-rental-id>
to be prompted a single time to log in to the primary calendar email.
This will create a certificate in the certs/
directory.
Example git post-receive hook deployment script:
#!/bin/bash
deployDir="/home/user/builds/tvatt"
rm -rf $deployDir &&
mkdir $deployDir || exit
echo "Checkout out master"
export GIT_WORK_TREE=$deployDir
export GIT_DIR=$(pwd)
git checkout -f master
cd $deployDir
echo "Building"
docker build -t tvatt . || exit
echo "Shutting down old"
DATE=$(date +"%Y-%m-%d %T")
echo "[SHUTTING DOWN OLD INSTANCE: $DATE]" >> ~/logs/tvatt/out.log
docker stop tvatt-container
docker rm tvatt-container
echo "Running"
DATE=$(date +"%Y-%m-%d %T")
echo "[STARTING NEW INSTANCE: $DATE]" >> ~/logs/tvatt/out.log
nohup docker run --restart=always \
-p 5100:80 \
-e SQLITE_FILE='/logs/db.sqlite' \
-v ~/logs/tvatt:/logs \
--name tvatt-container \
-t tvatt &>>~/logs/tvatt/out.log &
echo "Done"
start
runs the main server
update
book
update:day