diff options
| author | vin <vin@vineetk.net> | 2025-03-08 19:32:58 -0500 |
|---|---|---|
| committer | vin <vin@vineetk.net> | 2025-03-08 20:02:32 -0500 |
| commit | fc989a319a11ee08903596194f32e72a6e20abca (patch) | |
| tree | 5cdb827ec68d897eaf002ee88b84a08dd0315d38 /hosts | |
| parent | 750cf5eba12696925c974ddb4b076aac0cb86586 (diff) | |
demiurge: add systemd timer for refreshing invidious tokens
Diffstat (limited to 'hosts')
| -rw-r--r-- | hosts/demiurge/default.nix | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/hosts/demiurge/default.nix b/hosts/demiurge/default.nix index ddd3e63..e97ec57 100644 --- a/hosts/demiurge/default.nix +++ b/hosts/demiurge/default.nix | |||
| @@ -864,6 +864,45 @@ FQsOJMjIvhTm2IiOS8xIaZz7EJORxFjtOkLEIGGZBNK6QcnD714/nYbHSrQx4eNM | |||
| 864 | }; | 864 | }; |
| 865 | }; | 865 | }; |
| 866 | 866 | ||
| 867 | # extra systemd stuff | ||
| 868 | systemd = { | ||
| 869 | services.invidious_token = { | ||
| 870 | script = '' | ||
| 871 | set -euo pipefail | ||
| 872 | |||
| 873 | a="$(${pkgs.podman}/bin/podman run quay.io/invidious/youtube-trusted-session-generator | sed -n 4,5p)" | ||
| 874 | visitor_data=$(echo "$a" | sed -n 1p | cut -d' ' -f2) | ||
| 875 | po_token=$(echo "$a" | sed -n 2p | cut -d' ' -f2) | ||
| 876 | day=$(date +%e | tr -d ' ') | ||
| 877 | |||
| 878 | printf '{"visitor_data": "%s",\n"po_token": "%s",\n' \ | ||
| 879 | "$visitor_data" "$po_token" \ | ||
| 880 | >/run/invidious_settings | ||
| 881 | |||
| 882 | if [ $((day % 2)) -eq 0 ]; then | ||
| 883 | printf '"force_resolve": "ipv6"}\n' >>/run/invidious_settings | ||
| 884 | else | ||
| 885 | printf '"force_resolve": "ipv4"}\n' >>/run/invidious_settings | ||
| 886 | fi | ||
| 887 | |||
| 888 | ${pkgs.systemd}/bin/systemctl restart invidious-sig-helper | ||
| 889 | ${pkgs.systemd}/bin/systemctl restart invidious | ||
| 890 | ''; | ||
| 891 | serviceConfig = { | ||
| 892 | Type = "oneshot"; | ||
| 893 | User = "root"; | ||
| 894 | }; | ||
| 895 | }; | ||
| 896 | |||
| 897 | timers.invidious_token = { | ||
| 898 | timerConfig = { | ||
| 899 | OnCalendar = "hourly"; | ||
| 900 | Persistent = true; | ||
| 901 | }; | ||
| 902 | wantedBy = [ "timers.target" ]; | ||
| 903 | }; | ||
| 904 | }; | ||
| 905 | |||
| 867 | # create caches and use mandoc | 906 | # create caches and use mandoc |
| 868 | documentation.man = { | 907 | documentation.man = { |
| 869 | enable = true; | 908 | enable = true; |
