diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-09-13 04:45:37 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-09-13 04:45:37 +0200 |
commit | 7f0f97c06245b21a51210054e25fceab4b577cea (patch) | |
tree | 71d2b033d348f6741d417d1a3578c3b98b3c6925 /customized/fetch.sh | |
parent | 7b7ef4e9ba4d3c77bd874f4851f5165c06a27a5a (diff) | |
download | nixos-7f0f97c06245b21a51210054e25fceab4b577cea.tar nixos-7f0f97c06245b21a51210054e25fceab4b577cea.tar.gz nixos-7f0f97c06245b21a51210054e25fceab4b577cea.tar.bz2 nixos-7f0f97c06245b21a51210054e25fceab4b577cea.tar.xz nixos-7f0f97c06245b21a51210054e25fceab4b577cea.zip |
simplify factorio again
Diffstat (limited to 'customized/fetch.sh')
-rw-r--r-- | customized/fetch.sh | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/customized/fetch.sh b/customized/fetch.sh deleted file mode 100644 index 8ea615a1..00000000 --- a/customized/fetch.sh +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | source $stdenv/setup | ||
2 | |||
3 | # Curl flags to increase reliability a bit. | ||
4 | # | ||
5 | # Can't use fetchurl, for several reasons. One is that we definitely | ||
6 | # don't want --insecure for the login, though we need it for the | ||
7 | # download as their download cert isn't in the standard linux bundle. | ||
8 | curl="curl \ | ||
9 | --max-redirs 20 \ | ||
10 | --retry 3 \ | ||
11 | --cacert $cacert/etc/ssl/certs/ca-bundle.crt \ | ||
12 | -b cookies \ | ||
13 | -c cookies \ | ||
14 | $curlOpts \ | ||
15 | $NIX_CURL_FLAGS" | ||
16 | |||
17 | # We don't want the password to be on any program's argv, as it may be | ||
18 | # visible in /proc. Writing it to file with echo should be safe, since | ||
19 | # it's a shell builtin. | ||
20 | echo -n "$password" > password | ||
21 | # Might as well hide the username as well. | ||
22 | echo -n "$username" > username | ||
23 | |||
24 | # Get a CSRF token. | ||
25 | csrf=$($curl $loginUrl | xidel - -e '//input[@id="csrf_token"]/@value') | ||
26 | |||
27 | # Log in. We don't especially care about the result, but let's check if login failed. | ||
28 | $curl --data-urlencode csrf_token="$csrf" \ | ||
29 | --data-urlencode username@username \ | ||
30 | --data-urlencode password@password \ | ||
31 | -d action=Login \ | ||
32 | $loginUrl -D headers > /dev/null | ||
33 | |||
34 | if grep -q 'Location: https://' headers; then | ||
35 | # Now download. We need --insecure for this, but the sha256 should cover us. | ||
36 | $curl --insecure --location $url > $out | ||
37 | set +x | ||
38 | else | ||
39 | set +x | ||
40 | echo "Login failed (username: ‘$username’)" | ||
41 | echo 'Please set username and password with config.nix,' | ||
42 | echo 'or /etc/nix/nixpkgs-config.nix if on NixOS.' | ||
43 | echo | ||
44 | echo 'Example:' | ||
45 | echo '{' | ||
46 | echo ' packageOverrides = pkgs: rec {' | ||
47 | echo ' factorio = pkgs.factorio.override {' | ||
48 | echo ' username = "<username or email address>";' | ||
49 | echo ' password = "<password>";' | ||
50 | echo ' };' | ||
51 | echo ' };' | ||
52 | echo '}' | ||
53 | |||
54 | exit 1 | ||
55 | fi | ||