[3rd-Party Apps] 求救:deb打包的postinst配置,运行的设置跑到ROOT用户下面了
Tofloor
poster avatar
wavezhang66
deepin
2023-06-16 17:02
Author

来问个问题,我为什么为我用deb打包之后,在postinst这个配置安装文件运行一些程序,这些程序的运行的设置跑到ROOT用户下面了,没有到我当前用户程序下面

我把一些配置在我安装时,在当前用户有效,怎么能好 ?


36797ec9f943bf1abb033f84635f171f.png

Reply Favorite View the author
All Replies
忘记、过去
deepin
2023-06-16 17:22
#1

postinst 等维护脚本的运行环境本来就是 root 身份

不过,用户在使用 sudo 安装 deb 包的时候,是可以在 postinst 等维护脚本里获取到当前用户名称和 uid 的,

userName=$(/usr/bin/logname)
if [ $? -ne 0 ] ; then
    userName=""
fi

userId=$(/usr/bin/id -u $userName)
if [ $? -ne 0 ] ; then
    userId=""
fi

可以根据上述 $userName$userId 是否为空来拼接你要的路径

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2023-06-16 21:38
#2

不建议放在用户区间目录的配置在dpkg安装阶段释放,可能会有权限问题

建议改启动脚本

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2023-06-16 21:39
#3
忘记、过去

postinst 等维护脚本的运行环境本来就是 root 身份

不过,用户在使用 sudo 安装 deb 包的时候,是可以在 postinst 等维护脚本里获取到当前用户名称和 uid 的,

userName=$(/usr/bin/logname)
if [ $? -ne 0 ] ; then
    userName=""
fi

userId=$(/usr/bin/id -u $userName)
if [ $? -ne 0 ] ; then
    userId=""
fi

可以根据上述 $userName$userId 是否为空来拼接你要的路径

在部分发行版上logname会输出空

https://gitee.com/deepin-community-store/spark-store/blob/dev/tool/ssinstall#L23

我现在用这个

Reply View the author
enforcee
deepin
2023-06-17 00:55
#4

用户的配置文件应该运行时再生成

Reply View the author