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
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
(
|
(
|
||||||
transmission-remote -n 'transmission:transmission' -l |
|
transmission-remote -n 'transmission:transmission' -l
|
||||||
from ssv |
|
| from ssv
|
||||||
to html |
|
| 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>' |
|
| 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
|
| 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
|
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
|
# Download the torrents archive and save to temporary directory
|
||||||
let torrent_zip = ($temp_dir | path join "armbian-torrents.zip")
|
let torrent_zip = ($temp_dir | path join "armbian-torrents.zip")
|
||||||
(
|
(
|
||||||
http get -r "https://dl.armbian.com/torrent/all-torrents.zip" |
|
http get -r "https://dl.armbian.com/torrent/all-torrents.zip"
|
||||||
save -r $torrent_zip
|
| save -r $torrent_zip
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test torrent_zip for corruption
|
# 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
|
# Create list of current active Armbian torrent ids
|
||||||
let armbian_torrent_ids = (
|
let armbian_torrent_ids = (
|
||||||
transmission-remote -n 'debian-transmission:debian-transmission' -l |
|
transmission-remote -n 'debian-transmission:debian-transmission' -l
|
||||||
from ssv |
|
| from ssv
|
||||||
drop nth 0 |
|
| drop nth 0
|
||||||
drop |
|
| drop
|
||||||
find "Armbian" |
|
| find "Armbian"
|
||||||
get ID
|
| get ID
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove torrents from armbian_torrent_ids
|
# Remove torrents from armbian_torrent_ids
|
||||||
@ -43,9 +43,9 @@ $armbian_torrent_ids | each {
|
|||||||
|
|
||||||
# Add new/updated Armbian torrents
|
# Add new/updated Armbian torrents
|
||||||
(
|
(
|
||||||
ls ($temp_dir | path join "torrent-tmp") |
|
ls ($temp_dir | path join "torrent-tmp")
|
||||||
get name |
|
| get name
|
||||||
each {
|
| each {
|
||||||
|torrent|
|
|torrent|
|
||||||
transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)"
|
transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)"
|
||||||
} | ignore
|
} | ignore
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#!/usr/bin/env nu
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
(
|
let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
|
||||||
transmission-remote -l |
|
let new_head = (
|
||||||
from ssv |
|
["<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>"]
|
||||||
to html |
|
| str join ' '
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
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