1
0
Fork 0
1Panel-Appstore/update_local_appstore.sh

52 lines
1.4 KiB
Bash

check_command() {
command -v "$1" > /dev/null 2>&1 || {
echo >&2 "未找到 $1 命令"
exit 1
}
}
check_command "cp"
check_command "cut"
check_command "git"
check_command "grep"
check_command "rm"
check_command "which"
check_command "xargs"
BASE_DIR=$(which 1pctl | xargs grep '^BASE_DIR=' | cut -d'=' -f2)
if [ -z "$BASE_DIR" ]; then
echo "未找到 1panel 的安装路径"
exit 1
fi
TEMP_DIR="/tmp/localApps"
repo_prefixs=(
'https://github.com'
'https://gh-proxy.com/https://github.com'
'https://edgeone.gh-proxy.com/https://github.com'
'https://gh-proxy.net/github.com'
'https://kkgithub.com'
'https://wget.la/https://github.com'
'https://ghfast.top/https://github.com'
'https://githubfast.com'
'https://ghproxy.net/https://github.com'
)
repo_suffix="/pooneyy/1Panel-Appstore.git"
counter=0
for repo_prefix in "${repo_prefixs[@]}"; do
full_url="${repo_prefix}${repo_suffix}"
git clone --depth 1 -b localApps $full_url $TEMP_DIR > /dev/null 2>&1 && break
counter=$((counter + 1))
done
if [ $counter -eq ${#repo_prefixs[@]} ]; then
echo "All sources have been attempted, but cloning Failed"
else
echo "Successfully cloned from source ${full_url}"
echo "Latest commit in the local repository:"
git -C $TEMP_DIR log --pretty=format:"%s - %h - %cr(%ci)" -n 1
cp -rf $TEMP_DIR/apps/* $BASE_DIR/1panel/resource/apps/local/
rm -rf $TEMP_DIR
fi