-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
46 lines (39 loc) · 1.51 KB
/
setup.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
#!/bin/bash
version="1.0.3"
function installJava(){
command -v apt >/dev/null 2>&1 && (apt-get update; apt-get install openjdk-8-jdk -y; return;)
command -v yum >/dev/null 2>&1 && (yum install java-1.8.0-openjdk -y; return;)
}
function installUnzip(){
command -v apt >/dev/null 2>&1 && (apt-get update; apt-get install unzip -y; return;)
command -v yum >/dev/null 2>&1 && (yum install unzip -y; return;)
}
function download(){
wget -O "/tmp/BILIBILI-HELPER.zip" "https://glare.now.sh/JunzhouLiu/BILIBILI-HELPER/BILIBILI-HELPER-v${1}.zip"
mkdir "${HOME}/BILIBILI-HELPER"
command -v unzip >/dev/null 2>&1 || installUnzip
unzip -o "/tmp/BILIBILI-HELPER.zip" -d "${HOME}/BILIBILI-HELPER"
mv "${HOME}/BILIBILI-HELPER/BILIBILI-HELPER-v${1}.jar" "${HOME}/BILIBILI-HELPER/BILIBILI-HELPER.jar" -f
}
function setCron(){
file="/var/spool/cron/${USER}"
if [ ! -f "$file" ]; then
touch "$file"
else
find=`grep "BILIBILI-HELPER" "$file"`
if [ -z "$find" ]; then
echo "" >> "$file"
echo "30 10 * * * cd ${HOME}/BILIBILI-HELPER; java -jar ./BILIBILI-HELPER.jar ${1} ${2} ${3} ${4} >>/var/log/cron.log 2>&1 &" >> "$file"
service crond reload
service cron reload
fi
fi
}
read -p "请粘贴SESSDATA并回车:" SESSDATA
read -p "请粘贴DEDEUSERID并回车:" DEDEUSERID
read -p "请粘贴BILI_JCT并回车:" BILI_JCT
read -p "请粘贴SCKEY并回车:" SCKEY
download $version
setCron "${DEDEUSERID}" "${SESSDATA}" "${BILI_JCT}" "${SCKEY}"
command -v java >/dev/null 2>&1 || installJava
echo "执行完成"