diff --git a/configurations/host/valkyrie/secrets/default.nix b/configurations/host/valkyrie/secrets/default.nix index df5e536..f290f4d 100644 --- a/configurations/host/valkyrie/secrets/default.nix +++ b/configurations/host/valkyrie/secrets/default.nix @@ -16,6 +16,9 @@ sops.secrets.spotify-client-secret = {}; sops.secrets.youtube-api = {}; sops.secrets.certs = {}; + sops.secrets.steamladder-api = {}; + sops.secrets.webarchive-accesskey = {}; + sops.secrets.webarchive-secretkey = {}; services.openssh.hostKeys = [ { diff --git a/configurations/host/valkyrie/secrets/private/default.nix b/configurations/host/valkyrie/secrets/private/default.nix index 03ab97f..2804327 100644 Binary files a/configurations/host/valkyrie/secrets/private/default.nix and b/configurations/host/valkyrie/secrets/private/default.nix differ diff --git a/configurations/host/valkyrie/secrets/private/tosave.nix b/configurations/host/valkyrie/secrets/private/tosave.nix new file mode 100644 index 0000000..f17afb5 Binary files /dev/null and b/configurations/host/valkyrie/secrets/private/tosave.nix differ diff --git a/configurations/host/valkyrie/secrets/secrets.yaml b/configurations/host/valkyrie/secrets/secrets.yaml index 0fc58ec..259c9de 100644 --- a/configurations/host/valkyrie/secrets/secrets.yaml +++ b/configurations/host/valkyrie/secrets/secrets.yaml @@ -3,6 +3,9 @@ discord-token: ENC[AES256_GCM,data:JQ/6MJvBlJpKzs/L0hFB1LPpQSfJvDdEB6YerVZyDqGo7 spotify-client-id: ENC[AES256_GCM,data:WK7CJGw6mtIG3Jfp59cWx3ool4z1P09TvHcpbOQ2JV0=,iv:EaJ5ecXdmx0Ky+43xZITM811IOo4EisvPSyogXrJXng=,tag:NYTI4vLsWGa695CJ+TIgbw==,type:str] spotify-client-secret: ENC[AES256_GCM,data:TnR+zLLklTfzMdR4woaZWuMVJQ9VIYsFM588GRO6WCY=,iv:cYiqw8ZdMgLeug4ptwPV3L+MeY6xIldfUBfiYg1mFD8=,tag:YDLh6BXFcBHnpdgM7e87wg==,type:str] youtube-api: ENC[AES256_GCM,data:qmpFlFvudS9rXQfN+Th/UrPWCW0mg5GkpMucS/01AmOnlChqtojC,iv:q3bKwI2I6BNa3L9ezKCE1fWT/vZLiJ8uzug1z2z+TWA=,tag:gKG3HTz8jp2LAFh8e8O6sg==,type:str] +steamladder-api: ENC[AES256_GCM,data:m30o5atqugwqn/WbXGkUq5GvqiIKQT0kSRQCtHc1Gxk/dC3YcbDvMw==,iv:duLKl1NvysD0XMaUOkl/6nclMQB6seXcQYkGMrm7K7Y=,tag:9dw+UH10uAdca5fVdlw1Mg==,type:str] +webarchive-accesskey: ENC[AES256_GCM,data:jdKlHsZq2Dkk1BcBfUVv5g==,iv:BXCgPb/2W57PYXxRktInz1LxSEwlw6m3xnQU4TOPMeY=,tag:kK4+InaH7K4D4n1hyGaR+w==,type:str] +webarchive-secretkey: ENC[AES256_GCM,data:nuA9G5dNtrNfbcx0G/GUTg==,iv:RRuTm4kZr5dNjBt9Zvk/NVefHCZYODmRvWAqZizKGJY=,tag:J2V0Q3BzXNWifVVvAkwYyg==,type:str] certs: ENC[AES256_GCM,data:ttmSNTTx51a3L2HTC8RnSphDLHO2OSyIgXQ0YpZGySTdu69mgEyhaiSi+IAXg/1AHKRjpFJgE4fhsLAiW78pNYb+Zg7aDL47YtABO99sTZrZnBxZo6k6itpZ3oClDch2ZALzoXChLroc0tUbZKwsfOwGe3pw9lOJZJT34AhV+BVoXDDLQcpQoxz23Baa8oxklecT6wpJ1u1nW+aAHw33gm41Vw==,iv:b0aNZwaRKBg+ipe5+19BowyFbCjZt52S738om6emYGo=,tag:lUqtcc4vVWKx/fnc19vj7A==,type:str] sops: kms: [] @@ -19,8 +22,8 @@ sops: d2dMUUh1RDB3UnpEdFJsNHpQRXFWemMKc41dlOapTsvH91QLNhdPbrzerPFakOiX J/uoZDMIhsmQxgQM7Fqxr05NywhI/ZjOtJS2bayp73O57xjjMYcyNQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-03-23T14:02:11Z" - mac: ENC[AES256_GCM,data:wMQCs0h/FOEe9zzaTJxrBqQh1KgEgr5J7tdBTIr4frUAUtsD6SCXQ0keVUQ1J5DYEKDTqFbXvM1IetwSKipfKscTbSt1u3hpe30f4EWqTZKRrJtJaiVozJSZ667YWRQu1uWv5VDGXfC4tosejUyJsVUkUEYDqLKEv3z/y3eNa80=,iv:i2PX9y4J1EbASCnbG1XVo+RcxbFV9VOwyRg+DKcUyVc=,tag:6BQkD8ikUHfHI4KhiC5UJA==,type:str] + lastmodified: "2024-04-05T22:42:16Z" + mac: ENC[AES256_GCM,data:KSRGzHipb58uNYaRYXAy3y+D9cBG53RGxZpNrx2gy+CHbGtkUW1SWc4PPrBwBhb6+TN0vb1zHuOB4HK4Bys/jqmvGgVkO2VKj15MTFMpF5n6w0blFM7d5bCDydHAhvXEZA/PFWq97DTI1Zxb+N/HWJlefKCzYOHHWj7i4leKNjk=,iv:88Ekp0sjEo5UTBLUyYSrkP+MbIFcCmegclJIK3+0jOQ=,tag:H/ESeQhC1PEF00RiDnamyw==,type:str] pgp: - created_at: "2024-03-21T22:55:36Z" enc: |- diff --git a/configurations/host/valkyrie/services/default.nix b/configurations/host/valkyrie/services/default.nix index 1eda642..ae57beb 100644 --- a/configurations/host/valkyrie/services/default.nix +++ b/configurations/host/valkyrie/services/default.nix @@ -5,11 +5,13 @@ ./pleroma.nix ./pihole.nix ./dcbot.nix + ./saveyoursoul.nix ]; services.adguardhome.enable = true; valkyrieService.pihole.enable = false; valkyrieService.pleroma.enable = true; valkyrieService.dcbot.enable = true; + valkyrieService.saveyoursoul.enable = true; } diff --git a/configurations/host/valkyrie/services/saveyoursoul.nix b/configurations/host/valkyrie/services/saveyoursoul.nix new file mode 100644 index 0000000..7086c0d --- /dev/null +++ b/configurations/host/valkyrie/services/saveyoursoul.nix @@ -0,0 +1,75 @@ +{ config, pkgs, lib, materusArg, ... }: +{ + options.valkyrieService.saveyoursoul.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable saveyoursoul, web archive"; + + + + + config = + let + cfg = config.valkyrieService.saveyoursoul; + in + lib.mkIf cfg.enable { + systemd.timers.saveyoursoul = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-1,7,14,21 3:00:00"; + Persistent = true; + Unit = "saveyoursoul.service"; + }; + }; + + systemd.services.saveyoursoul = { + description = "Make curl requests to archive related things"; + path = [ pkgs.coreutils pkgs.util-linux pkgs.curl ]; + serviceConfig.Type = "oneshot"; + serviceConfig.RemainAfterExit = false; + script = '' + STEAM_IDS=( ${ builtins.foldl' (x: y: x +"\""+ y + "\" ") "" materusArg.to_save.steamids }) + EXTRA_LINKS=( ${ builtins.foldl' (x: y: x +"\""+ y + "\" ") "" materusArg.to_save.extraLinks }) + + steamladder() { + for id in ''${STEAM_IDS[@]}; do + curl -X POST -H "Authorization: Token ''$(cat ${config.sops.secrets.steamladder-api.path})" \ + "https://steamladder.com/api/v1/profile/$id/" + done; + } + + webarchive(){ + for id in ''${STEAM_IDS[@]}; do + curl -X POST -H "Accept: application/json" \ + -H "Authorization: LOW ''$(cat ${config.sops.secrets.webarchive-accesskey.path}):''$(cat ${config.sops.secrets.webarchive-secretkey.path})" \ + -d"url=https://steamcommunity.com/profiles/$id" \ + -d"capture_outlinks=1" \ + -d"capture_screenshot=on" \ + -d"capture_all=on" \ + "https://web.archive.org/save"; + sleep 180; + done; + + + for link in ''${EXTRA_LINKS[@]}; do + curl -X POST -H "Accept: application/json" \ + -H "Authorization: LOW ''$(cat ${config.sops.secrets.webarchive-accesskey.path}):''$(cat ${config.sops.secrets.webarchive-secretkey.path})" \ + -d"url=$link" \ + -d"capture_outlinks=1" \ + -d"capture_screenshot=on" \ + -d"capture_all=on" \ + "https://web.archive.org/save"; + sleep 180; + done; + + } + + + + steamladder & + webarchive + wait + ''; + }; + + }; + + +}