shenmo 217b299a67
update tool/ssinstall.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2022-12-15 12:04:37 +00:00

84 lines
2.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "Spark Store Install script.星火商店安装脚本"
function pkexec_as_current_user() {
#Detect the name of the display in use
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
#Detect the user using such display
local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1)
#Detect the id of the user
local uid=$(id -u $user)
sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus pkexec "$@"
}
function zenity() {
#Detect the name of the display in use
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
#Detect the user using such display
local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1)
#Detect the id of the user
local uid=$(id -u $user)
sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus zenity "$@"
}
#################检测文件是否存在
if [ $# -eq 0 ];then
echo "没有接收到参数,退出"
echo "用法:$0 deb路径"
exit
fi
if [ ! -f "$1" ]
then
echo "文件不存在"
exit 1
fi
if [ "$(id -u)" != "0" ];then
#############################无root权限时
echo "请使用root启动ssinstall"
exit 1
fi
###
DEBPATH=`realpath $1`
if [ ! -e "/var/lib/apt/lists/d.store.deepinos.org.cn_Packages" ];then
echo "接收星火仓库软件信息中..."
aptss ssupdate
fi
echo "正在计算hash并与星火仓库匹配..."
DEB_MD5SUM=`md5sum "$DEBPATH" | cut -c -32`
IS_MD5SUM_CHECKD=`cat /var/lib/apt/lists/d.store.deepinos.org.cn_Packages | grep $DEB_MD5SUM`
if [ ! -z "$IS_MD5SUM_CHECKD" ];then
echo "校验成功,开始安装"
echo ----------------------------------------------------------------------------------
dpkg -i "$DEBPATH" || aptss install -yf
else
zenity --info --icon-name=spark-store --height 270 --width 500 --text "软件包校验失败!这不应该发生!\n可能是因为软件包已损坏星火仓库未同步或者最坏的情况恶意软件尝试利用自动安装来入侵系统\n如果你不清楚发生了什么请在接下来的认证窗口中选择取消认证\n执行 sudo aptss ssupdate 后再尝试安装。\n如果问题仍然存在请在应用信息界面点击 应用反馈 来提交反馈给我们!\n\n如果你是审核人员这是正常现象在审核通过前星火仓库不会保存相关信息。请在接下来的弹窗中进行认证即可"
echo "软件包校验失败!这不应该发生!"
echo "执行 sudo aptss ssupdate 后再尝试安装。"
echo "如果问题仍然存在,请在应用信息界面点击 应用反馈 来提交反馈给我们!"
echo "如果你是审核人员,这是正常现象,在审核通过前星火仓库不会保存相关信息。请在接下来的弹窗中进行认证即可"
pkexec_as_current_user bash -c "dpkg -i "$DEBPATH" || aptss install -yf "
fi