-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathql
More file actions
executable file
·153 lines (137 loc) · 3.21 KB
/
Copy pathql
File metadata and controls
executable file
·153 lines (137 loc) · 3.21 KB
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
#!/usr/bin/env bash
# Easy alias for escape codes
function echo() {
command echo -e "${@}"
}
function help_menu() {
echo
echo "${BOLD}QLauncher menu${RST}"
echo
echo "${BOLD}USAGE:${RST} ${0} <options>"
echo
echo "${BOLD}EXAMPLE:${RST} ${0} -s"
echo
echo "${BOLD}EXAMPLE:${RST} ${0} --status"
echo
echo " -b | --bind: Bind account to QQQ App"
echo " -c | --check: Verify Installation"
echo " -f | --freeze: Stop miner"
echo " -h | --help: Help menu"
echo " -k | --kickoff: Start miner"
echo " -r | --restart: Restart miner"
echo " -s | --status: Status miner"
echo " -S | --sn: Change Serial Number"
echo " -u | --update: Update QLauncher"
echo
}
function setup_variables() {
DIRQL="$HOME/qlauncher"
ZIP="app.tar.gz"
BOLD="\033[1m"
RST="\033[0m"
QLS="$DIRQL/qlauncher.sh"
}
function bind() {
echo
echo "Scan the QR code below"
echo
qrencode "NAS-QNAP-$(cat /etc/qlauncher)" -t ANSIUTF8 -o -
echo
echo "You can also use the link below"
$QLS bind
echo
}
function check() {
echo
echo "Current SN : $(cat /etc/qlauncher)"
echo
$QLS check
echo
}
function freeze() {
$QLS stop
}
function kickoff() {
$QLS start
}
function restart() {
$QLS restart
}
function status() {
$QLS status
}
function change_sn() {
read -r -p "do you want to change the serial number? [y/N]" PROMPT
if [[ $PROMPT =~ [yY](es)* ]]; then
echo
echo "Enter new serial number : "
read -r NEWSN
echo "Applying new serial number"
echo "${NEWSN}" > /etc/machine-id
echo "${NEWSN}" > /etc/qlauncher
echo "Done."
else
echo
echo "Use default serial number"
fi
}
function sn() {
if [[ -e /etc/qlauncher ]]; then
echo
echo "Serial Number already exist"
echo
change_sn
echo
else
echo
echo "Serial Number doesn't exist"
echo
change_sn
echo
fi
}
function zipdl() {
wget https://github.com/poseidon-network/qlauncher-linux/releases/latest/download/ql-linux.tar.gz -O "${ZIP}"
tar -vxzf "${ZIP}" -C "${DIRQL}"
echo "start QLauncher"
kickoff
}
function update() {
if [[ -d ${DIRQL} ]]; then
echo "folder exist, deleting current qlauncher folder"
freeze
rm -rf ${DIRQL}
mkdir ${DIRQL}
if [[ -e ${ZIP} ]]; then
echo
# remove package if exist then start updating
rm -rf "${ZIP}"
zipdl
else
echo
# seems file doesn't exist, lets start updating
zipdl
rm -rf "${ZIP}"
fi
else
echo
echo "QLauncher doesn't exist, read the README for how to install it"
echo
fi
}
function parse_parameters() {
case "${1}" in
"-b"|"--bind") bind ;;
"-c"|"--check") check ;;
"-f"|"--freeze") freeze ;;
"-k"|"--kickoff") kickoff ;;
"-r"|"--restart") restart ;;
"-s"|"--status") status ;;
"-S"|"--sn") sn ;;
"-u"|"--update") update ;;
# HELP!
"-h"|"--help"|*) help_menu ;;
esac
}
setup_variables
parse_parameters "${@}"