forked from bambrman/yota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.sh
124 lines (99 loc) · 3.14 KB
/
gen.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#/bin/bash
if [ $# != "1" ]
then
echo "Usage: `basename $0` personal-cabinet.htm"
exit 1
fi
x=$(cat $1)
y=${x#*\"steps\":}
y=${y%\"optionList\"*}
y=${y#*\"code\":\"}
y=${y#*speedNumber\":\"}
i=0
acod=""
asn=""
while [ true ]; do
y1=${y#*\"code\":\"}
if [ "$y1" = "$y" ]; then
break
fi
y=$y1
cod=${y%%\"*}
y=${y#*speedNumber\":\"}
sn=${y%%\"*}
if [ "$sn" = "<div class=\\" ]; then
sn="max"
fi
acod="$acod"" ""$cod"
asn="$asn"" ""$sn"
done
#---------------------------------------------------------
#---------------------------------------------------------
#---------------------------------------------------------
echo "#!/bin/bash" > n_yota.sh
echo "" >> n_yota.sh
echo "Number_of_expected_args=3" >> n_yota.sh
echo "E_WRONG_ARGS=85" >> n_yota.sh
echo "" >> n_yota.sh
echo "script_usage=\"<login> <passwd> <speed>" >> n_yota.sh
echo "<speed in kbps>""$asn"")\"" >> n_yota.sh
echo "if [ \$# != \$Number_of_expected_args ]" >> n_yota.sh
echo "then" >> n_yota.sh
echo "echo \"Usage:\`basename \$0\` \$script_usage\"" >> n_yota.sh
echo "exit \$E_WRONG_ARGS" >> n_yota.sh
echo "fi " >> n_yota.sh
echo "" >> n_yota.sh
echo "case \$3 in" >> n_yota.sh
i_num=1
for q in $asn; do
p=$(echo $acod | awk '{print $'"${i_num}"' }')
if [ "$i_num" = "1" ]; then
pd=$p
fi
echo $q") TARIF=\""$p"\";;" >> n_yota.sh
let i_num++
done
echo "*) TARIF=\"$pd\";;">>n_yota.sh
echo "esac" >> n_yota.sh
echo "pr=\`curl -c cook.txt -s -k -L -d \"IDToken1=\$1&IDToken2=\$2&IDToken3=\$2&goto=https%3A%2F%2Fmy.yota.ru%3A443%2Fselfcare%2FloginSuccess&gotoOnFail=https%3A%2F%2Fmy.yota.ru%3A443%2Fselfcare%2FloginError&old-token=&org=customer\" https://login.yota.ru/UI/Login | grep \"Yota - Вход в Личный кабинет/Регистрация\"\`">>n_yota.sh
echo "" >> n_yota.sh
echo "if [ \${#pr} -eq 0 ]" >> n_yota.sh
echo "then" >> n_yota.sh
echo "pr=\`curl -b cook.txt -s -k -L https://my.yota.ru/selfcare/devices | grep \"\\\"product\\\" va\"\`" >> n_yota.sh
echo " if [ \${#pr} -eq 0 ]" >> n_yota.sh
echo " then" >> n_yota.sh
echo "echo \"Personal cabinet error!!!\"" >> n_yota.sh
echo "logger -t YOTA \"Personal cabinet error!!!\"" >> n_yota.sh
echo "exit 1" >> n_yota.sh
echo "fi" >> n_yota.sh
echo "else
echo \"Login error!!!\"
logger -t YOTA \"Login error!!!\"
exit 1
fi
pr=\${pr#*value=\\\"}
pr=\${pr%\\\" />}
OCODE=\$TARIF" >> n_yota.sh
echo "od=\`curl -b cook.txt -s -k -L -d \"product=\$pr&offerCode=\$OCODE&homeOfferCode=&areOffersAvailable=false&period=&status=custom&autoprolong=0&isSlot=false&resourceId=¤tDevice=1&username=&isDisablingAutoprolong=false\" https://my.yota.ru/selfcare/devices/changeOffer | grep \"offerDisabled\"\`">>n_yota.sh
echo "
if [ \${#od} -eq 0 ]
then
echo \"ChangeOffer Error!!!\"
logger -t YOTA \"ChangeOffer Error!!!\"
exit 1
fi " >> n_yota.sh
echo "
od=\${od#*offerDisabled}
od=\${od%%amountNumber*}
dn=\${od##*:}
dn=\$\"Days: \"\${dn%,*}
" >> n_yota.sh
echo "
speed=\${od#*speedNumber\\\":}
speed=\$\"Speed: \"\${speed%%,*}
echo \$speed \$dn
logger -t YOTA \$speed \$dn
exit 0
" >> n_yota.sh
echo "n_yota.sh created"
exit 0