-
Notifications
You must be signed in to change notification settings - Fork 119
/
onekey.sh
100 lines (94 loc) · 2.92 KB
/
onekey.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
#!/bin/bash
#
# [QuickBox Lite One Key Installation wrapper ]
#
# GitHub: https://github.com/amefs/quickbox-lite
# Author: Amefs
# Current version: v1.5.6
# URL:
# Original Repo: https://github.com/QuickBox/QB
# Credits to: QuickBox.io
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#################################################################################
if [[ $1 == "--dev" ]]; then
if [[ ! -d /install ]]; then
mkdir /install/
fi
if [[ ! -f /install/.developer.lock ]]; then
touch /install/.developer.lock
fi
branch="--branch development"
ExtraArgs=${*:2}
elif [[ $1 == "--legacy" ]]; then
if [[ ! -d /install ]]; then
mkdir /install/
fi
if [[ ! -f /install/.legacy.lock ]]; then
touch /install/.legacy.lock
fi
branch="--branch legacy"
ExtraArgs=${*:2}
else
ExtraArgs=${*:1}
fi
_norm=$(tput sgr0)
_red=$(tput setaf 1)
_green=$(tput setaf 2)
_tan=$(tput setaf 3)
_cyan=$(tput setaf 6)
function _print() {
printf "${_norm}%s${_norm}\n" "$@"
}
function _info() {
printf "${_cyan}➜ %s${_norm}\n" "$@"
}
function _success() {
printf "${_green}✓ %s${_norm}\n" "$@"
}
function _warning() {
printf "${_tan}⚠ %s${_norm}\n" "$@"
}
function _error() {
printf "${_red}✗ %s${_norm}\n" "$@"
}
function _checkroot() {
if [[ $EUID != 0 ]]; then
_error "You do not have root privileges, please run \"sudo su -\" and try again!"
exit 1
fi
}
_checkroot
DEBIAN_FRONTEND=noninteractive apt-get -yqq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update
DEBIAN_FRONTEND=noninteractive apt-get -yqq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
if [ "$?" -eq 2 ]; then
_warning "dpkg database is locked."
_info "fixing dpkg lock..."
rm -f /var/lib/dpkg/updates/0*
locks=$(find /var/lib/dpkg/lock* && find /var/cache/apt/archives/lock*)
if [[ ${locks} == $(find /var/lib/dpkg/lock* && find /var/cache/apt/archives/lock*) ]]; then
for l in ${locks}; do
rm -rf "${l}"
done
dpkg --configure -a
DEBIAN_FRONTEND=noninteractive apt-get -yqq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update >/dev/null 2>&1
DEBIAN_FRONTEND=noninteractive apt-get -yqq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade >/dev/null 2>&1
fi
if [ "$?" -eq 2 ]; then
_error "unable to resolve dpkg lock, exit...."
exit 1
fi
fi
apt-get -yqq install git lsb-release dos2unix screen
if [[ -d /etc/QuickBox ]]; then
rm -rf /etc/QuickBox
fi
URL="https://github.com/amefs/quickbox-lite.git"
# shellcheck disable=SC2086
git clone --recursive ${branch} "${URL}" /etc/QuickBox
dos2unix /etc/QuickBox/setup.sh
cd /etc/QuickBox || exit
screen -dmS qbox-install -T xterm
screen -S qbox-install -X stuff "sleep 3; bash /etc/QuickBox/setup.sh $ExtraArgs;\n"
screen -rA qbox-install