Created
November 15, 2024 13:51
-
-
Save chrisdone-artificial/1f8437e9309e6c5a502565501509f1cb to your computer and use it in GitHub Desktop.
reflect cron hell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@fsn1-cd-1:~# cat /root/brossa-cd/scripts/reflect-cron.hell | |
#!/usr/bin/env hell | |
-- assumes: jq, docker | |
main = do | |
input <- Text.readProcessStdout_ $ Process.proc "docker" ["ps","--format","json"] | |
let lines = Text.lines input | |
Monad.forM_ lines \json -> do | |
labels' <- Main.jq json [".Labels","-r"] | |
let labels = Text.splitOn "," labels' | |
Monad.forM_ labels \label -> | |
Monad.when (Text.isPrefixOf "artificial.brossa.name=reflect" label) do | |
id <- do text <- Main.jq json [".ID","-r"] | |
Monad.return $ Text.strip text | |
Process.runProcess_ $ Process.proc "docker" ["stop", id] | |
Process.runProcess_ $ Process.proc "docker" ["rm", id] | |
jq = \json args -> Text.readProcessStdout_ $ Text.setStdin json $ Process.proc "jq" args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment