This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartup.sh
executable file
·69 lines (53 loc) · 2.08 KB
/
startup.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Foundry Cloud Credentials
FC_USERNAME=$1
FC_PASSWORD=$2
FC_FURNACES=$3
#
FC_PROTOCOL="http://"
FC_HOST="api.foundry.zorc:800"
FC_LOGIN_PATH="/login"
FC_LOGIN_URL="$FC_PROTOCOL$FC_HOST$FC_LOGIN_PATH"
FC_REQUEST_HTTP_METHOD="-X POST"
FC_REQUEST_PAYLOAD="-d '{\"username\": \"$FC_USERNAME\",\"password\": \"$FC_PASSWORD\"}'"
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
function usage () {
echo "Invalid arguments"
if [ "$1" = "username" ]; then
echo "Username missing."
fi
if [ "$1" = "password" ]; then
echo "Password missing."
fi
if [ "$1" = "furnaces"]; then
echo "Furnaces missing"
fi
echo "\nusage: $0 <foundry_cloud-username> <foundry_cloud-password> <foundry_cloud-furnaces>"
exit 2
}
# Validating Data
[[ -z "$FC_USERNAME" ]] && usage 'username'
[[ -z "$FC_PASSWORD" ]] && usage 'password'
[[ -z "$FC_FURNACES" ]] && usage 'furnaces'
echo 'Logging in to Hengli Foundry Cloud.'
echo "curl"
sleep 15
CREDENTIALS=$(curl -s -d "{\"username\": \"$FC_USERNAME\",\"password\": \"$FC_PASSWORD\"}" \
-H "Content-Type: application/json" -H "Accept: application/json" \
$FC_REQUEST_HEADERS $FC_REQUEST_HTTP_METHOD $FC_LOGIN_URL)
ACCESS_TOKEN=$(echo $CREDENTIALS | python3 -c "import sys, json; print(json.load(sys.stdin)['access'])" 2>&1)
REFRESH_TOKEN=$(echo $CREDENTIALS | python3 -c "import sys, json; print(json.load(sys.stdin)['refresh'])" 2>&1)
echo $ACCESS_TOKEN
echo $REFRESH_TOKEN
FC_MONITORING_HOST="foundry.zorc:800"
FC_MONITORING_URL_PARAMETERS="accessToken=$ACCESS_TOKEN&refreshToken=$REFRESH_TOKEN&fullScreen=true&furnaces=$FURNACES"
FC_MONITORING_PATH="/monitoring/melt-shop/detailed-displays?$FC_MONITORING_URL_PARAMETERS"
FC_MONITORING_URL=$FC_PROTOCOL$FC_MONITORING_HOST$FC_MONITORING_PATH
echo $FC_MONITORING_URL
xset s noblank
xset s off
xset -dpms
export DISPLAY=:0
unclutter -idle 0.5 -root &
/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk $FC_MONITORING_URL &