modify: 加入了配置系统,不再用瞳孔地震的方式处理升级

This commit is contained in:
shenmo 2023-08-13 21:44:53 +08:00
parent 9f32a02f35
commit 0e810cea87
4 changed files with 30 additions and 37 deletions

@ -45,26 +45,13 @@ case "$1" in
gpg --dearmor /tmp/spark-store-install/spark-store.asc
cp -f /tmp/spark-store-install/spark-store.asc.gpg /etc/apt/trusted.gpg.d/spark-store.gpg
# Run apt update to avoid users being fucked up by the non-exist dependency problem
# Now abandoned as aptss now run ssupdate everytime
#aptss ssupdate
# Start upgrade detect service
systemctl daemon-reload
# Do NOT enable upgrade detect service if disabled by user
if [ ! -f "/usr/lib/systemd/system/spark-update-notifier.service.bak" ] ; then
systemctl enable spark-update-notifier
systemctl start spark-update-notifier
else
if [ $(systemctl is-enabled spark-update-notifier.service) = "enabled" ] ; then
systemctl reenable spark-update-notifier
if [ $(systemctl is-active spark-update-notifier.service) = "active" ] ; then
systemctl restart spark-update-notifier
fi
fi
systemctl enable spark-update-notifier
systemctl start spark-update-notifier
rm -f /usr/lib/systemd/system/spark-update-notifier.service.bak
fi
# Update certain caches
update-icon-caches /usr/share/icons/hicolor || true

@ -28,6 +28,16 @@ if [ "$1" = "remove" -o "$1" = "purge" ] ; then
# Remove residual symbol links to stop upgrade detect
rm -f /etc/xdg/autostart/spark-update-notifier.desktop
# Remove config files
for username in `ls /home`
do
echo /home/$username
if [ -d /home/$username/.config/spark-union/spark-store ]
then
rm -rf /home/$username/.config/spark-union/spark-store
fi
done
# Shutdown services
systemctl stop spark-update-notifier
@ -49,18 +59,4 @@ else
fi
fi
if [ "$1" = "upgrade" ] ; then
echo "非卸载操作,不进行配置清理"
if [ -f "/usr/lib/systemd/system/spark-update-notifier.service" ] ; then
mv -f /usr/lib/systemd/system/spark-update-notifier.service /usr/lib/systemd/system/spark-update-notifier.service.bak
fi
if [ ! -z "`pidof spark-store`" ] ; then
echo "关闭已有 spark-store..."
notify-send "正在升级星火商店" "请在升级结束后重启星火商店" -i spark-store
killall spark-store
else
echo "继续安装 spark-store..."
fi
fi

@ -8,7 +8,7 @@ endloop=0
#####################检测是否启动过了更新检测工具
while [ $endloop -eq 0 ] ;do
if [ -e /etc/systemd/system/multi-user.target.wants/spark-update-notifier.service ];then
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify ];then
text_update_open="${TRANSHELL_CONTENT_CLOSE}"
#已经开启了就显示关闭
else
@ -21,14 +21,12 @@ option=`zenity --list --text="${TRANSHELL_CONTENT_WELCOME_AND_CHOOSE_ONE_TO_RUN}
case $option in
0)
if [ -e /etc/systemd/system/multi-user.target.wants/spark-update-notifier.service ];then
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_CLOSING_UPGRADE_CHECK}" --timeout=2
pkexec systemctl disable spark-update-notifier
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify ];then
mkdir -p $HOME/.config/spark-union/spark-store/
touch $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_CLOSED}" --timeout=2
else
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_OPENING_UPGRADE_CHECK}" --timeout=2
pkexec systemctl enable spark-update-notifier
pkexec service spark-update-notifier start
rm -f $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_OPENED}" --timeout=2
fi
;;

@ -20,6 +20,8 @@ function notify-send() {
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send "$@"
}
# 检测网络链接畅通
function network-check()
{
@ -106,4 +108,14 @@ fi
update_transhell
## 如果都是hold或者版本一致的那就直接退出否则把剩余的给提醒了
##TODO:除了apt-mark hold之外额外有一个禁止检查列表
## 如果不想提示就不提示
user=$(who | awk '{print $1}' | head -n 1)
if [ -e "$user/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify" ];then
exit
else
notify-send -a spark-store "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_NOTIFY}" "${TRANSHELL_CONTENT_THERE_ARE_APPS_TO_UPGRADE}"
fi