This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
update.sh
executable file
·66 lines (58 loc) · 2.71 KB
/
update.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
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cd $( dirname -- "$0"; )
function get_commit_version(){
COMMIT=$(curl -s https://api.github.com/repos/hiddify/$1/git/refs/heads/main|jq -r .object.sha)
echo ${COMMIT:0:7}
}
function main(){
PACKAGE_MODE=$(cd hiddify-panel;python3 -m hiddifypanel all-configs|jq -r ".hconfigs.package_mode")
if [[ "$PACKAGE_MODE" == "develop" ]];then
echo "you are in develop mode"
LATEST=$(get_commit_version HiddifyPanel)
INSTALL_DIR=$(pip show hiddifypanel |grep Location |awk -F": " '{ print $2 }')
CURRENT=$(cat $INSTALL_DIR/hiddifypanel/VERSION)
echo "DEVLEOP: hiddify panel version current=$CURRENT latest=$LATEST"
if [[ "$LATEST" != "$CURRENT" ]];then
pip3 uninstall -y hiddifypanel
pip3 install -U git+https://github.com/hiddify/HiddifyPanel
echo $LATEST>$INSTALL_DIR/hiddifypanel/VERSION
echo "__version__='$LATEST'">$INSTALL_DIR/hiddifypanel/VERSION.py
fi
else
CURRENT=`pip3 freeze |grep hiddifypanel|awk -F"==" '{ print $2 }'`
LATEST=`lastversion hiddifypanel --at pip`
echo "hiddify panel version current=$CURRENT latest=$LATEST"
if [[ "$CURRENT" != "$LATEST" ]];then
echo "panel is outdated! updating...."
pip3 install -U hiddifypanel
fi
fi
CURRENT_CONFIG_VERSION=$(cat VERSION)
if [[ "$PACKAGE_MODE" == "develop" ]];then
LAST_CONFIG_VERSION=$(get_commit_version hiddify-central-config)
echo "DEVELOP: Current Config Version=$CURRENT_CONFIG_VERSION -- Latest=$LAST_CONFIG_VERSION"
if [[ "$CURRENT_CONFIG_VERSION" != "$LAST_CONFIG_VERSION" ]];then
wget -c https://github.com/hiddify/hiddify-central-config/archive/refs/heads/main.tar.gz
tar xvzf main.tar.gz --strip-components=1
rm main.tar.gz
echo $LAST_CONFIG_VERSION > VERSION
bash install.sh
fi
else
LAST_CONFIG_VERSION=$(lastversion hiddify/hiddify-central-config)
echo "Current Config Version=$CURRENT_CONFIG_VERSION -- Latest=$LAST_CONFIG_VERSION"
if [[ "$CURRENT_CONFIG_VERSION" != "$LAST_CONFIG_VERSION" ]];then
echo "Config is outdated! updating..."
wget -c $(lastversion hiddify/hiddify-central-config --source)
tar xvzf hiddify-central-config-v$LAST_CONFIG_VERSION.tar.gz --strip-components=1
rm hiddify-central-config-v$LAST_CONFIG_VERSION.tar.gz
bash install.sh
fi
fi
if [[ "$CURRENT" != "$LATEST" ]];then
systemctl restart hiddify-central-panel
fi
}
mkdir -p log/system/
main |& tee log/system/update.log