summaryrefslogtreecommitdiff
path: root/customized/fetch.sh
diff options
context:
space:
mode:
Diffstat (limited to 'customized/fetch.sh')
-rw-r--r--customized/fetch.sh55
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 @@
1source $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.
8curl="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.
20echo -n "$password" > password
21# Might as well hide the username as well.
22echo -n "$username" > username
23
24# Get a CSRF token.
25csrf=$($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
34if 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
38else
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
55fi