Files
tms-bbt-pkg/tms-bbt.install
2025-12-14 22:38:52 +08:00

51 lines
2.2 KiB
Plaintext
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.

# post_install: 在软件包安装后执行
post_install() {
echo "Checking for 'smart' user..."
if ! id -u smart &>/dev/null; then
echo "WARNING: User 'smart' does not exist. Please create the 'smart' user for SmartTMS to function correctly."
echo "You can create it with: sudo useradd -m smart"
fi
echo "Reloading systemd configuration, enabling and starting smarttms.service..."
systemctl daemon-reload >/dev/null 2>&1 || :
systemctl enable smarttms.service >/dev/null 2>&1 || :
systemctl start smarttms.service >/dev/null 2>&1 || :
echo "Updating desktop database..."
update-desktop-database /usr/share/applications >/dev/null 2>&1 || :
echo "SmartTMS application installed to /home/smart/.tms3."
echo "A systemd service 'smarttms.service' has been enabled and started."
echo "A sudoers.d entry for 'smart' user has been added."
echo "Desktop shortcut 'tmsrestart.desktop' is available."
echo "Please ensure the 'smart' user exists and has appropriate permissions for /home/smart/.tms3."
}
# pre_remove: 在软件包卸载前执行
pre_remove() {
echo "Stopping and disabling smarttms.service..."
systemctl stop smarttms.service >/dev/null 2>&1 || :
systemctl disable smarttms.service >/dev/null 2>&1 || :
}
# post_remove: 在软件包卸载后执行
post_remove() {
echo "Reloading systemd configuration after removal..."
systemctl daemon-reload >/dev/null 2>&1 || :
echo "Updating desktop database after removal..."
update-desktop-database /usr/share/applications >/dev/null 2>&1 || :
# 可选:如果 /home/smart/.tms3 目录为空,则删除它。
# 这与 RPM 的行为一致RPM 只会删除它跟踪的文件。
# 如果用户在该目录中创建了文件RPM 不会删除该目录,此脚本也不会。
local _app_base_dir="/home/smart/.tms3"
if [ -d "${_app_base_dir}" ] && [ -z "$(ls -A "${_app_base_dir}")" ]; then
rmdir "${_app_base_dir}" >/dev/null 2>&1 || :
fi
echo "SmartTMS application has been removed."
echo "Note: User 'smart' and its home directory are NOT removed."
echo "Any user-generated data in /home/smart/.tms3 (not tracked by the package) remains."
}