forked from Mzdyl/LiteLoaderQQNT_Install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepack_appimage.sh
executable file
·90 lines (75 loc) · 2.41 KB
/
repack_appimage.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
#!/bin/bash
if [ $# -eq 0 ]; then
echo "未提供 QQ.AppImage 文件的路径,默认使用当前目录下的 QQ.AppImage"
appimage_path="$PWD/QQ.AppImage"
else
appimage_path="$1"
fi
qq_path=$(dirname "$appimage_path")
if [ -f "$appimage_path" ]; then
echo "当前 QQ.AppImage 路径: $appimage_path"
cp "$appimage_path" QQ.AppImage.bak
chmod +x "$appimage_path"
else
echo "未找到指定的 QQ.AppImage 文件"
exit 1
fi
echo "处理原AppImage"
chmod +x $appimage_path
$appimage_path --appimage-extract >/dev/null
rm "$appimage_path"
cd $qq_path/squashfs-root
target_dir="$qq_path/squashfs-root"
install_dir="$target_dir/resources/app/app_launcher"
config_file="$target_dir/AppRun"
plugin_dir="\$HOME/.config/QQ/LiteLoader"
echo "当前target_dir:$target_dir"
# 检查是否已存在LITELOADERQQNT_PROFILE
if grep -q "export LITELOADERQQNT_PROFILE=" "$config_file"; then
sed -i 's|export LITELOADERQQNT_PROFILE=.*|export LITELOADERQQNT_PROFILE="'$plugin_dir'"|' "$config_file"
else
# 如果不存在,则添加新的行
echo 'export LITELOADERQQNT_PROFILE="'$plugin_dir'"' >> "$config_file"
echo "已添加 LITELOADERQQNT_PROFILE: $plugin_dir"
fi
cd /tmp
echo "正在拉取最新版本的仓库..."
rm -rf LiteLoader
git clone https://github.com/LiteLoaderQQNT/LiteLoaderQQNT.git LiteLoader
# 移动到安装目录
echo "拉取完成,正在安装LiteLoader..."
cp -f LiteLoader/src/preload.js $target_dir/resources/app/application/preload.js
# 移动LiteLoader
mv -f LiteLoader "$install_dir/LiteLoader"
# 进入安装目录
cd "$install_dir"
# 修改index.js
echo "正在修补index.js...$appimage_path"
# 检查是否已存在相同的修改
if grep -q "require('./LiteLoader');" index.js; then
echo "index.js 已包含相同的修改,无需再次修改。"
else
# 如果不存在,则进行修改
sed -i -e "1i\\
require('./LiteLoader');" -e '$a\' index.js
echo "已修补 index.js。"
fi
chmod -R 0777 $install_dir
cd "$target_dir/.."
echo "正在重打包"
mksquashfs squashfs-root tmp.squashfs -root-owned -noappend >/dev/null
cat runtime-x86_64 >> QQ.AppImage
cat tmp.squashfs >> QQ.AppImage
chmod a+x QQ.AppImage
echo "注意,插件与配置文件将放在 $plugin_dir"
echo "清理临时文件"
# 清理临时文件
rm -rf /tmp/LiteLoader
rm -rf tmp.squashfs
rm -r $target_dir
# 错误处理.
if [ $? -ne 0 ]; then
echo "发生错误,安装失败"
exit 1
fi
exit 0