Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
6db2c2d683 | |||
a9191e84a0 | |||
4a4e3d9614 | |||
66f45cae07 | |||
91186f29ff | |||
e148e79195 | |||
482ef99320 | |||
5ec8dec3e7 |
@@ -1,2 +1,3 @@
|
|||||||
volume/
|
volume/
|
||||||
|
config/
|
||||||
node_modules
|
node_modules
|
21
.gitignore
vendored
21
.gitignore
vendored
@@ -75,15 +75,19 @@ typings/
|
|||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
# next.js build output
|
# Next.js build output
|
||||||
.next
|
.next
|
||||||
|
|
||||||
# nuxt.js build output
|
# Nuxt.js build / generate output
|
||||||
.nuxt
|
.nuxt
|
||||||
|
dist
|
||||||
|
.vscode
|
||||||
|
|
||||||
# gatsby files
|
# Gatsby files
|
||||||
.cache/
|
.cache/
|
||||||
public
|
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
.vuepress/dist
|
.vuepress/dist
|
||||||
@@ -97,6 +101,11 @@ public
|
|||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
# custom .gitignore
|
docker-cache/
|
||||||
volume
|
assets/css/
|
||||||
|
assets/js/
|
||||||
|
assets/webp/
|
||||||
|
config/
|
@@ -14,16 +14,10 @@ artix-packy-pusher:
|
|||||||
script:
|
script:
|
||||||
- docker build --pull --no-cache -t "$CI_REGISTRY_IMAGE" .
|
- docker build --pull --no-cache -t "$CI_REGISTRY_IMAGE" .
|
||||||
|
|
||||||
artix-packy-exporter:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE:exporter" prometheus/
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
script:
|
script:
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
- docker push "$CI_REGISTRY_IMAGE"
|
- docker push "$CI_REGISTRY_IMAGE"
|
||||||
- docker push "$CI_REGISTRY_IMAGE:exporter"
|
|
47
Dockerfile
47
Dockerfile
@@ -1,22 +1,47 @@
|
|||||||
FROM gitea.artixlinux.org/artixdocker/artixlinux:base-devel
|
FROM artixlinux/artixlinux:devel as build-env
|
||||||
|
|
||||||
VOLUME /usr/volume
|
WORKDIR /usr/notifier
|
||||||
WORKDIR /usr/files
|
|
||||||
|
|
||||||
RUN pacman -Sy --noconfirm artools-pkg artix-checkupdates git nodejs npm cronie-openrc openssh icu glibc openssl openssl-1.1 &&\
|
RUN pacman -Sy --noconfirm nodejs npm
|
||||||
mkdir -p /root/.config/artools/ /root/.cache/ && \
|
|
||||||
ln -sf /usr/files/.cron /etc/cron.d/.cron
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN chmod 0644 ./* && \
|
RUN npm run-script build && \
|
||||||
chmod +x ./*.sh && \
|
npm ci --only=production
|
||||||
npm install
|
|
||||||
|
|
||||||
|
FROM artixlinux/artixlinux:devel as deploy
|
||||||
|
|
||||||
|
VOLUME /usr/notifier/config
|
||||||
|
WORKDIR /usr/notifier
|
||||||
|
HEALTHCHECK --timeout=15m \
|
||||||
|
CMD curl --fail http://localhost:8080/healthcheck || exit 1
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
RUN pacman -Sy --noconfirm curl artools-pkg artix-checkupdates git nodejs npm openssh icu glibc openssl openssl-1.1 &&\
|
||||||
|
mkdir -p /root/.config/artools/ /root/.cache/ && \
|
||||||
|
useradd -m artix
|
||||||
|
|
||||||
|
COPY --from=build-env /usr/notifier /usr/notifier
|
||||||
|
|
||||||
|
RUN mkdir -p ./config /home/artix/.config/artix-checkupdates \
|
||||||
|
/home/artix/.config/artools /home/artix/.cache/artix-checkupdates && \
|
||||||
|
ln -sf /usr/notifier/config/artools-pkg.conf /home/artix/.config/artools/artools-pkg.conf && \
|
||||||
|
ln -sf /usr/notifier/config/artix-checkupdates.conf /home/artix/.config/artix-checkupdates/config && \
|
||||||
|
chown -R artix:artix /home/artix/ && \
|
||||||
|
chown -R artix:artix .
|
||||||
|
|
||||||
|
USER artix
|
||||||
|
|
||||||
ENV CRON="*/30 * * * *"
|
|
||||||
ENV ARTIX_MIRROR="https://mirrors.qontinuum.space/artixlinux/%s/os/x86_64"
|
ENV ARTIX_MIRROR="https://mirrors.qontinuum.space/artixlinux/%s/os/x86_64"
|
||||||
ENV ARCH_MIRROR="https://mirrors.qontinuum.space/archlinux/%s/os/x86_64"
|
ENV ARCH_MIRROR="https://mirrors.qontinuum.space/archlinux/%s/os/x86_64"
|
||||||
ENV ARTIX_REPOS="system-goblins,world-goblins,galaxy-goblins,lib32-goblins,system-gremlins,world-gremlins,galaxy-gremlins,lib32-gremlins,system,world,galaxy,lib32"
|
ENV ARTIX_REPOS="system-goblins,world-goblins,galaxy-goblins,lib32-goblins,system-gremlins,world-gremlins,galaxy-gremlins,lib32-gremlins,system,world,galaxy,lib32"
|
||||||
ENV ARCH_REPOS="core-staging,extra-staging,multilib-staging,core-testing,extra-testing,multilib-testing,core,extra,multilib"
|
ENV ARCH_REPOS="core-staging,extra-staging,multilib-staging,core-testing,extra-testing,multilib-testing,core,extra,multilib"
|
||||||
|
ENV GITEA_TOKEN="CHANGEME"
|
||||||
|
|
||||||
CMD ./startup.sh
|
CMD [ "node", "index.js"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Cory Sanin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
65
README.md
65
README.md
@@ -1,25 +1,58 @@
|
|||||||
# artix-packy-notifier
|
# artix-packy-notifier
|
||||||
|
|
||||||
Notify me when one of my packages needs maintaining
|
Notification system and web frontend for Artix packages with pending operations. Notifications can be sent via
|
||||||
|
[Apprise](https://github.com/caronc/apprise/wiki#notification-services) or IRC. Web interface shows all packages with pending operations
|
||||||
|
and publishes prometheus metrics.
|
||||||
|
|
||||||
mount a folder to `/usr/volume`.
|
## configuration
|
||||||
|
|
||||||
Inside the volume, create a `packages.json` with the following schema:
|
create `config/config.json`:
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
|-----------------|-----------------------------------------------------------------------------------------------------------------------|
|
|-----------------|-----------------------------------------------------------------------------------------------------------------------|
|
||||||
| PREVIOUS | The path to store the generated list of actionable packages. Defaults to `previous.json` in the mounted volume. |
|
| apprise | The URL of the Apprise instance for sending notifications |
|
||||||
| packages | An array of packages to look for pending operations for. |
|
| maintainers | Array of maintainer names as strings or objects containing the `name` of the maintainer and a list of `channels` to send notifications to |
|
||||||
| writeAllPending | Boolean. If all pending packages should be included in the PREVIOUS file. Provided as `allPackages` and `allMovable`. |
|
| cron | The cron schedule for when the application should check for pending operations via [artix-checkupdates](https://gitea.artixlinux.org/artix/artix-checkupdates) |
|
||||||
| apprise.api | The url of the Apprise server to use for sending notifications. For example, "http://192.168.1.123:8000" |
|
| syncfreq | How often (in days) should the application sync package ownership from Gitea |
|
||||||
| apprise.urls | An array of Apprise destination URLs to deliver notifications to. For example, "tgram://bot-token/chat-id" |
|
| port | What port to run the webserver on (defaults to 8080) |
|
||||||
|
| savePath | Location of auxiliary save data (defaults to `config/data.db`) |
|
||||||
|
| db | Location of the SQLite DB (defaults to `config/packages.db`) |
|
||||||
|
| irc-framework | The options to feed into [irc-framework](https://github.com/kiwiirc/irc-framework/blob/master/docs/clientapi.md) |
|
||||||
|
| ircClient | Auxilary config data for the IRC bot. For now, it takes `ircClient.channel` and optionally `ircClient.channel_key` |
|
||||||
|
|
||||||
The following environment variables should be supplied.
|
Note that the IRC bot needs to be exempt from excess flooding. The following command permanently voices a bot on Libera.chat:
|
||||||
|
```
|
||||||
|
/msg ChanServ FLAGS #example artix-update-bot +V
|
||||||
|
```
|
||||||
|
If the channel is intended only for the bot to broadcast, consider setting the channel mode to "moderated":
|
||||||
|
```
|
||||||
|
/mode +m #example
|
||||||
|
```
|
||||||
|
|
||||||
| Variable | Description |
|
## How to run
|
||||||
|--------------|--------------------------------------------|
|
|
||||||
| CRON | The cron schedule for checking for updates |
|
```
|
||||||
| ARTIX_MIRROR | The Artix mirror to use |
|
npm install
|
||||||
| ARCH_MIRROR | The Arch mirror to use |
|
node index.js
|
||||||
| ARTIX_REPOS | The Artix repos to check |
|
```
|
||||||
| ARCH_REPOS | The Arch repos to check |
|
|
||||||
|
## Docker Setup
|
||||||
|
|
||||||
|
Image : `registry.gitlab.com/sanin.dev/artix-packy-notifier`
|
||||||
|
|
||||||
|
mount a folder to `/usr/notifier/config`.
|
||||||
|
|
||||||
|
Include a `config.json` as described above.
|
||||||
|
|
||||||
|
Include `artools-pkg.conf`:
|
||||||
|
```
|
||||||
|
GIT_TOKEN='YOUR-GITEA-TOKEN-HERE'
|
||||||
|
```
|
||||||
|
|
||||||
|
Include `artix-checkupdates.conf`:
|
||||||
|
```
|
||||||
|
ARTIX_MIRROR=https://example.com/%s/os/x86_64
|
||||||
|
ARCH_MIRROR=https://example.com/%s/os/x86_64
|
||||||
|
ARTIX_REPOS=system-goblins,world-goblins,galaxy-goblins,lib32-goblins,system-gremlins,world-gremlins,galaxy-gremlins,lib32-gremlins,system,world,galaxy,lib32
|
||||||
|
ARCH_REPOS=core-staging,extra-staging,multilib-staging,core-testing,extra-testing,multilib-testing,core,extra,multilib
|
||||||
|
```
|
26
assets/svg/artix_logo.svg
Normal file
26
assets/svg/artix_logo.svg
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 46.725 46.725"><script xmlns=""/>
|
||||||
|
<script/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient xlink:href="#a" id="h" x1="70.513" x2="63.044" y1="62.847" y2="59.204" gradientTransform="matrix(-1 0 0 1 114.837 50.597)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
<linearGradient id="a">
|
||||||
|
<stop offset="0" stop-color="#fff" stop-opacity=".365"/>
|
||||||
|
<stop offset="1" stop-color="#fff" stop-opacity="0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient xlink:href="#a" id="g" x1="70.513" x2="55.281" y1="62.847" y2="56.394" gradientTransform="translate(-21.061 67.885)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
<linearGradient xlink:href="#b" id="f" x1="70.725" x2="81.158" y1="12.292" y2="19.324" gradientTransform="translate(-11.754 126.585)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
<linearGradient id="b">
|
||||||
|
<stop offset="0" stop-opacity=".102"/>
|
||||||
|
<stop offset="1" stop-opacity=".304"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient xlink:href="#b" id="e" x1="70.725" x2="87.092" y1="12.292" y2="26.895" gradientTransform="translate(-26.4 101.152)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
<linearGradient xlink:href="#b" id="d" x1="105.834" x2="80.209" y1="15.354" y2="30.531" gradientTransform="translate(-56.383 115.378)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
<linearGradient xlink:href="#a" id="c" x1="75.543" x2="81.2" y1="145.986" y2="143.227" gradientTransform="translate(-16.572 -7.109)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
</defs>
|
||||||
|
<path class="artix-logo-base" fill="#10a0cc" stroke-width=".1" d="m23.362 0-8.034 16.474 22.112 12.39zM12.901 21.45.574 46.726l36.578-15.111zm26.955 12.368L28.32 40.441l17.832 6.284z"/>
|
||||||
|
<path fill="url(#c)" stroke-width=".265" d="m58.971 138.877 4.138-5.876 6.295 12.908z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
<path fill="url(#d)" stroke-width=".265" d="m23.826 145.909 25.626-15.177 10.952.065z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
<path fill="url(#e)" stroke-width=".265" d="m60.693 128.047-22.112-12.39 5.744-2.213z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
<path fill="url(#f)" stroke-width=".265" d="m69.404 145.909-17.831-6.284 7.398-.748z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
<path fill="url(#g)" stroke-width=".265" d="m23.826 145.909 25.626-15.177-13.3-10.098z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
<path fill="url(#h)" stroke-width=".265" d="m60.693 128.047-16.368-14.603 2.29-14.26z" transform="translate(-23.253 -99.183)"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
169
build.js
Normal file
169
build.js
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
/**
|
||||||
|
* Writing this myself because gulp has a billion garbage dependencies
|
||||||
|
* and webpack sucks poop through a straw. Everyone is stupid.
|
||||||
|
*/
|
||||||
|
const fsp = require('fs').promises;
|
||||||
|
const path = require('path');
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
const sass = require('sass');
|
||||||
|
const csso = require('csso');
|
||||||
|
const uglifyjs = require("uglify-js");
|
||||||
|
|
||||||
|
const STYLESDIR = 'styles';
|
||||||
|
const SCRIPTSDIR = 'scripts';
|
||||||
|
const IMAGESDIR = path.join('assets', 'images');
|
||||||
|
const STYLEOUTDIR = process.env.STYLEOUTDIR || path.join(__dirname, 'assets', 'css');
|
||||||
|
const SCRIPTSOUTDIR = process.env.SCRIPTSOUTDIR || path.join(__dirname, 'assets', 'js');
|
||||||
|
const IMAGESOUTDIR = process.env.IMAGESOUTDIR || path.join(__dirname, 'assets', 'webp');
|
||||||
|
const STYLEOUTFILE = process.env.STYLEOUTFILE || 'styles.css';
|
||||||
|
const SQUASH = new RegExp('^[0-9]+-');
|
||||||
|
|
||||||
|
async function emptyDir(dir) {
|
||||||
|
await Promise.all((await fsp.readdir(dir, { withFileTypes: true })).map(f => path.join(dir, f.name)).map(p => fsp.rm(p, {
|
||||||
|
recursive: true,
|
||||||
|
force: true
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mkdir(dir) {
|
||||||
|
if (typeof dir === 'string') {
|
||||||
|
await fsp.mkdir(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await Promise.all(dir.map(mkdir));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process styles
|
||||||
|
async function styles() {
|
||||||
|
await mkdir([STYLEOUTDIR, STYLESDIR]);
|
||||||
|
await await emptyDir(STYLEOUTDIR);
|
||||||
|
let styles = [];
|
||||||
|
let files = await fsp.readdir(STYLESDIR);
|
||||||
|
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||||
|
let p = path.join(STYLESDIR, f);
|
||||||
|
console.log(`Processing style ${p}`);
|
||||||
|
let style = sass.compile(p).css;
|
||||||
|
if (f.charAt(0) !== '_') {
|
||||||
|
if (SQUASH.test(f)) {
|
||||||
|
styles.push(style);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let o = path.join(STYLEOUTDIR, f.substring(0, f.lastIndexOf('.')) + '.css');
|
||||||
|
await fsp.writeFile(o, csso.minify(style).css);
|
||||||
|
console.log(`Wrote ${o}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res(0);
|
||||||
|
})));
|
||||||
|
let out = csso.minify(styles.join('\n')).css;
|
||||||
|
let outpath = path.join(STYLEOUTDIR, STYLEOUTFILE);
|
||||||
|
await fsp.writeFile(outpath, out);
|
||||||
|
console.log(`Wrote ${outpath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process scripts
|
||||||
|
async function scripts() {
|
||||||
|
await mkdir([SCRIPTSOUTDIR, SCRIPTSDIR]);
|
||||||
|
await emptyDir(SCRIPTSOUTDIR);
|
||||||
|
let files = await fsp.readdir(SCRIPTSDIR);
|
||||||
|
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||||
|
let p = path.join(SCRIPTSDIR, f);
|
||||||
|
let o = path.join(SCRIPTSOUTDIR, f);
|
||||||
|
console.log(`Processing script ${p}`);
|
||||||
|
try {
|
||||||
|
await fsp.writeFile(o, uglifyjs.minify((await fsp.readFile(p)).toString()).code);
|
||||||
|
console.log(`Wrote ${o}`);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.log(`error writing ${o}: ${ex}`);
|
||||||
|
}
|
||||||
|
res(0);
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process images
|
||||||
|
async function images(dir = '') {
|
||||||
|
let p = path.join(IMAGESDIR, dir);
|
||||||
|
await mkdir(p);
|
||||||
|
if (dir.length === 0) {
|
||||||
|
await mkdir(IMAGESOUTDIR)
|
||||||
|
await emptyDir(IMAGESOUTDIR);
|
||||||
|
}
|
||||||
|
let files = await fsp.readdir(p, {
|
||||||
|
withFileTypes: true
|
||||||
|
});
|
||||||
|
if (files.length) {
|
||||||
|
await Promise.all(files.map(f => new Promise(async (res, reject) => {
|
||||||
|
if (f.isFile()) {
|
||||||
|
let outDir = path.join(IMAGESOUTDIR, dir);
|
||||||
|
let infile = path.join(p, f.name);
|
||||||
|
let outfile = path.join(outDir, f.name.substring(0, f.name.lastIndexOf('.')) + '.webp');
|
||||||
|
await mkdir(outDir);
|
||||||
|
console.log(`Processing image ${infile}`)
|
||||||
|
let process = spawn('cwebp', ['-mt', '-q', '50', infile, '-o', outfile]);
|
||||||
|
let timeout = setTimeout(() => {
|
||||||
|
reject('Timed out');
|
||||||
|
process.kill();
|
||||||
|
}, 30000);
|
||||||
|
process.on('exit', async (code) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
if (code === 0) {
|
||||||
|
console.log(`Wrote ${outfile}`);
|
||||||
|
res();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
reject(code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (f.isDirectory()) {
|
||||||
|
images(path.join(dir, f.name)).then(res).catch(reject);
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async function () {
|
||||||
|
await Promise.all([styles(), scripts(), images()]);
|
||||||
|
if (process.argv.indexOf('--watch') >= 0) {
|
||||||
|
console.log('watching for changes...');
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const watcher = fsp.watch(STYLESDIR);
|
||||||
|
for await (const _ of watcher)
|
||||||
|
await styles();
|
||||||
|
} catch (err) {
|
||||||
|
if (err.name === 'AbortError')
|
||||||
|
return;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const watcher = fsp.watch(SCRIPTSDIR);
|
||||||
|
for await (const _ of watcher)
|
||||||
|
await scripts();
|
||||||
|
} catch (err) {
|
||||||
|
if (err.name === 'AbortError')
|
||||||
|
return;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const watcher = fsp.watch(IMAGESDIR, {
|
||||||
|
recursive: true // no Linux ☹️
|
||||||
|
});
|
||||||
|
for await (const _ of watcher)
|
||||||
|
await images();
|
||||||
|
} catch (err) {
|
||||||
|
if (err.name === 'AbortError')
|
||||||
|
return;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
})();
|
118
db.js
Normal file
118
db.js
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
const sqlite = require('better-sqlite3');
|
||||||
|
const TABLE = 'packages';
|
||||||
|
|
||||||
|
class DB {
|
||||||
|
constructor(file) {
|
||||||
|
this._db = new sqlite(file);
|
||||||
|
const db = this._db;
|
||||||
|
|
||||||
|
if (!db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='${TABLE}';`).get()) {
|
||||||
|
db.prepare(`CREATE TABLE ${TABLE} (package VARCHAR(128) PRIMARY KEY, maintainer VARCHAR(128), move INTEGER, udate INTEGER, lastseen DATETIME);`).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._queries = {
|
||||||
|
GETPACKAGE: db.prepare(`SELECT * FROM ${TABLE} WHERE package = @package;`),
|
||||||
|
ADDPACKAGE: db.prepare(`INSERT INTO ${TABLE} (package,maintainer,move,udate,lastseen) VALUES (@package, @maintainer, 0, 0, @lastseen);`),
|
||||||
|
UPDATEMAINTAINER: db.prepare(`UPDATE ${TABLE} SET maintainer = @maintainer, lastseen= @lastseen WHERE package = @package`),
|
||||||
|
GETMAINTAINERPACKAGECOUNT: db.prepare(`SELECT COUNT(package) as count FROM ${TABLE} WHERE maintainer = @maintainer;`),
|
||||||
|
REMOVEOLDPACKAGE: db.prepare(`DELETE FROM ${TABLE} WHERE lastseen < @lastseen;`),
|
||||||
|
move: {
|
||||||
|
GET: db.prepare(`SELECT * FROM ${TABLE} WHERE move = @bool;`),
|
||||||
|
GETNEWBYMAINTAINER: db.prepare(`SELECT * FROM ${TABLE} WHERE maintainer = @maintainer AND move = 4;`),
|
||||||
|
UPDATE: db.prepare(`UPDATE ${TABLE} SET move = @bool WHERE package = @package`),
|
||||||
|
INCREMENT: db.prepare(`UPDATE ${TABLE} SET move = move + 1 WHERE package = @package`),
|
||||||
|
DECREMENT: db.prepare(`UPDATE ${TABLE} SET move = 0 WHERE move = 1`),
|
||||||
|
FIXFLAG: db.prepare(`UPDATE ${TABLE} SET move = 1 WHERE move > 1`),
|
||||||
|
GETPACKAGESBYMAINTAINER: db.prepare(`SELECT * FROM ${TABLE} WHERE maintainer = @maintainer AND move > 0;`),
|
||||||
|
GETPACKAGECOUNTBYMAINTAINER: db.prepare(`SELECT COUNT(package) as count FROM ${TABLE} WHERE maintainer = @maintainer AND move > 0;`)
|
||||||
|
},
|
||||||
|
udate: {
|
||||||
|
GET: db.prepare(`SELECT * FROM ${TABLE} WHERE udate = @bool;`),
|
||||||
|
GETNEWBYMAINTAINER: db.prepare(`SELECT * FROM ${TABLE} WHERE maintainer = @maintainer AND udate = 4;`),
|
||||||
|
UPDATE: db.prepare(`UPDATE ${TABLE} SET udate = @bool WHERE package = @package`),
|
||||||
|
INCREMENT: db.prepare(`UPDATE ${TABLE} SET udate = udate + 1 WHERE package = @package`),
|
||||||
|
DECREMENT: db.prepare(`UPDATE ${TABLE} SET udate = 0 WHERE udate = 1`),
|
||||||
|
FIXFLAG: db.prepare(`UPDATE ${TABLE} SET udate = 1 WHERE udate > 1`),
|
||||||
|
GETPACKAGESBYMAINTAINER: db.prepare(`SELECT * FROM ${TABLE} WHERE maintainer = @maintainer AND udate > 0;`),
|
||||||
|
GETPACKAGECOUNTBYMAINTAINER: db.prepare(`SELECT COUNT(package) as count FROM ${TABLE} WHERE maintainer = @maintainer AND udate > 0;`)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreFlags() {
|
||||||
|
this._queries.move.FIXFLAG.run();
|
||||||
|
this._queries.udate.FIXFLAG.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
getPackage(pack) {
|
||||||
|
return this._queries.GETPACKAGE.get({
|
||||||
|
package: pack
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePackage(pack, maintainer, lastseen) {
|
||||||
|
return this._queries[this.getPackage(pack) ? 'UPDATEMAINTAINER' : 'ADDPACKAGE'].run({
|
||||||
|
package: pack,
|
||||||
|
maintainer,
|
||||||
|
lastseen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
incrementFlag(pack, type) {
|
||||||
|
this._queries[type].INCREMENT.run({
|
||||||
|
package: pack
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
decrementFlags(type) {
|
||||||
|
this._queries[type].DECREMENT.run();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFlag(pack, type, bool) {
|
||||||
|
this._queries[type].UPDATE.run({
|
||||||
|
package: pack,
|
||||||
|
bool
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getFlag(type, bool = true) {
|
||||||
|
return this._queries[type].GET.all({
|
||||||
|
bool
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getNewByMaintainer(maintainer, type) {
|
||||||
|
return this._queries[type].GETNEWBYMAINTAINER.all({
|
||||||
|
maintainer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPackagesByMaintainer(maintainer, type) {
|
||||||
|
return this._queries[type].GETPACKAGESBYMAINTAINER.all({
|
||||||
|
maintainer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPackageCountByMaintainer(maintainer, type) {
|
||||||
|
return this._queries[type].GETPACKAGECOUNTBYMAINTAINER.get({
|
||||||
|
maintainer
|
||||||
|
}).count;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanOldPackages(lastseen) {
|
||||||
|
return this._queries.REMOVEOLDPACKAGE.run({
|
||||||
|
lastseen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getMaintainerPackageCount(maintainer) {
|
||||||
|
return this._queries.GETMAINTAINERPACKAGECOUNT.get({
|
||||||
|
maintainer
|
||||||
|
}).count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = DB;
|
@@ -5,20 +5,11 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
volumes:
|
volumes:
|
||||||
- ./volume:/usr/volume
|
- ./config:/usr/notifier/config
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
environment:
|
environment:
|
||||||
ARTIX_MIRROR: "https://mirrors.qontinuum.space/artixlinux/%s/os/x86_64"
|
ARTIX_MIRROR: "https://mirrors.qontinuum.space/artixlinux/%s/os/x86_64"
|
||||||
ARCH_MIRROR: "https://mirrors.qontinuum.space/archlinux/%s/os/x86_64"
|
ARCH_MIRROR: "https://mirrors.qontinuum.space/archlinux/%s/os/x86_64"
|
||||||
ARTIX_REPOS: "system-goblins,world-goblins,system-gremlins,world-gremlins,system,world"
|
ARTIX_REPOS: "system-goblins,world-goblins,system-gremlins,world-gremlins,system,world"
|
||||||
ARCH_REPOS: "core-staging,extra-staging,core-testing,extra-testing,core,extra"
|
ARCH_REPOS: "core-staging,extra-staging,core-testing,extra-testing,core,extra"
|
||||||
CRON: "*/30 * * * *"
|
|
||||||
|
|
||||||
packy-prom:
|
|
||||||
build:
|
|
||||||
context: ./prometheus
|
|
||||||
volumes:
|
|
||||||
- ./volume:/usr/volume
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
environment:
|
|
||||||
PORT: 8080
|
|
||||||
|
282
index.js
282
index.js
@@ -1,21 +1,186 @@
|
|||||||
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const fsp = fs.promises;
|
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const cron = require('node-cron');
|
||||||
|
const dayjs = require('dayjs');
|
||||||
|
const json5 = require('json5');
|
||||||
const phin = require('phin');
|
const phin = require('phin');
|
||||||
|
const DB = require('./db');
|
||||||
|
const IRCBot = require('./ircbot');
|
||||||
|
const Web = require('./web');
|
||||||
|
const fsp = fs.promises;
|
||||||
|
|
||||||
const TIMEOUT = 180000;
|
const TIMEOUT = 180000;
|
||||||
const PKGCONFIG = process.env.PKGCONFIG || '/usr/volume/packages.json';
|
|
||||||
const EXTRASPACE = new RegExp('\\s+', 'g');
|
const EXTRASPACE = new RegExp('\\s+', 'g');
|
||||||
|
const NICETYPES = {
|
||||||
|
move: 'move',
|
||||||
|
udate: 'update'
|
||||||
|
}
|
||||||
|
|
||||||
|
let saveData = {
|
||||||
|
'last-sync': null,
|
||||||
|
move: [],
|
||||||
|
update: []
|
||||||
|
}
|
||||||
|
|
||||||
|
let cronjob;
|
||||||
|
let ircBot;
|
||||||
|
|
||||||
|
let savePath = process.env.SAVEPATH || path.join(__dirname, 'config', 'data.json');
|
||||||
|
|
||||||
|
fs.readFile(process.env.CONFIGPATH || path.join(__dirname, 'config', 'config.json'), async (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const config = json5.parse(data);
|
||||||
|
savePath = config.savePath || savePath;
|
||||||
|
const db = new DB(process.env.DBPATH || config.db || path.join(__dirname, 'config', 'packages.db'));
|
||||||
|
|
||||||
|
try {
|
||||||
|
saveData = JSON.parse(await fsp.readFile(savePath));
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.error(`Failed to read existing save data at ${savePath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// resetting flags in case of improper shutdown
|
||||||
|
db.restoreFlags();
|
||||||
|
|
||||||
|
cronjob = cron.schedule(process.env.CRON || config.cron || '*/30 * * * *', () => {
|
||||||
|
main(config, db);
|
||||||
|
});
|
||||||
|
|
||||||
|
const web = new Web(db, config, saveData);
|
||||||
|
ircBot = new IRCBot(config);
|
||||||
|
ircBot.connect();
|
||||||
|
|
||||||
|
process.on('SIGTERM', () => {
|
||||||
|
cronjob.stop();
|
||||||
|
web.close();
|
||||||
|
ircBot.clouse();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function main(config, db) {
|
||||||
|
console.log('Starting scheduled task');
|
||||||
|
cronjob.stop();
|
||||||
|
let now = dayjs();
|
||||||
|
if (!('last-sync' in saveData) || !saveData['last-sync'] || dayjs(saveData['last-sync']).isBefore(now.subtract(process.env.SYNCFREQ || config.syncfreq || 2, 'days'))) {
|
||||||
|
ircBot.close();
|
||||||
|
await updateMaintainers(config, db);
|
||||||
|
saveData['last-sync'] = now.toJSON();
|
||||||
|
await writeSaveData();
|
||||||
|
await ircBot.connect();
|
||||||
|
}
|
||||||
|
await checkupdates(config, db);
|
||||||
|
await writeSaveData();
|
||||||
|
cronjob.start();
|
||||||
|
console.log('Task complete.');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function writeSaveData() {
|
||||||
|
try {
|
||||||
|
await fsp.writeFile(savePath, JSON.stringify(saveData));
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.error(`Failed to write save data to ${savePath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkupdates(config, db) {
|
||||||
|
await handleUpdates(config, db, saveData.move = await execCheckUpdates(['-m']), 'move');
|
||||||
|
await handleUpdates(config, db, saveData.update = await execCheckUpdates(['-u']), 'udate');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUpdates(config, db, packs, type) {
|
||||||
|
packs.forEach(v => {
|
||||||
|
let p = db.getPackage(v);
|
||||||
|
p && db.updateFlag(v, type, p[type] > 0 ? 2 : 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < config.maintainers.length; i++) {
|
||||||
|
const m = config.maintainers[i];
|
||||||
|
const mname = typeof m === 'object' ? m.name : m;
|
||||||
|
const ircName = typeof m === 'object' ? (m.ircName || mname) : m;
|
||||||
|
const packages = db.getNewByMaintainer(mname, type);
|
||||||
|
if (typeof m === 'object') {
|
||||||
|
notify({
|
||||||
|
api: config.apprise,
|
||||||
|
urls: m.channels
|
||||||
|
}, packages, NICETYPES[type])
|
||||||
|
}
|
||||||
|
ircNotify(packages, ircName, NICETYPES[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
db.decrementFlags(type);
|
||||||
|
db.restoreFlags(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateMaintainers(config, db) {
|
||||||
|
console.log('Syncing packages...');
|
||||||
|
const lastseen = (new Date()).getTime();
|
||||||
|
const maintainers = config.maintainers;
|
||||||
|
for (let i = 0; maintainers && i < maintainers.length; i++) {
|
||||||
|
let maintainer = maintainers[i];
|
||||||
|
if (typeof maintainer === 'object') {
|
||||||
|
maintainer = maintainer.name;
|
||||||
|
}
|
||||||
|
console.log(`Syncing ${maintainer}...`);
|
||||||
|
try {
|
||||||
|
(await getMaintainersPackages(maintainer)).forEach(package => db.updatePackage(package, maintainer, lastseen));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(`Failed to get packages for ${maintainer}`);
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(`removing unused packages...`);
|
||||||
|
db.cleanOldPackages(lastseen);
|
||||||
|
console.log(`Package sync complete`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMaintainersPackages(maintainer) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let process = spawn('artixpkg', ['admin', 'query', '-m', maintainer]);
|
||||||
|
let timeout = setTimeout(() => {
|
||||||
|
reject('Timed out');
|
||||||
|
process.kill();
|
||||||
|
}, TIMEOUT);
|
||||||
|
let packagelist = [];
|
||||||
|
process.stdout.on('data', data => {
|
||||||
|
packagelist = packagelist.concat(data.toString().trim().split('\n'));
|
||||||
|
});
|
||||||
|
process.stderr.on('data', err => {
|
||||||
|
console.error(err.toString());
|
||||||
|
})
|
||||||
|
process.on('exit', async (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
resolve(packagelist);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
reject(code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function notify(apprise, packarr, type) {
|
async function notify(apprise, packarr, type) {
|
||||||
|
if (!(packarr && packarr.length && apprise && apprise.api && apprise.urls)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const packagesStr = packarr.map(p => p.package).join('\n');
|
||||||
for (let i = 0; i < 25; i++) {
|
for (let i = 0; i < 25; i++) {
|
||||||
try {
|
try {
|
||||||
return await phin({
|
return await phin({
|
||||||
url: `${apprise.api}/notify/`,
|
url: `${apprise.api}/notify/`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
title: `Packages ready to ${type}`,
|
title: `${packarr[0].maintainer}: packages ready to ${type}`,
|
||||||
body: packarr.join('\n'),
|
body: packagesStr,
|
||||||
urls: apprise.urls.join(',')
|
urls: apprise.urls.join(',')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -28,6 +193,23 @@ async function notify(apprise, packarr, type) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ircNotify(packarr, maintainer, type) {
|
||||||
|
if (!(packarr && packarr.length)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const packagesStr = packarr.map(p => p.package).join('\n');
|
||||||
|
for (let i = 0; i < 25; i++) {
|
||||||
|
try {
|
||||||
|
return ircBot.sendMessage(`${maintainer}: packages ready to ${type}\n${packagesStr}\n-------- EOF --------`);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error('Failed to send IRC notification, attempt #%d', i + 1);
|
||||||
|
console.error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function parseCheckUpdatesOutput(output) {
|
function parseCheckUpdatesOutput(output) {
|
||||||
let packages = [];
|
let packages = [];
|
||||||
let lines = output.split('\n');
|
let lines = output.split('\n');
|
||||||
@@ -40,108 +222,28 @@ function parseCheckUpdatesOutput(output) {
|
|||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkUpdates(flags) {
|
function execCheckUpdates(flags) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let process = spawn('artix-checkupdates', flags);
|
let process = spawn('artix-checkupdates', flags);
|
||||||
let timeout = setTimeout(() => {
|
let timeout = setTimeout(() => {
|
||||||
reject('Timed out');
|
reject('Timed out');
|
||||||
process.kill();
|
process.kill();
|
||||||
}, TIMEOUT);
|
}, TIMEOUT);
|
||||||
let packagelist = [];
|
let outputstr = '';
|
||||||
process.stdout.on('data', data => {
|
process.stdout.on('data', data => {
|
||||||
packagelist = packagelist.concat(parseCheckUpdatesOutput(data.toString()));
|
outputstr += data.toString();
|
||||||
});
|
});
|
||||||
process.stderr.on('data', err => {
|
process.stderr.on('data', err => {
|
||||||
console.log(err.toString());
|
console.error(err.toString());
|
||||||
})
|
})
|
||||||
process.on('exit', async (code) => {
|
process.on('exit', async (code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
resolve(packagelist);
|
resolve(parseCheckUpdatesOutput(outputstr));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reject(code);
|
reject(code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPendingPackages() {
|
|
||||||
return {
|
|
||||||
movable: await checkUpdates(['-m']),
|
|
||||||
upgradable: await checkUpdates(['-u'])
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.readFile(PKGCONFIG, async (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data = JSON.parse(data);
|
|
||||||
const PREVIOUS = data.PREVIOUS || process.env.PREVIOUS || '/usr/volume/previous.json';
|
|
||||||
const packages = data.packages;
|
|
||||||
const actionableFilter = p => packages.indexOf(p) >= 0;
|
|
||||||
let previousm = [], previousu = [], movable = [], upgradable = [], newpack = [];
|
|
||||||
try {
|
|
||||||
const p = JSON.parse(await fsp.readFile(PREVIOUS));
|
|
||||||
if ('packages' in p) {
|
|
||||||
previousu = p.packages;
|
|
||||||
}
|
|
||||||
if ('movable' in p) {
|
|
||||||
previousm = p.movable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
console.log(`Could not read ${PREVIOUS}: ${ex}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
let allPending = await getPendingPackages();
|
|
||||||
|
|
||||||
movable = allPending.movable.filter(actionableFilter);
|
|
||||||
upgradable = allPending.upgradable.filter(actionableFilter);
|
|
||||||
|
|
||||||
console.log('Movable:');
|
|
||||||
movable.forEach(pkg => console.log(pkg));
|
|
||||||
console.log('\nUpgradable:');
|
|
||||||
upgradable.forEach(pkg => console.log(pkg));
|
|
||||||
|
|
||||||
let output = {
|
|
||||||
packages: upgradable,
|
|
||||||
movable
|
|
||||||
};
|
|
||||||
if (data.writeAllPending) {
|
|
||||||
output['allPackages'] = allPending.upgradable;
|
|
||||||
output['allMovable'] = allPending.movable;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await fsp.writeFile(PREVIOUS, JSON.stringify(output));
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
console.log(`Could not write ${PREVIOUS}: ${ex}`);
|
|
||||||
}
|
|
||||||
movable.forEach(package => {
|
|
||||||
if (previousm.indexOf(package) === -1) {
|
|
||||||
newpack.push(package);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (newpack.length > 0) {
|
|
||||||
await notify(data.apprise, newpack, 'move');
|
|
||||||
}
|
|
||||||
newpack = [];
|
|
||||||
upgradable.forEach(package => {
|
|
||||||
if (previousu.indexOf(package) === -1) {
|
|
||||||
newpack.push(package);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (newpack.length > 0) {
|
|
||||||
await notify(data.apprise, newpack, 'upgrade');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
console.log('Task failed:', ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
61
ircbot.js
Normal file
61
ircbot.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
const IRC = require('irc-framework');
|
||||||
|
|
||||||
|
class IRCBot {
|
||||||
|
|
||||||
|
constructor(config) {
|
||||||
|
const options = config['irc-framework'];
|
||||||
|
const aux = this._aux = config.ircClient || {};
|
||||||
|
this._channel = aux.channel;
|
||||||
|
this._messageQueue = [];
|
||||||
|
if (options) {
|
||||||
|
const bot = this._bot = new IRC.Client(options);
|
||||||
|
|
||||||
|
bot.on('sasl failed', d => console.error(d));
|
||||||
|
|
||||||
|
bot.on('notice', d => console.log(`irc:notice: ${d.message}`));
|
||||||
|
|
||||||
|
bot.on('action', d => console.log(`irc:action: ${d.message}`));
|
||||||
|
|
||||||
|
setInterval(() => this.processMessageQueue(), 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const bot = this._bot;
|
||||||
|
bot.connect();
|
||||||
|
const callback = () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
console.log(`IRC bot ${bot.user.nick} connected.`);
|
||||||
|
bot.join(this._aux.channel, this._aux.channel_key);
|
||||||
|
bot.removeListener('registered', callback);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
bot.removeListener('registered', callback);
|
||||||
|
reject('timeout exceeded');
|
||||||
|
}, 60000);
|
||||||
|
bot.on('registered', callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(str) {
|
||||||
|
str.split('\n').forEach(line => {
|
||||||
|
this._messageQueue.push(line);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
processMessageQueue() {
|
||||||
|
const bot = this._bot
|
||||||
|
let message = bot.connected && this._messageQueue.shift();
|
||||||
|
message && bot.say(this._channel, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
if (this._bot.connected) {
|
||||||
|
this._bot.quit('Shutting down');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = IRCBot;
|
3148
package-lock.json
generated
3148
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@@ -1,8 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "artix-packy-notifier",
|
"name": "artix-packy-notifier",
|
||||||
"version": "2.2.1",
|
"version": "3.3.1",
|
||||||
"description": "Determine packages that need attention",
|
"description": "Determine packages that need attention",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "node build.js",
|
||||||
|
"watch": "node build.js --watch"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/sanin.dev/artix-packy-notifier.git"
|
"url": "git+ssh://git@gitlab.com/sanin.dev/artix-packy-notifier.git"
|
||||||
@@ -19,6 +23,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/sanin.dev/artix-packy-notifier#readme",
|
"homepage": "https://gitlab.com/sanin.dev/artix-packy-notifier#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"phin": "^3.7.0"
|
"better-sqlite3": "9.4.0",
|
||||||
|
"dayjs": "1.11.10",
|
||||||
|
"ejs": "3.1.9",
|
||||||
|
"express": "4.18.2",
|
||||||
|
"irc-framework": "4.13.1",
|
||||||
|
"json5": "2.2.3",
|
||||||
|
"node-cron": "3.0.3",
|
||||||
|
"phin": "^3.7.0",
|
||||||
|
"prom-client": "15.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"csso": "5.0.5",
|
||||||
|
"sass": "1.66.1",
|
||||||
|
"uglify-js": "3.17.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
FROM oven/bun:alpine AS build-env
|
|
||||||
|
|
||||||
WORKDIR /build
|
|
||||||
|
|
||||||
COPY ./package*json ./
|
|
||||||
COPY ./bun.lockb ./
|
|
||||||
RUN bun install --production --no-progress
|
|
||||||
|
|
||||||
FROM oven/bun:alpine
|
|
||||||
EXPOSE ${PORT:-8080}
|
|
||||||
HEALTHCHECK --timeout=3s \
|
|
||||||
CMD curl --fail http://localhost:${PORT:-8080}/healthcheck || exit 1
|
|
||||||
WORKDIR /usr/src/artix-packy-exporter
|
|
||||||
RUN apk add --no-cache curl
|
|
||||||
COPY --from=build-env /build .
|
|
||||||
COPY . .
|
|
||||||
USER bun
|
|
||||||
|
|
||||||
CMD [ "bun", "run", "index.ts"]
|
|
@@ -1,15 +0,0 @@
|
|||||||
# artix-packy-exporter
|
|
||||||
|
|
||||||
To install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
To run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run index.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
This project was created using `bun init` in bun v1.0.11. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
Binary file not shown.
@@ -1,59 +0,0 @@
|
|||||||
import express from 'express';
|
|
||||||
import prom from 'prom-client';
|
|
||||||
import fs from 'fs';
|
|
||||||
const fsp = fs.promises;
|
|
||||||
const http = express();
|
|
||||||
|
|
||||||
const NAME = 'Artix Package Exporter';
|
|
||||||
const PORT = process.env.PORT || 8080;
|
|
||||||
const METRICPREFIX = process.env.METRICPREFIX || 'artixpackages_';
|
|
||||||
const register = prom.register;
|
|
||||||
const NICE_NAMES: any = {
|
|
||||||
packages: 'My upgradable',
|
|
||||||
movable: 'My movable',
|
|
||||||
allPackages: 'All upgradable',
|
|
||||||
allMovable: 'All movable'
|
|
||||||
};
|
|
||||||
|
|
||||||
new prom.Gauge({
|
|
||||||
name: `${METRICPREFIX}pending_packages`,
|
|
||||||
help: 'Number of packages that have pending updates or moves.',
|
|
||||||
labelNames: ['category'],
|
|
||||||
async collect() {
|
|
||||||
const prev = JSON.parse((await fsp.readFile(process.env.PREVIOUS || '/usr/volume/previous.json')).toString());
|
|
||||||
for (const category in prev) {
|
|
||||||
this.set({ category: ((category in NICE_NAMES) ? NICE_NAMES[category] : category) }, (prev[category] as string[]).length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new prom.Gauge({
|
|
||||||
name: `${METRICPREFIX}watched_packages`,
|
|
||||||
help: 'Number of packages being monitored for updates.',
|
|
||||||
async collect() {
|
|
||||||
const config = JSON.parse((await fsp.readFile(process.env.PACKAGES || '/usr/volume/packages.json')).toString());
|
|
||||||
this.set('packages' in config ? config['packages'].length : 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
http.get('/', async (_, res) => {
|
|
||||||
res.send(NAME);
|
|
||||||
});
|
|
||||||
|
|
||||||
http.get('/metrics', async (_, res) => {
|
|
||||||
try {
|
|
||||||
res.set('Content-Type', register.contentType);
|
|
||||||
res.end(await register.metrics());
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
res.status(500).send(ex);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
http.get('/healthcheck', async (_, res) => {
|
|
||||||
res.send('Healthy');
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on('SIGTERM', http.listen(PORT, () => {
|
|
||||||
console.log(`${NAME} running on port ${PORT}.`);
|
|
||||||
}).close);
|
|
753
prometheus/package-lock.json
generated
753
prometheus/package-lock.json
generated
@@ -1,753 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "artix-packy-exporter",
|
|
||||||
"version": "2.2.1",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "artix-packy-exporter",
|
|
||||||
"version": "2.2.1",
|
|
||||||
"dependencies": {
|
|
||||||
"express": "4.18.2",
|
|
||||||
"prom-client": "15.1.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/express": "^4.17.21",
|
|
||||||
"bun-types": "latest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@opentelemetry/api": {
|
|
||||||
"version": "1.7.0",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/body-parser": {
|
|
||||||
"version": "1.19.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
|
|
||||||
"integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/connect": "*",
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/connect": {
|
|
||||||
"version": "3.4.38",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
|
|
||||||
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/express": {
|
|
||||||
"version": "4.17.21",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
|
|
||||||
"integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/body-parser": "*",
|
|
||||||
"@types/express-serve-static-core": "^4.17.33",
|
|
||||||
"@types/qs": "*",
|
|
||||||
"@types/serve-static": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/express-serve-static-core": {
|
|
||||||
"version": "4.17.41",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz",
|
|
||||||
"integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/node": "*",
|
|
||||||
"@types/qs": "*",
|
|
||||||
"@types/range-parser": "*",
|
|
||||||
"@types/send": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/http-errors": {
|
|
||||||
"version": "2.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
|
|
||||||
"integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/mime": {
|
|
||||||
"version": "1.3.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
|
|
||||||
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/node": {
|
|
||||||
"version": "20.9.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
|
|
||||||
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"undici-types": "~5.26.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/qs": {
|
|
||||||
"version": "6.9.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz",
|
|
||||||
"integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/range-parser": {
|
|
||||||
"version": "1.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
|
|
||||||
"integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/send": {
|
|
||||||
"version": "0.17.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",
|
|
||||||
"integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/mime": "^1",
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/serve-static": {
|
|
||||||
"version": "1.15.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz",
|
|
||||||
"integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/http-errors": "*",
|
|
||||||
"@types/mime": "*",
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/accepts": {
|
|
||||||
"version": "1.3.8",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"mime-types": "~2.1.34",
|
|
||||||
"negotiator": "0.6.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/array-flatten": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/bintrees": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/body-parser": {
|
|
||||||
"version": "1.20.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"bytes": "3.1.2",
|
|
||||||
"content-type": "~1.0.4",
|
|
||||||
"debug": "2.6.9",
|
|
||||||
"depd": "2.0.0",
|
|
||||||
"destroy": "1.2.0",
|
|
||||||
"http-errors": "2.0.0",
|
|
||||||
"iconv-lite": "0.4.24",
|
|
||||||
"on-finished": "2.4.1",
|
|
||||||
"qs": "6.11.0",
|
|
||||||
"raw-body": "2.5.1",
|
|
||||||
"type-is": "~1.6.18",
|
|
||||||
"unpipe": "1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8",
|
|
||||||
"npm": "1.2.8000 || >= 1.4.16"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/bun-types": {
|
|
||||||
"version": "1.0.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.0.11.tgz",
|
|
||||||
"integrity": "sha512-XaDwjnBlkdTOtBEAcXhDnPSKFMlwFK/526z0iyairYIDhZJMzZM1QU4D7XRiEI2SpKQWexn0S/LN9Mwx5xSJNg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/bytes": {
|
|
||||||
"version": "3.1.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/call-bind": {
|
|
||||||
"version": "1.0.5",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.2",
|
|
||||||
"get-intrinsic": "^1.2.1",
|
|
||||||
"set-function-length": "^1.1.1"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/content-disposition": {
|
|
||||||
"version": "0.5.4",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"safe-buffer": "5.2.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/content-type": {
|
|
||||||
"version": "1.0.5",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/cookie": {
|
|
||||||
"version": "0.5.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/cookie-signature": {
|
|
||||||
"version": "1.0.6",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/debug": {
|
|
||||||
"version": "2.6.9",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/define-data-property": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"get-intrinsic": "^1.2.1",
|
|
||||||
"gopd": "^1.0.1",
|
|
||||||
"has-property-descriptors": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/depd": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/destroy": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8",
|
|
||||||
"npm": "1.2.8000 || >= 1.4.16"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ee-first": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/encodeurl": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/escape-html": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/etag": {
|
|
||||||
"version": "1.8.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/express": {
|
|
||||||
"version": "4.18.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"accepts": "~1.3.8",
|
|
||||||
"array-flatten": "1.1.1",
|
|
||||||
"body-parser": "1.20.1",
|
|
||||||
"content-disposition": "0.5.4",
|
|
||||||
"content-type": "~1.0.4",
|
|
||||||
"cookie": "0.5.0",
|
|
||||||
"cookie-signature": "1.0.6",
|
|
||||||
"debug": "2.6.9",
|
|
||||||
"depd": "2.0.0",
|
|
||||||
"encodeurl": "~1.0.2",
|
|
||||||
"escape-html": "~1.0.3",
|
|
||||||
"etag": "~1.8.1",
|
|
||||||
"finalhandler": "1.2.0",
|
|
||||||
"fresh": "0.5.2",
|
|
||||||
"http-errors": "2.0.0",
|
|
||||||
"merge-descriptors": "1.0.1",
|
|
||||||
"methods": "~1.1.2",
|
|
||||||
"on-finished": "2.4.1",
|
|
||||||
"parseurl": "~1.3.3",
|
|
||||||
"path-to-regexp": "0.1.7",
|
|
||||||
"proxy-addr": "~2.0.7",
|
|
||||||
"qs": "6.11.0",
|
|
||||||
"range-parser": "~1.2.1",
|
|
||||||
"safe-buffer": "5.2.1",
|
|
||||||
"send": "0.18.0",
|
|
||||||
"serve-static": "1.15.0",
|
|
||||||
"setprototypeof": "1.2.0",
|
|
||||||
"statuses": "2.0.1",
|
|
||||||
"type-is": "~1.6.18",
|
|
||||||
"utils-merge": "1.0.1",
|
|
||||||
"vary": "~1.1.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/finalhandler": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "2.6.9",
|
|
||||||
"encodeurl": "~1.0.2",
|
|
||||||
"escape-html": "~1.0.3",
|
|
||||||
"on-finished": "2.4.1",
|
|
||||||
"parseurl": "~1.3.3",
|
|
||||||
"statuses": "2.0.1",
|
|
||||||
"unpipe": "~1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/forwarded": {
|
|
||||||
"version": "0.2.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/fresh": {
|
|
||||||
"version": "0.5.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/function-bind": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/get-intrinsic": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.2",
|
|
||||||
"has-proto": "^1.0.1",
|
|
||||||
"has-symbols": "^1.0.3",
|
|
||||||
"hasown": "^2.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/gopd": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"get-intrinsic": "^1.1.3"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has-property-descriptors": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"get-intrinsic": "^1.2.2"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has-proto": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has-symbols": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/hasown": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/http-errors": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"depd": "2.0.0",
|
|
||||||
"inherits": "2.0.4",
|
|
||||||
"setprototypeof": "1.2.0",
|
|
||||||
"statuses": "2.0.1",
|
|
||||||
"toidentifier": "1.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/iconv-lite": {
|
|
||||||
"version": "0.4.24",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"safer-buffer": ">= 2.1.2 < 3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/inherits": {
|
|
||||||
"version": "2.0.4",
|
|
||||||
"license": "ISC"
|
|
||||||
},
|
|
||||||
"node_modules/ipaddr.js": {
|
|
||||||
"version": "1.9.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/media-typer": {
|
|
||||||
"version": "0.3.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/merge-descriptors": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/methods": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mime": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"bin": {
|
|
||||||
"mime": "cli.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mime-db": {
|
|
||||||
"version": "1.52.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mime-types": {
|
|
||||||
"version": "2.1.35",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"mime-db": "1.52.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/negotiator": {
|
|
||||||
"version": "0.6.3",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/object-inspect": {
|
|
||||||
"version": "1.13.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/on-finished": {
|
|
||||||
"version": "2.4.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"ee-first": "1.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/parseurl": {
|
|
||||||
"version": "1.3.3",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/path-to-regexp": {
|
|
||||||
"version": "0.1.7",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/prom-client": {
|
|
||||||
"version": "15.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/prom-client/-/prom-client-15.1.0.tgz",
|
|
||||||
"integrity": "sha512-cCD7jLTqyPdjEPBo/Xk4Iu8jxjuZgZJ3e/oET3L+ZwOuap/7Cw3dH/TJSsZKs1TQLZ2IHpIlRAKw82ef06kmMw==",
|
|
||||||
"dependencies": {
|
|
||||||
"@opentelemetry/api": "^1.4.0",
|
|
||||||
"tdigest": "^0.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^16 || ^18 || >=20"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/proxy-addr": {
|
|
||||||
"version": "2.0.7",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"forwarded": "0.2.0",
|
|
||||||
"ipaddr.js": "1.9.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/qs": {
|
|
||||||
"version": "6.11.0",
|
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"dependencies": {
|
|
||||||
"side-channel": "^1.0.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/range-parser": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/raw-body": {
|
|
||||||
"version": "2.5.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"bytes": "3.1.2",
|
|
||||||
"http-errors": "2.0.0",
|
|
||||||
"iconv-lite": "0.4.24",
|
|
||||||
"unpipe": "1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/safe-buffer": {
|
|
||||||
"version": "5.2.1",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "patreon",
|
|
||||||
"url": "https://www.patreon.com/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "consulting",
|
|
||||||
"url": "https://feross.org/support"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/safer-buffer": {
|
|
||||||
"version": "2.1.2",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/send": {
|
|
||||||
"version": "0.18.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "2.6.9",
|
|
||||||
"depd": "2.0.0",
|
|
||||||
"destroy": "1.2.0",
|
|
||||||
"encodeurl": "~1.0.2",
|
|
||||||
"escape-html": "~1.0.3",
|
|
||||||
"etag": "~1.8.1",
|
|
||||||
"fresh": "0.5.2",
|
|
||||||
"http-errors": "2.0.0",
|
|
||||||
"mime": "1.6.0",
|
|
||||||
"ms": "2.1.3",
|
|
||||||
"on-finished": "2.4.1",
|
|
||||||
"range-parser": "~1.2.1",
|
|
||||||
"statuses": "2.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/send/node_modules/ms": {
|
|
||||||
"version": "2.1.3",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/serve-static": {
|
|
||||||
"version": "1.15.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"encodeurl": "~1.0.2",
|
|
||||||
"escape-html": "~1.0.3",
|
|
||||||
"parseurl": "~1.3.3",
|
|
||||||
"send": "0.18.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/set-function-length": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"define-data-property": "^1.1.1",
|
|
||||||
"get-intrinsic": "^1.2.1",
|
|
||||||
"gopd": "^1.0.1",
|
|
||||||
"has-property-descriptors": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/setprototypeof": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"license": "ISC"
|
|
||||||
},
|
|
||||||
"node_modules/side-channel": {
|
|
||||||
"version": "1.0.4",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"call-bind": "^1.0.0",
|
|
||||||
"get-intrinsic": "^1.0.2",
|
|
||||||
"object-inspect": "^1.9.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/statuses": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tdigest": {
|
|
||||||
"version": "0.1.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"bintrees": "1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/toidentifier": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/type-is": {
|
|
||||||
"version": "1.6.18",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"media-typer": "0.3.0",
|
|
||||||
"mime-types": "~2.1.24"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/typescript": {
|
|
||||||
"version": "5.2.2",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
|
||||||
"tsc": "bin/tsc",
|
|
||||||
"tsserver": "bin/tsserver"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.17"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/undici-types": {
|
|
||||||
"version": "5.26.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
|
||||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/unpipe": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/utils-merge": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/vary": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "artix-packy-exporter",
|
|
||||||
"version": "2.2.1",
|
|
||||||
"module": "index.ts",
|
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
|
||||||
"express": "4.18.2",
|
|
||||||
"prom-client": "15.1.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/express": "^4.17.21",
|
|
||||||
"bun-types": "latest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["ESNext"],
|
|
||||||
"module": "esnext",
|
|
||||||
"target": "esnext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"composite": true,
|
|
||||||
"strict": true,
|
|
||||||
"downlevelIteration": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"allowJs": true,
|
|
||||||
"types": [
|
|
||||||
"bun-types" // add Bun global
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo " ~cron job started~ "
|
|
||||||
cd /usr/files
|
|
||||||
node index.js
|
|
||||||
echo "job finished."
|
|
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "Artix Packy Notifier"
|
|
||||||
echo "cron schedule: $CRON"
|
|
||||||
mkdir -p /usr/volume/packages ~/.config/artix-checkupdates
|
|
||||||
printf "ARTIX_MIRROR=$ARTIX_MIRROR\nARCH_MIRROR=$ARCH_MIRROR\nARTIX_REPOS=$ARTIX_REPOS\nARCH_REPOS=$ARCH_REPOS" "%s" "%s" > ~/.config/artix-checkupdates/config
|
|
||||||
R=$(echo "$CRON" | sed "s/\\//\\\\\\//g")
|
|
||||||
sed "s/%CRON%/$R/" cron > .cron
|
|
||||||
crontab /etc/cron.d/.cron
|
|
||||||
crond -f
|
|
48
styles/00-reset.css
Normal file
48
styles/00-reset.css
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/* http://meyerweb.com/eric/tools/css/reset/
|
||||||
|
v2.0 | 20110126
|
||||||
|
License: none (public domain)
|
||||||
|
*/
|
||||||
|
|
||||||
|
html, body, div, span, applet, object, iframe,
|
||||||
|
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||||
|
a, abbr, acronym, address, big, cite, code,
|
||||||
|
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||||
|
small, strike, strong, sub, sup, tt, var,
|
||||||
|
b, u, i, center,
|
||||||
|
dl, dt, dd, ol, ul, li,
|
||||||
|
fieldset, form, label, legend,
|
||||||
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||||
|
article, aside, canvas, details, embed,
|
||||||
|
figure, figcaption, footer, header, hgroup,
|
||||||
|
menu, nav, output, ruby, section, summary,
|
||||||
|
time, mark, audio, video {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
font: inherit;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
/* HTML5 display-role reset for older browsers */
|
||||||
|
article, aside, details, figcaption, figure,
|
||||||
|
footer, header, hgroup, menu, nav, section {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
ol, ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
blockquote, q {
|
||||||
|
quotes: none;
|
||||||
|
}
|
||||||
|
blockquote:before, blockquote:after,
|
||||||
|
q:before, q:after {
|
||||||
|
content: '';
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
200
styles/01-main.scss
Normal file
200
styles/01-main.scss
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
html,
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
color: #d9d9d9;
|
||||||
|
font-size: 1.1em;
|
||||||
|
line-height: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*:after {
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.8em;
|
||||||
|
line-height: 1.5em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 1.6em;
|
||||||
|
line-height: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 1.5em;
|
||||||
|
line-height: 1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
font-size: 1.4em;
|
||||||
|
line-height: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
font-size: 1.3em;
|
||||||
|
line-height: 1.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h6 {
|
||||||
|
font-size: 1.2em;
|
||||||
|
line-height: 1.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-bottom: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #53bffc;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover,
|
||||||
|
a:focus {
|
||||||
|
color: #92D7FC;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
li {
|
||||||
|
line-height: 1.75em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
td,
|
||||||
|
th {
|
||||||
|
border: 1px solid #858585;
|
||||||
|
text-align: left;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0f3147;
|
||||||
|
border: 1px solid #0A6682;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
|
||||||
|
a:hover,
|
||||||
|
a:focus {
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&.logo svg .artix-logo-base {
|
||||||
|
fill: #53bffc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a.logo {
|
||||||
|
display: inline-block;
|
||||||
|
height: 3em;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 3em;
|
||||||
|
height: 3em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
svg+span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
float: right;
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 3em;
|
||||||
|
height: 3em;
|
||||||
|
padding: 0 10px 0 10px;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
border-bottom: 2px solid #92D7FC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
font-size: 9pt;
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 1em 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr td:last-child {
|
||||||
|
min-width: 6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding: .5em .75em;
|
||||||
|
width: 80%;
|
||||||
|
margin: .5em auto;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0);
|
||||||
|
|
||||||
|
&.bg {
|
||||||
|
background-color: #2a2a2a;
|
||||||
|
border: 1px solid #858585;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:790px) {
|
||||||
|
.container {
|
||||||
|
width: initial;
|
||||||
|
margin: .5em .5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:660px) {
|
||||||
|
header {
|
||||||
|
nav {
|
||||||
|
float: initial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:270px) {
|
||||||
|
footer ul li {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
header nav ul li {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
font-size: 1em;
|
||||||
|
line-height: 1.1em;
|
||||||
|
}
|
||||||
|
}
|
9
views/error.ejs
Normal file
9
views/error.ejs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<%- include("head", locals) %>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%- include("header", locals) %>
|
||||||
|
<div class="container bg">
|
||||||
|
<h1><%= status %></h1>
|
||||||
|
<p><%= description %></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
9
views/footer.ejs
Normal file
9
views/footer.ejs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="container bg">
|
||||||
|
<footer>
|
||||||
|
<ul>
|
||||||
|
<li>© <%= (new Date()).getFullYear() %> Artix Linux</li>
|
||||||
|
<li>Developed by Cory Sanin</li>
|
||||||
|
<li><a href="https://gitea.artixlinux.org/corysanin/artix-packy-notifier">Source</a></li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
||||||
|
</div>
|
14
views/head.ejs
Normal file
14
views/head.ejs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title><%= site.prefix %> - <%= site.suffix %></title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="author" content="Cory Sanin" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="apple-mobile-web-app-title" content="Artix Checkupdates">
|
||||||
|
<meta name="application-name" content="Artix Checkupdates">
|
||||||
|
<meta name="theme-color" content="#212121">
|
||||||
|
<link rel="stylesheet" href="/assets/css/styles.css?v=2">
|
||||||
|
<link rel="shortcut icon" href="/assets/svg/artix_logo.svg">
|
||||||
|
</head>
|
16
views/header.ejs
Normal file
16
views/header.ejs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="container">
|
||||||
|
<header>
|
||||||
|
<a href="/" class="logo"><%- inliner('/assets/svg/artix_logo.svg') %>
|
||||||
|
<span>Artix Checkupdates</span>
|
||||||
|
</a>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/">Checkupdates</a></li>
|
||||||
|
<li><a href="https://artixlinux.org/">Artix Linux</a></li>
|
||||||
|
<li><a href="https://forum.artixlinux.org/">Forum</a></li>
|
||||||
|
<li><a href="https://wiki.artixlinux.org/">Wiki</a></li>
|
||||||
|
<li><a href="https://gitea.artixlinux.org/explore/repos">Sources</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
</div>
|
28
views/index.ejs
Normal file
28
views/index.ejs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<%- include("head", locals) %>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%- include("header", locals) %>
|
||||||
|
<div class="container bg">
|
||||||
|
<h1>Pending Packages</h1>
|
||||||
|
<h2>By Maintainer</h2>
|
||||||
|
<ul>
|
||||||
|
<% maintainers && maintainers.forEach(m => { %>
|
||||||
|
<li><a href="/maintainer/<%= m %>"><%= m %></a></li>
|
||||||
|
<% }); %>
|
||||||
|
</ul>
|
||||||
|
<h2>All Pending</h2>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Package</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
<% packages && packages.forEach(p => { %>
|
||||||
|
<tr>
|
||||||
|
<td><a href="<%= p.url %>"><%= p.package %></a></td>
|
||||||
|
<td><%= p.action %></td>
|
||||||
|
</tr>
|
||||||
|
<% }); %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<%- include("footer", locals) %>
|
||||||
|
</body>
|
23
views/maintainer.ejs
Normal file
23
views/maintainer.ejs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<%- include("head", locals) %>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%- include("header", locals) %>
|
||||||
|
<div class="container bg">
|
||||||
|
<h1><%= maintainer %>'s Operations</h1>
|
||||||
|
<p>
|
||||||
|
<%= maintainer %> owns <a href="https://gitea.artixlinux.org/explore/repos?q=maintainer-<%= maintainer %>&topic=1"><%= packagesOwned %> packages</a>.
|
||||||
|
</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Package</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
<% packages && packages.forEach(p => { %>
|
||||||
|
<tr>
|
||||||
|
<td><a href="<%= p.url %>"><%= p.package.package %></a></td>
|
||||||
|
<td><%= p.action %></td>
|
||||||
|
</tr>
|
||||||
|
<% }); %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
203
web.js
Normal file
203
web.js
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const prom = require('prom-client');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const PROJECT_ROOT = __dirname;
|
||||||
|
const VIEWOPTIONS = {
|
||||||
|
outputFunctionName: 'echo'
|
||||||
|
};
|
||||||
|
const NAMECOMPLIANCE = [
|
||||||
|
p => p.replace(/([a-zA-Z0-9]+)\+([a-zA-Z]+)/g, '$1-$2'),
|
||||||
|
p => p.replace(/\+/g, "plus"),
|
||||||
|
p => p.replace(/[^a-zA-Z0-9_\-\.]/g, "-"),
|
||||||
|
p => p.replace(/[_\-]{2,}/g, "-")
|
||||||
|
]
|
||||||
|
|
||||||
|
function inliner(file) {
|
||||||
|
return fs.readFileSync(path.join(PROJECT_ROOT, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
function packageUrl(p) {
|
||||||
|
let packagename = typeof p === 'string' ? p : p.package;
|
||||||
|
return `https://gitea.artixlinux.org/packages/${NAMECOMPLIANCE.reduce((s, fn) => fn(s), packagename)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepPackages(arr, action) {
|
||||||
|
return arr.map(m => {
|
||||||
|
return {
|
||||||
|
package: m,
|
||||||
|
action,
|
||||||
|
url: packageUrl(m)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class Web {
|
||||||
|
constructor(db, options, savedata) {
|
||||||
|
const app = express();
|
||||||
|
const port = process.env.PORT || options.port || 8080;
|
||||||
|
const METRICPREFIX = process.env.METRICPREFIX || 'artixpackages_';
|
||||||
|
const maintainers = this._maintainers = options.maintainers.map(m => typeof m === 'object' ? m.name : m).sort();
|
||||||
|
|
||||||
|
app.set('trust proxy', 1);
|
||||||
|
app.set('view engine', 'ejs');
|
||||||
|
app.set('view options', VIEWOPTIONS);
|
||||||
|
|
||||||
|
function sendError(req, res, status, description) {
|
||||||
|
console.log(`${status} (${description}): ${req.url} requested by ${req.ip} "${req.headers['user-agent']}"`);
|
||||||
|
res.render('error',
|
||||||
|
{
|
||||||
|
inliner,
|
||||||
|
site: {
|
||||||
|
prefix: 'Artix Checkupdates',
|
||||||
|
suffix: 'Error'
|
||||||
|
},
|
||||||
|
status,
|
||||||
|
description
|
||||||
|
},
|
||||||
|
function (err, html) {
|
||||||
|
if (!err) {
|
||||||
|
res.status(status).send(html);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).send(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/healthcheck', async (_, res) => {
|
||||||
|
res.send('Healthy');
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/', async (_, res) => {
|
||||||
|
let packages = prepPackages(savedata.move, 'Move');
|
||||||
|
packages = packages.concat(prepPackages(savedata.update, 'Update'));
|
||||||
|
res.render('index',
|
||||||
|
{
|
||||||
|
inliner,
|
||||||
|
site: {
|
||||||
|
prefix: 'Artix Checkupdates',
|
||||||
|
suffix: 'Web Edition'
|
||||||
|
},
|
||||||
|
packages,
|
||||||
|
maintainers: maintainers
|
||||||
|
},
|
||||||
|
function (err, html) {
|
||||||
|
if (!err) {
|
||||||
|
res.send(html);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error(err);
|
||||||
|
sendError(req, res, 500, 'Something went wrong. Try again later.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/maintainer/:maintainer', async (req, res) => {
|
||||||
|
const maintainer = req.params.maintainer;
|
||||||
|
const packagesOwned = db.getMaintainerPackageCount(maintainer);
|
||||||
|
let packages = prepPackages(db.getPackagesByMaintainer(maintainer, 'move'), 'Move');
|
||||||
|
packages = packages.concat(prepPackages(db.getPackagesByMaintainer(maintainer, 'udate'), 'Update'));
|
||||||
|
if (packagesOwned > 0) {
|
||||||
|
res.render('maintainer',
|
||||||
|
{
|
||||||
|
inliner,
|
||||||
|
site: {
|
||||||
|
prefix: 'Artix Checkupdates',
|
||||||
|
suffix: `${maintainer}'s pending actions`
|
||||||
|
},
|
||||||
|
maintainer,
|
||||||
|
packagesOwned,
|
||||||
|
packages
|
||||||
|
},
|
||||||
|
function (err, html) {
|
||||||
|
if (!err) {
|
||||||
|
res.send(html);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).send('Something went wrong. Try again later.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendError(req, res, 404, 'File not found');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/robots.txt', (_, res) => {
|
||||||
|
res.set('content-type', 'text/plain').send('User-agent: *\nDisallow: /metrics\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
const register = prom.register;
|
||||||
|
|
||||||
|
new prom.Gauge({
|
||||||
|
name: `${METRICPREFIX}pending_packages`,
|
||||||
|
help: 'Number of packages that have pending moves and updates.',
|
||||||
|
labelNames: ['maintainer', 'action'],
|
||||||
|
collect() {
|
||||||
|
maintainers.forEach(m => {
|
||||||
|
this.set({
|
||||||
|
maintainer: `${m}`,
|
||||||
|
action: 'move'
|
||||||
|
}, db.getPackageCountByMaintainer(m, 'move'));
|
||||||
|
this.set({
|
||||||
|
maintainer: `${m}`,
|
||||||
|
action: 'update'
|
||||||
|
}, db.getPackageCountByMaintainer(m, 'udate'));
|
||||||
|
});
|
||||||
|
this.set({
|
||||||
|
maintainer: 'any',
|
||||||
|
action: 'move'
|
||||||
|
}, savedata.move.length);
|
||||||
|
this.set({
|
||||||
|
maintainer: 'any',
|
||||||
|
action: 'update'
|
||||||
|
}, savedata.update.length);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
new prom.Gauge({
|
||||||
|
name: `${METRICPREFIX}watched_packages`,
|
||||||
|
help: 'Number of packages being monitored for updates.',
|
||||||
|
labelNames: ['maintainer'],
|
||||||
|
collect() {
|
||||||
|
maintainers.forEach(m => {
|
||||||
|
this.set({
|
||||||
|
maintainer: `${m}`
|
||||||
|
}, db.getMaintainerPackageCount(m));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/metrics', async (_, res) => {
|
||||||
|
try {
|
||||||
|
res.set('Content-Type', register.contentType);
|
||||||
|
res.end(await register.metrics());
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).send('something went wrong.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use('/assets/', express.static('assets', {
|
||||||
|
maxAge: '30d'
|
||||||
|
}));
|
||||||
|
|
||||||
|
app.use((req, res) => sendError(req, res, 404, 'File not found'));
|
||||||
|
|
||||||
|
this._webserver = app.listen(port, () => console.log(`artix-packy-notifier-web running on port ${port}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
close = () => {
|
||||||
|
this._webserver.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Web;
|
Reference in New Issue
Block a user