mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Refactor
This commit is contained in:
parent
7901f31322
commit
bdc8562d90
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
(
|
||||
transmission-remote -n 'transmission:transmission' -l |
|
||||
from ssv |
|
||||
to html |
|
||||
str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Armbian torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>' |
|
||||
save -f -r /home/jas/staging/armbian-torrentstats.html
|
||||
transmission-remote -n 'transmission:transmission' -l
|
||||
| from ssv
|
||||
| to html
|
||||
| str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Armbian torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>'
|
||||
| save -f -r /home/jas/staging/armbian-torrentstats.html
|
||||
)
|
||||
|
||||
scp /home/jas/staging/armbian-torrentstats.html jas@192.168.2.102:/home/jas/public/html/armbian-torrentstats.html
|
||||
|
@ -8,8 +8,8 @@ chmod 700 $temp_dir
|
||||
# Download the torrents archive and save to temporary directory
|
||||
let torrent_zip = ($temp_dir | path join "armbian-torrents.zip")
|
||||
(
|
||||
http get -r "https://dl.armbian.com/torrent/all-torrents.zip" |
|
||||
save -r $torrent_zip
|
||||
http get -r "https://dl.armbian.com/torrent/all-torrents.zip"
|
||||
| save -r $torrent_zip
|
||||
)
|
||||
|
||||
# Test torrent_zip for corruption
|
||||
@ -23,12 +23,12 @@ unzip -o $torrent_zip -d ($temp_dir | path join "torrent-tmp") | ignore
|
||||
|
||||
# Create list of current active Armbian torrent ids
|
||||
let armbian_torrent_ids = (
|
||||
transmission-remote -n 'debian-transmission:debian-transmission' -l |
|
||||
from ssv |
|
||||
drop nth 0 |
|
||||
drop |
|
||||
find "Armbian" |
|
||||
get ID
|
||||
transmission-remote -n 'debian-transmission:debian-transmission' -l
|
||||
| from ssv
|
||||
| drop nth 0
|
||||
| drop
|
||||
| find "Armbian"
|
||||
| get ID
|
||||
)
|
||||
|
||||
# Remove torrents from armbian_torrent_ids
|
||||
@ -43,9 +43,9 @@ $armbian_torrent_ids | each {
|
||||
|
||||
# Add new/updated Armbian torrents
|
||||
(
|
||||
ls ($temp_dir | path join "torrent-tmp") |
|
||||
get name |
|
||||
each {
|
||||
ls ($temp_dir | path join "torrent-tmp")
|
||||
| get name
|
||||
| each {
|
||||
|torrent|
|
||||
transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)"
|
||||
} | ignore
|
||||
|
@ -1,11 +1,15 @@
|
||||
#!/usr/bin/env nu
|
||||
|
||||
(
|
||||
transmission-remote -l |
|
||||
from ssv |
|
||||
to html |
|
||||
str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>' |
|
||||
save -f -r /home/jas/public/html/torrentstats.html
|
||||
let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
|
||||
let new_head = (
|
||||
["<html><head><title>Torrent Stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
|
||||
| str join ' '
|
||||
)
|
||||
|
||||
chown jas:jas /home/jas/public/html/torrentstats.html
|
||||
(
|
||||
transmission-remote -l
|
||||
| from ssv
|
||||
| to html
|
||||
| str replace ($old_head) ($new_head)
|
||||
| save -f -r /home/jas/public/html/torrentstats.html
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user