forked from boredazfcuk/docker-icloudpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreauth.sh
32 lines (25 loc) · 912 Bytes
/
reauth.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/ash
run_as() {
local command_to_run
command_to_run="${1}"
if [ "$(id -u)" = 0 ]; then
su "${user:=user}" -s /bin/ash -c "${command_to_run}"
else
/bin/ash -c "${command_to_run}"
fi
}
user="$(grep "^user=" /config/icloudpd.conf | awk -F= '{print $2}')"
apple_id="$(grep apple_id /config/icloudpd.conf | awk -F= '{print $2}')"
auth_china="$(grep auth_china /config/icloudpd.conf | awk -F= '{print $2}')"
cookie_file="$(echo -n "${apple_id//[^a-z0-9_]/}")"
if [ "${auth_china:=false}" = true ]; then
auth_domain="cn"
fi
if [ -f "/config/${cookie_file}" ]; then
rm "/config/${cookie_file}"
fi
if [ -f "/config/${cookie_file}.session" ]; then
rm "/config/${cookie_file}.session"
fi
run_as "/opt/icloudpd/bin/icloudpd --username ${apple_id} --cookie-directory /config --auth-only --domain ${auth_domain:=com} | tee /tmp/icloudpd/reauth.log"
rm /tmp/icloudpd/reauth.log