-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoco.setup
162 lines (159 loc) · 3.99 KB
/
poco.setup
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
if [[ $LANG == zh_*.UTF-8 ]]; then
curl -sL powerlean.github.io/blob/poco.setup.cn|bash
exit 0
fi
export found="bash"
WHICH() {
for PROGRAM in "$found"; do
RET=1
IFS_SAVE="$IFS"
IFS=:
case $PROGRAM in
*/*)
if [ -f "$PROGRAM" ] && [ -x "$PROGRAM" ]; then
echo "$PROGRAM"
RET=0
fi
;;
*)
for ELEMENT in $PATH; do
if [ -z "$ELEMENT" ]; then
ELEMENT=.
fi
if [ -f "$ELEMENT/$PROGRAM" ] && [ -x "$ELEMENT/$PROGRAM" ]; then
echo "$ELEMENT/$PROGRAM"
RET=0
[[ "$ALLMATCHES" -eq 1 ]] || break
fi
done
;;
esac
IFS="$IFS_SAVE"
if [ "$RET" -ne 0 ]; then
ALLRET=1
fi
done
}
export bin=`WHICH | sed 's/bash//g'`
#特殊字符#
export yellow="\033[33m"
export red="\033[31m"
export green="\033[32m"
export done="\033[0m"
function progress {
point="echo -e -n ${green}.${done}"
sec="0.2"
loop=1
while [[ $loop -lt 4 ]]; do
sleep $sec
$point
loop=$(($loop+1))
done
}
if [ not"$bin" == "not" ]; then
echo -e "${red}请将此问题反馈至:https://github.com/Powerlean/Power-Collector/issues/new ${done}"
exit 2
fi
#分区一
if [ "$mode" == "update" ]; then
curl -sOL powerlean.github.io/blob/poco
curl -sOL powerlean.github.io/blob/poco-rescue
mv poco $bin
mv poco-rescue $bin
chmod +x $bin/poco
chmod +x $bin/poco-rescue
if [ ! -d "$PREFIX/etc/poco/" ]; then
mkdir "$PREFIX/etc/poco/"
fi
if [ ! -f "$PREFIX/etc/poco/poco.conf" ]; then
curl -sOL powerlean.github.io/blob/poco.conf
mv poco.conf "$PREFIX/etc/poco"
fi
if [ ! -f "$PREFIX/etc/poco/poco.data" ]; then
curl -sOL powerlean.github.io/blob/poco.data
mv poco.conf "$PREFIX/etc/poco"
fi
exit 0
fi
#分区二
get_now_timestamp() {
cur_sec_and_ns=`date '+%s-%N'`
echo ${cur_sec_and_ns%-*}
}
end_now_timestamp() {
end=`get_now_timestamp`
second=`expr ${end} - ${begin}`
min=`expr ${second} / 1`
time="s"
if [ "$min" -ge "20" ]; then
des="too slow!"
fi
if [ "$min" -ge "60" ]; then
min=`expr ${second} / 60`
time="min"
fi
echo "Total spant ${min}${time}${des}"
}
if [ -f "$bin/poco" ]; then
clear
curl -s powerlean.github.io/blob/poco.fav
echo -ne "\033[33m\033[4m";echo " https://powerlean.github.io/poco"
echo ""
echo ""
echo -e "${green}Power Collector is existing on your device,if you want to reinstall, please try to remove '${bin}poco'. ${done}"
exit 0
fi
begin=$(get_now_timestamp)
clear
curl -s powerlean.github.io/blob/poco.fav
echo -ne "\033[33m\033[4m";echo "https://powerlean.github.io/poco"
sleep 3
echo -n "The installation should be started"
progress
clear
echo -e "${yellow}[1/6] ${done} Downloading poco.sh" #别问我这个地方为什么写得这么弱智,我也不理解你们这群人为什么要把事情想得那么复杂
curl -#OL powerlean.github.io/blob/poco
clear
echo -e "${yellow}[2/6] ${done} Downloading poco.conf"
curl -#OL powerlean.github.io/blob/poco.conf
clear
echo -e "${yellow}[3/6] ${done} Downloading poco-fix"
curl -#OL powerlean.github.io/blob/poco-rescue
clear
echo -e "${yellow}[4/6] ${done} Downloading poco-remove"
curl -#OL powerlean.github.io/blob/poco-remove
clear
echo -e "${yellow}[5/6] ${done} Updating poco.data"
curl -#OL powerlean.github.io/blob/poco.data
clear
echo -e "${yellow}[6/6] Writing poco.init${done}"
curl -#OL powerlean.github.io/blob/poco.init
clear
curl -s powerlean.github.io/blob/poco.fav
echo -n "Getting ready"
progress
if [ ! -d "$PREFIX/etc/poco/" ]; then
mkdir -p "$PREFIX/etc/poco/"
fi
mv poco.conf "$PREFIX/etc/poco"
mv poco.init "$PREFIX/etc/poco"
mv poco $bin
mv poco-rescue $bin
mv poco-remove $bin
mv poco.data "$PREFIX/etc/poco"
chmod +x $bin/poco
chmod +x $bin/poco-rescue
chmod +x $bin/poco-remove
echo "Done"
if [ -f "$bin/sudo" ]; then
if [ -f "$bin/su" ]; then
echo -e ${yellow}"Please run 'sudo su' to allow PowerCollector's operates"${done}
fi
fi
${set_env}
echo "Power Collector installation is completed"
echo -e "Run ${green}poco help${done} to get help"
end_now_timestamp
echo "Coded by powerlean.github.io"
sleep 4