blob: 5e636d33ba04ddcd23a9f9721c6650a3c86c1ee6 (
plain)
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
|
DEVICENAME=$(cat /sys/devices/virtual/dmi/id/product_name)
# 安装或升级后的操作
post_upgrade_or_install() {
sudo systemctl daemon-reload
sudo systemctl disable --now sk-efi-mount.service
if [[ ! -d "/sys/class/power_supply/BAT1" ]]; then
vp_status=$(systemctl is-enabled vpower.service 2>/dev/null)
if [[ "$vp_status" != "masked" ]]; then
echo "Mask vpower.service"
sudo systemctl mask --now vpower.service
fi
fi
jfc_status=$(systemctl is-enabled jupiter-fan-control.service 2>/dev/null)
if [[ "$jfc_status" != "masked" ]]; then
echo "Mask jupiter-fan-control.service"
sudo systemctl mask --now jupiter-fan-control.service
fi
# if file /usr/bin/efi-mount is exist, rename it
if [ -f "/usr/bin/efi-mount" ]; then
echo "Rename /usr/bin/efi-mount to /usr/bin/efi-mount.bak"
sudo mv /usr/bin/efi-mount /usr/bin/efi-mount.bak
fi
# if file /usr/bin/auto-swap is exist, rename it
if [ -f "/usr/bin/auto-swap" ]; then
echo "Rename /usr/bin/auto-swap to /usr/bin/auto-swap.bak"
sudo mv /usr/bin/auto-swap /usr/bin/auto-swap.bak
fi
if [[ $(grep -c ^ /proc/swaps) -gt 1 && $(awk 'NR==2{print $1}' /proc/swaps) == "/dev/"* ]]; then
echo "Swap is already enabled. Set swap PARTUUID in /etc/default/auto_swap"
# swap partuuid
SWAP_PARTITION=$(awk 'NR==2{print $1}' /proc/swaps)
SWAP_PARTUUID=$(lsblk -rno PARTUUID ${SWAP_PARTITION})
echo "$SWAP_PARTUUID" | sudo tee /etc/default/auto_swap
fi
# 备份原始的 /etc/fstab 文件
sudo cp /etc/fstab /etc/fstab.backup
# 使用 awk 分析 /etc/fstab 文件并生成新的内容
sudo awk '!($1 == "PARTUUID=" && $2 == "/boot/efi")' /etc/fstab > /etc/fstab.tmp
# 将临时文件替换回原始的 /etc/fstab 文件
sudo mv /etc/fstab.tmp /etc/fstab
# 机型特殊处理
# G1619-04 (WinMAX2) 机型不需要蓝牙自动挂起 会导致连接xbox手柄异常
if [[ "${DEVICENAME}" != "G1619-04" ]]; then
echo "" | tee /etc/udev/rules.d/99-disable-bluetooth-autosuspend.rules
fi
if [[ "${DEVICENAME}" != "Jupiter 1" ]]; then
sudo systemctl mask --now jupiter-controller-update.service
fi
}
# 安装前的操作
pre_install() {
sudo cp /etc/default/grub /etc/default/grub.sk-holoiso-config.bak
}
# 升级前的操作
pre_upgrade() {
if [ ! -f "/etc/default/grub.sk-holoiso-config.bak" ]; then
sudo cp /etc/default/grub /etc/default/grub.sk-holoiso-config.bak
fi
}
# 安装后的操作
post_install() {
post_upgrade_or_install
sudo systemctl enable sk-auto-swap.service
sudo systemctl enable sk-root-resume.service
# OXP2 自启动相关服务
if [[ "${DEVICENAME}" == "ONEXPLAYER 2 ARP23" ]]; then
sudo systemctl enable --now oxp2-lsusb.service
sudo systemctl enable --now oxp2-volume-button-fix.service
fi
if [[ "${DEVICENAME}" != "AIR Plus" ]]; then
sudo systemctl disable --now ayaled.service
fi
}
# 升级后的操作
post_upgrade() {
post_upgrade_or_install
}
pre_remove() {
curr_version=$1
# cp /etc/default/grub /etc/default/grub.bak-"${curr_version}"
}
post_remove() {
curr_version=$1
echo "Restore grub"
# cp /etc/default/grub.bak-"${curr_version}" /etc/default/grub
# rm /etc/default/grub.bak-"${curr_version}"
if [ -f "/etc/default/grub.sk-holoiso-config.bak" ]; then
sudo cp /etc/default/grub.sk-holoiso-config.bak /etc/default/grub
# sudo rm /etc/default/grub.sk-holoiso-config.bak
fi
}
|