The script will require a VPS or VDS server with a minimum version of Ubuntu 20.04.6 LTS for stable operation of the program.
After authorization on the server, clone the repository to the /home
directory.
Install git:
sudo apt update && sudo apt upgrade
sudo apt install -y git
You can confirm that you have installed Git correctly by running the following command and checking that you receive relevant output.
git --version
Go to your home directory and clone the repository:
cd /home
git clone https://github.com/BLazzeD21/UMTE-Calendar.git
Check the version of node.js installed on the server:
node -v
If the version below v18.20.6 or node.js is not installed, then you need to install:
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Installing project dependencies and playwright:
cd UMTE-Calendar/
npm i && npx playwright install && npx playwright install-deps
In the UMTE-Calendar directory you need to create a .env
file containing the credentials for umeos.ru
UMTE_USERNAME=username
UMTE_PASSWORD=password
Using pm2 to run the script. PM2 is a daemon process manager that will help you manage and keep your application online.
The latest PM2 version is installable with NPM:
npm install pm2@latest -g
Action | Description | Command |
---|---|---|
Start Process | Run the application named UTME-schedule using the desired number of CPU cores specifying them after -i , if you want to use all cores use max instead of a number |
npm run start |
Script in package.json : |
"start": "npm run build && pm2 start build/index.js --name UMTE-schedule --time -i 1" |
|
Stop Process | Stop the running process | npm run stop |
Script in package.json : |
"stop": "pm2 stop UMTE-schedule" |
|
Reload Process | Reload the process without downtime | npm run reload |
Script in package.json : |
"reload": "pm2 reload UMTE-schedule" |
|
Delete Process | Remove the process from PM2 | npm run delete |
Script in package.json : |
"delete": "pm2 delete UMTE-schedule" |
Action | Description | Command |
---|---|---|
List Processes | Display all running processes | pm2 list |
Detailed Information | Show detailed information about the process | pm2 describe UMTE-schedule |
Real-Time Monitoring | Monitor system resources and processes in real-time | pm2 monit |
Action | Description | Command |
---|---|---|
View All Logs | Show all logs | pm2 logs |
View Process Logs | View logs for a specific process | pm2 logs UMTE-schedule |
View Errors | Show only error logs | pm2 logs --err |
Clear Logs | Clear all logs | pm2 flush |
Action | Description | Command |
---|---|---|
Enable Auto Start | Set up auto start for processes on server reboot | pm2 startup |
Save Process List | Save the current process list for auto start | pm2 save |
Action | Description | Command |
---|---|---|
Reload Single Process | Reload the process after code changes | pm2 reload UMTE-schedule |
Reload All Processes | Reload all running processes | pm2 reload all |
Now let's run the script:
npm run start
After running the script, a calendar.ics
file will appear in the /UMTE-Calendar/calendar
directory, which will contain a calendar that can be used for various purposes.
First, install nginx:
sudo apt install -y nginx
Create a symbolic link to the calendar.ics
file in a directory accessible to nginx. Run the following command:
sudo ln -s /home/UMTE-Calendar/calendar/calendar.ics /var/www/html/calendar.ics
Open the nginx configuration file for editing:
sudo nano /etc/nginx/sites-available/default
To serve then calendar.ics
file, you need to modify the configuration:
server {
listen 80;
server_name yourdomain.com; # Replace with your domain or IP address
location /calendar.ics {
root /var/www/html;
autoindex on;
}
}
Explanation of the configuration:
listen 80;
: Tells nginx to listen on port 80 (HTTP).server_name yourdomain.com;
: Replace yourdomain.com with your actual domain or IP address.location /calendar.ics { ... }
: This block tells nginx how to handle requests for the filecalendar.ics
.root /var/www/html;
: This specifies the root directory where nginx will look for files. Since we created a symbolic link earlier, nginx will find the filecalendar.ics
here.autoindex on;
: Enables directory listing, allowing you to see files in the directory if needed.
After making the changes, you need to save the file and exit nano:
- Press
Ctrl + O
to save the file. - Press
Enter
to confirm the file name. - Press
Ctrl + X
to exit the editor.
After modifying the configuration file, you must restart nginx to apply the changes:
sudo systemctl restart nginx
To check if nginx is serving the calendar.ics
file, use the curl command. Replace yourdomain.com
with your domain or IP address:
curl -o - -I http://yourdomain.com/calendar.ics
If the file is being served correctly, you will see this response. If the file isn't accessible, double-check that nginx is running, the configuration is correct, and that the file exists at /var/www/html/calendar.ics
.
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Now, the file calendar.ics
should be available at http://yourdomain.com/calendar.ics
.
If you want to secure Nginx with Let's Encrypt, follow these instructions.
The Telegram bot is disabled by default. To enable notifications, create a bot using @BotFather. You will receive a token to access the HTTP Telegram API. You will also need the CHAT_ID where the bot's messages will be sent, or the CHAT_ID and TOPIC_ID if you have topics enabled in the group.
Configuration data you must add to .env
.
TELEGRAM_BOT_TOKEN=Token from BotFather
CHAT_ID=Telegram chat ID
TOPIC_ID=Telegram chat topic ID
If you don't have any topics in your chat, don't add TOPIC_ID.
Important
In order for the bot to be able to send messages to the specified chat ID, it must be added to this chat.
After filling in .env
and adding the bot to the chat, the bot will work correctly and send messages every time the schedule changes.