mirror of
https://github.com/thedrewen/protojx-manager.git
synced 2026-03-21 09:48:56 +01:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ec7187afd | |||
| 2aa5c56ca7 | |||
| 7b35fcf31b | |||
| a5476b26fe | |||
| c99c11c241 | |||
| df048c1352 | |||
| 290e8b982a | |||
| 8bfeb1c43c | |||
| e2a8255d5a | |||
| 85ec27cb2b | |||
| e2c896c6f1 | |||
| 3ff4278217 | |||
| 7b80aca9e1 | |||
| afd8d1f68a | |||
| c571e03495 | |||
| a577f99277 | |||
| 4b6b2c8575 | |||
| e375fb2631 | |||
| 39178d1322 | |||
| d7b772544f | |||
| 27fc82d371 |
@@ -19,3 +19,7 @@ DB_LOGGING=false
|
||||
|
||||
# Environment
|
||||
NODE_ENV=development
|
||||
|
||||
# Protected IPS
|
||||
PROTOJX_ROUTER_1=
|
||||
PROTOJX_ROUTER_2=
|
||||
52
.github/workflows/deploy.yml
vendored
Normal file
52
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
name: Deploy
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup SSH Agent
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
|
||||
- name: Add VPS to known_hosts
|
||||
run: |
|
||||
ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy to VPS
|
||||
run: |
|
||||
ssh -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
|
||||
cd /home/${{ secrets.VPS_USER }}/protojx/protojx-manager &&
|
||||
git pull &&
|
||||
|
||||
# Stop and remove old container if exists
|
||||
docker stop protojx_manager 2>/dev/null || true &&
|
||||
docker rm protojx_manager 2>/dev/null || true &&
|
||||
|
||||
# Build new image
|
||||
docker buildx build -t protojx_manager . &&
|
||||
|
||||
# Run new container
|
||||
docker run -d \
|
||||
--name protojx_manager \
|
||||
--restart unless-stopped \
|
||||
--network shared \
|
||||
protojx_manager
|
||||
"
|
||||
@@ -7,4 +7,6 @@ COPY . .
|
||||
RUN apt-get update && apt-get install -y iputils-ping
|
||||
RUN npm i
|
||||
|
||||
# RUN npm run register
|
||||
|
||||
CMD [ "npm", "run", "start" ]
|
||||
@@ -1,4 +1,4 @@
|
||||
# Protojx Manager Non Official
|
||||
# Protojx Manager
|
||||
A status bot and other features for protojx.
|
||||
|
||||
- Add the bot : https://discord.com/oauth2/authorize?client_id=1432680068085190656
|
||||
@@ -12,8 +12,8 @@ A status bot and other features for protojx.
|
||||
| Number of services down in the bot's status. | 🌐 |
|
||||
| Notification system in case of downtime. | 🌐 |
|
||||
| Ability to create persistent status messages that update automatically. (/live_status) | 🌐 |
|
||||
| Deployment workflow on Oracle VPS. | ➖ |
|
||||
| Filter for notifs. | ✅ |
|
||||
| Deployment workflow on Oracle VPS. | 🌐 |
|
||||
| Filter for notifs. | 🌐 |
|
||||
|
||||
- 🌐 -> In production
|
||||
- ✅ -> Done
|
||||
|
||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@types/ping": "^0.4.4",
|
||||
"cron": "^4.3.3",
|
||||
"dayjs": "^1.11.19",
|
||||
"discord.js": "^14.24.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"pg": "^8.16.3",
|
||||
@@ -552,9 +553,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dayjs": {
|
||||
"version": "1.11.18",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.18.tgz",
|
||||
"integrity": "sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==",
|
||||
"version": "1.11.19",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
|
||||
"integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"dependencies": {
|
||||
"@types/ping": "^0.4.4",
|
||||
"cron": "^4.3.3",
|
||||
"dayjs": "^1.11.19",
|
||||
"discord.js": "^14.24.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"pg": "^8.16.3",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplicationIntegrationType, ChannelType, ContainerBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
|
||||
import { ApplicationIntegrationType, ChannelType, ContainerBuilder, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
import { CommandDefinition } from "../../type";
|
||||
import statusService from "../../services/status.service";
|
||||
import { AppDataSource } from "../../data-source";
|
||||
@@ -16,7 +16,8 @@ const cmd : CommandDefinition = {
|
||||
)
|
||||
.setIntegrationTypes(
|
||||
ApplicationIntegrationType.GuildInstall
|
||||
),
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({flags: [MessageFlags.Ephemeral]});
|
||||
|
||||
@@ -25,7 +26,13 @@ const cmd : CommandDefinition = {
|
||||
const channel = await interaction.guild?.channels.fetch(channel_options?.id);
|
||||
|
||||
if(channel?.isSendable()) {
|
||||
const message = await channel.send({components: [statusService.getUpdatedContainer(true)], flags: [MessageFlags.IsComponentsV2]});
|
||||
let message;
|
||||
try {
|
||||
message = await channel.send({components: [statusService.getUpdatedContainer(true)], flags: [MessageFlags.IsComponentsV2]});
|
||||
} catch (error) {
|
||||
await interaction.editReply({content: 'An error has occurred. Please check the permissions for the channel.'});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const guildRepo = AppDataSource.getRepository(Guild);
|
||||
|
||||
@@ -86,6 +86,9 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
|
||||
client.once(Events.ClientReady, readyClient => {
|
||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||
client.guilds.cache.forEach((value) => {
|
||||
console.log(`${value.name} conf loaded !`);
|
||||
});
|
||||
statusService.setClient(client);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { HostsLog } from "../entity/hostslog.entity";
|
||||
import { Repository } from "typeorm";
|
||||
import { Follow } from "../entity/follow.entity";
|
||||
import { Guild } from "../entity/guild.entity";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
type Nofity = {time: Date, name : string, alive : boolean, type : InfraType, host: string};
|
||||
|
||||
@@ -14,16 +15,16 @@ export class StatusService {
|
||||
|
||||
public hosts: Host[] = [
|
||||
{
|
||||
'host': 'https://protojx.com',
|
||||
'name': 'Protojx Website',
|
||||
host: 'https://protojx.com',
|
||||
name: 'Protojx Website',
|
||||
alive: false,
|
||||
ping_type: 'website',
|
||||
type: 'website',
|
||||
notify: false
|
||||
},
|
||||
{
|
||||
'host': 'https://manager.protojx.com',
|
||||
'name': 'Espace Client',
|
||||
host: 'https://manager.protojx.com',
|
||||
name: 'Espace Client',
|
||||
alive: false,
|
||||
ping_type: 'website',
|
||||
type: 'website',
|
||||
@@ -93,6 +94,14 @@ export class StatusService {
|
||||
type: 'games',
|
||||
notify: true
|
||||
},
|
||||
{
|
||||
host: '5.178.99.17',
|
||||
name: 'RYZEN-GAME 02',
|
||||
alive: false,
|
||||
ping_type: 'ping',
|
||||
type: 'games',
|
||||
notify: true
|
||||
},
|
||||
{
|
||||
host: '5.178.99.63',
|
||||
name: 'XEON-GAME 01',
|
||||
@@ -100,6 +109,23 @@ export class StatusService {
|
||||
ping_type: 'ping',
|
||||
type: 'games',
|
||||
notify: true
|
||||
},
|
||||
// Routers
|
||||
{
|
||||
host: process.env.PROTOJX_ROUTER_1 as string,
|
||||
name: 'ROUTER-FR 01',
|
||||
alive: false,
|
||||
ping_type: 'ping',
|
||||
type: 'router',
|
||||
notify: false
|
||||
},
|
||||
{
|
||||
host: process.env.PROTOJX_ROUTER_2 as string,
|
||||
name: 'ROUTER-FR 02',
|
||||
alive: false,
|
||||
ping_type: 'ping',
|
||||
type: 'router',
|
||||
notify: false
|
||||
}
|
||||
];
|
||||
|
||||
@@ -285,6 +311,11 @@ export class StatusService {
|
||||
title: 'Games',
|
||||
type: 'games',
|
||||
thumbnail: 'https://protojx.com/assets/img/hero-img.png'
|
||||
},
|
||||
{
|
||||
title: 'Routers\n-# *The data displayed here is not real data but demonstration data. (Beta)*',
|
||||
type: 'router',
|
||||
thumbnail: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRMnCmtQRkLlcD1Cb6vKXz6NOxAu79vzmq2pRqpNYxpTJa5JQEsouhqnVn7cyl6ivYSyzY&usqp=CAU'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -303,8 +334,9 @@ export class StatusService {
|
||||
)
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
container.addTextDisplayComponents((text) => text.setContent(`${live ? 'Last update : ' : ''}${now.getDate()}-${now.getMonth() + 1}-${now.getFullYear()} ${(now.getHours() + '').padStart(2, "0")}:${(now.getMinutes() + '').padStart(2, "0")} - Receive automatic notifications when there is an outage with /follow !`));
|
||||
container.addSeparatorComponents((s) => s);
|
||||
|
||||
container.addTextDisplayComponents((text) => text.setContent(`:globe_with_meridians: Website Status : https://statut.protojx.com/\n${live ? 'Last update : ' : ''}<t:${dayjs().unix()}:f> - Receive automatic notifications when there is an outage with /follow !`));
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
2
src/type.d.ts
vendored
2
src/type.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
import { ButtonInteraction, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
export type InfraType = 'website' | 'ryzen' | 'xeon' | 'games';
|
||||
export type InfraType = 'website' | 'ryzen' | 'xeon' | 'games' | 'router';
|
||||
export type Host = {
|
||||
host: string,
|
||||
name: string,
|
||||
|
||||
Reference in New Issue
Block a user