forked from hiddify/hiddify-central-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·141 lines (110 loc) · 4 KB
/
install.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
cd $( dirname -- "$0"; )
echo "we are going to install :)"
export DEBIAN_FRONTEND=noninteractive
if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run by root' >&2
# exit 1
fi
source ./common/ticktick.sh
function set_config_from_hpanel(){
hiddify=`cd hiddify-panel;python3 -m hiddifypanel all-configs`
tickParse "$hiddify"
tickVars
function setenv () {
echo $1=$2
export $1="$2"
}
setenv FIRST_SETUP ``hconfigs[first_setup]``
setenv DB_VERSION ``hconfigs[db_version]``
setenv BASE_PROXY_PATH ``hconfigs[proxy_path]``
setenv DECOY_DOMAIN ``hconfigs[decoy_domain]``
setenv ENABLE_FIREWALL ``hconfigs[firewall]``
setenv ENABLE_NETDATA ``hconfigs[netdata]``
setenv ENABLE_AUTO_UPDATE ``hconfigs[auto_update]``
setenv SERVER_IP `curl --connect-timeout 1 -s https://v4.ident.me/`
setenv SERVER_IPv6 `curl --connect-timeout 1 -s https://v6.ident.me/`
function get () {
group=$1
index=`printf "%012d" "$2"`
member=$3
var="__tick_data_${group}_${index}_${member}";
echo ${!var}
}
MAIN_DOMAIN=
for i in $(seq 0 ``parent_domains.length()``); do
domain=$(get parent_domains $i domain)
if [ "" == "$MAIN_DOMAIN" ];then
MAIN_DOMAIN="$domain"
elif [ "" != "$domain" ];then
MAIN_DOMAIN="$domain;$MAIN_DOMAIN"
fi
done
setenv MAIN_DOMAIN $MAIN_DOMAIN
}
function runsh() {
command=$1
if [[ $3 == "false" ]];then
command=uninstall.sh
fi
pushd $2 >>/dev/null
# if [[ $? != 0]];then
# echo "$2 not found"
# fi
if [[ $? == 0 && -f $command ]];then
echo "==========================================================="
echo "===$command $2"
echo "==========================================================="
bash $command
fi
popd >>/dev/null
}
function do_for_all() {
systemctl daemon-reload
runsh $1.sh common
runsh $1.sh caddy
}
function check_installation_ok(){
for s in caddy hiddify-central-panel;do
if [[ "$(systemctl is-active $s)" != "active" ]];then
sleep 5
if [[ "$(systemctl is-active $s)" != "active" ]];then
>&2 echo "Error! Important Service $s can not be activated"
exit 2
fi
fi
done
}
function main(){
which hiddifypanel
if [[ "$?" != 0 ]];then
echo "/opt/hiddify-central-config/menu.sh">>~/.bashrc
echo "cd /opt/hiddify-central-config/">>~/.bashrc
fi
export MODE="$1"
runsh install.sh hiddify-panel
set_config_from_hpanel
if [[ $DB_VERSION == "" ]];then
>&2 echo "ERROR!!!! There is an error in the installation of python panel. Exit...."
exit 1
fi
if [[ -z "$DO_NOT_INSTALL" || "$DO_NOT_INSTALL" == false ]];then
do_for_all install
systemctl daemon-reload
fi
if [[ -z "$DO_NOT_RUN" || "$DO_NOT_RUN" == false ]];then
do_for_all run
fi
check_installation_ok
echo ""
echo ""
bash status.sh
echo "==========================================================="
echo "Finished! Thank you for helping Iranians to skip filternet."
echo "Please open the following link in the browser for client setup"
(cd hiddify-panel;python3 -m hiddifypanel admin-links)
echo "---------------------Finished!------------------------"
systemctl restart hiddify-central-panel
}
mkdir -p log/system/
main $@|& tee log/system/0-install.log