mirror of
https://github.com/QYG2297248353/appstore-1panel.git
synced 2024-11-24 08:33:50 +08:00
修缮脚本,增加友善的安装命令检查。
Signed-off-by: 萌森 <qyg2297248353@163.com>
This commit is contained in:
parent
e33258b501
commit
8ba72fd83a
25
README.md
25
README.md
@ -130,6 +130,10 @@
|
||||
> 当您已安装其他第三方库时并且存在应用冲突,安装过程中会主动删除冲突的第三方库应用,如果您不同意,请不要执行脚本。
|
||||
>
|
||||
> 我们建议您在安装之前备份您的数据,或手动安装。
|
||||
>
|
||||
> 如果您不使用 `curl` 命令,可以使用 `wget` 命令代替。
|
||||
>
|
||||
> 将 `curl -sSL` 替换为 `wget -qO-` 即可。
|
||||
|
||||
### 自动化安装
|
||||
|
||||
@ -137,13 +141,13 @@
|
||||
|
||||
每三小时自动更新一次应用列表。
|
||||
|
||||
```shell
|
||||
```sh
|
||||
curl -sSL https://install.lifebus.top/auto_install.sh | bash
|
||||
```
|
||||
|
||||
> 卸载自动化脚本 (不会卸载应用)
|
||||
|
||||
```shell
|
||||
```sh
|
||||
curl -sSL https://install.lifebus.top/auto_uninstall.sh | bash
|
||||
```
|
||||
|
||||
@ -159,7 +163,7 @@ curl -sSL https://install.lifebus.top/auto_uninstall.sh | bash
|
||||
|
||||
更新时机由自己把握,手动执行命令。
|
||||
|
||||
```shell
|
||||
```sh
|
||||
curl -sSL https://install.lifebus.top/app_install.sh | bash
|
||||
```
|
||||
|
||||
@ -167,7 +171,7 @@ curl -sSL https://install.lifebus.top/app_install.sh | bash
|
||||
|
||||
将内容写入Shell计划任务中,设定定期执行。
|
||||
|
||||
```shell
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
# 此处可以定义代理方案
|
||||
@ -223,6 +227,8 @@ curl -sSL https://install.lifebus.top/pre_app_uninstall.sh | bash
|
||||
|
||||
可能您的库中遗留了一些无用的应用,您可以通过此脚本进行清理。该脚本不影响 `自动化脚本` 的应用更新。
|
||||
|
||||
**此脚本必须`root`用户执行**
|
||||
|
||||
```sh
|
||||
curl -sSL https://install.lifebus.top/local_app_uninstall.sh | bash
|
||||
```
|
||||
@ -231,6 +237,17 @@ curl -sSL https://install.lifebus.top/local_app_uninstall.sh | bash
|
||||
|
||||
## 常见问题
|
||||
|
||||
+ 安装脚本提示
|
||||
+ 没有权限
|
||||
+ 请使用 `root` 用户执行脚本
|
||||
+ `curl: command not found`
|
||||
+ 请安装 `curl` 命令
|
||||
+ `apt install curl -y`
|
||||
+ `yum install curl -y`
|
||||
+ 由于安装脚本的网络问题导致安装失败
|
||||
+ 请检查网络状况
|
||||
+ 请尝试重新执行安装脚本
|
||||
+ 请尝试使用 `wget` 命令代替 `curl` 命令
|
||||
+ 升级失败
|
||||
+ 检查网络状况与磁盘空间
|
||||
+ 配置镜像地址
|
||||
|
@ -27,6 +27,23 @@ if [ -z "$BASE_DIR" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w "$BASE_DIR" ]; then
|
||||
echo "Error: No write permission to the 1panel install directory."
|
||||
echo "Please run as a superuser."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_DIR="${BASE_DIR}/1panel/resource/apps/local/appstore-localApps"
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
mkdir -p "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
if [ ! -w "$TARGET_DIR" ]; then
|
||||
echo "Error: No write permission to the target directory."
|
||||
echo "Please run as a superuser."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$(date): Step 1 - Cloning repository..."
|
||||
repos=(
|
||||
'https://github.com/QYG2297248353/appstore-1panel'
|
||||
@ -50,6 +67,19 @@ ENVS_DIR="$BASE_DIR/1panel/resource/apps/local/appstore-localApps/envs"
|
||||
DEST_ENVS_DIR="/etc/1panel/envs"
|
||||
|
||||
echo "$(date): Step 2 - Checking for updated apps..."
|
||||
|
||||
if [ ! -w "$LOCAL_DIR" ]; then
|
||||
echo "Error: No write permission to $LOCAL_DIR."
|
||||
echo "Please run as a superuser."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w "$DEST_ENVS_DIR" ]; then
|
||||
echo "Error: No write permission to $DEST_ENVS_DIR."
|
||||
echo "Please run as a superuser."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for app_directory in "${APPS_DIR:?}"/*; do
|
||||
app_name=$(basename "$app_directory")
|
||||
|
||||
|
@ -1,6 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p /home/task
|
||||
echo "$(date): [Init] Check..."
|
||||
|
||||
if ! command -v crontab &> /dev/null; then
|
||||
echo "crontab could not be found, please install it first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v wget &> /dev/null; then
|
||||
downloader="wget -O"
|
||||
elif command -v curl &> /dev/null; then
|
||||
downloader="curl -o"
|
||||
else
|
||||
echo "Neither wget nor curl is installed. Please install one of them first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -w /home/task ]]; then
|
||||
task_dir="/home/task"
|
||||
elif [[ ! -d /home/task ]]; then
|
||||
mkdir -p /home/task
|
||||
if [[ $? -ne 0 || ! -w /home/task ]]; then
|
||||
echo "No permission to write to /home/task."
|
||||
else
|
||||
task_dir="/home/task"
|
||||
fi
|
||||
elif [[ -w /etc/task ]]; then
|
||||
task_dir="/etc/task"
|
||||
elif [[ ! -d /etc/task ]]; then
|
||||
mkdir -p /etc/task
|
||||
if [[ $? -ne 0 || ! -w /etc/task ]]; then
|
||||
echo "No permission to write to /etc/task."
|
||||
else
|
||||
task_dir="/etc/task"
|
||||
fi
|
||||
else
|
||||
echo "No permission to write to /home/task or /etc/task. Please run as a superuser."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$(date): [Init] Download the installation script..."
|
||||
|
||||
urls=(
|
||||
'https://install.lifebus.top/app_install.sh'
|
||||
@ -10,19 +49,33 @@ urls=(
|
||||
'https://github.com/QYG2297248353/appstore-1panel/releases/download/install/app_install.sh'
|
||||
)
|
||||
|
||||
download_successful=false
|
||||
|
||||
for url in "${urls[@]}"; do
|
||||
wget -O /home/task/app_install.sh "$url" && break
|
||||
$downloader "$task_dir/app_install.sh" "$url"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
download_successful=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f /home/task/app_install.sh ]]; then
|
||||
chmod +x /home/task/app_install.sh
|
||||
echo "$(date): [Next] Deploy installation scripts..."
|
||||
|
||||
crontab -l | grep -v '/home/task/app_install.sh' | crontab -
|
||||
crontab -l | grep -v '/home/task/app_install_zh.sh' | crontab -
|
||||
if [[ "$download_successful" = true && -f "$task_dir/app_install.sh" ]]; then
|
||||
if [[ -w "$task_dir/app_install.sh" ]]; then
|
||||
chmod +x "$task_dir/app_install.sh"
|
||||
|
||||
(crontab -l ; echo "0 */3 * * * /bin/bash /home/task/app_install.sh") | crontab -
|
||||
crontab -l | grep -v "$task_dir/app_install.sh" | crontab -
|
||||
crontab -l | grep -v "$task_dir/app_install_zh.sh" | crontab -
|
||||
|
||||
/bin/bash /home/task/app_install.sh
|
||||
(crontab -l ; echo "0 */3 * * * /bin/bash $task_dir/app_install.sh") | crontab -
|
||||
|
||||
/bin/bash "$task_dir/app_install.sh"
|
||||
else
|
||||
echo "No permission to change the script's permissions."
|
||||
fi
|
||||
else
|
||||
echo "网络异常,请检查您的网络状态。"
|
||||
echo "Script download failed. Please check your network connection."
|
||||
fi
|
||||
|
||||
echo "$(date): [Run] Update application list"
|
||||
|
Loading…
Reference in New Issue
Block a user