Files
tms-arch-linux-lts-calamare…/archiso/airootfs/home/smart/SmartOrganizer/common/MiaozhenProbe/uninstall.sh
2025-11-26 16:12:02 +08:00

73 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# 脚本所在目录 绝对路径
ROOT_PATH="/home/smart/SmartOrganizer"
. ${ROOT_PATH}/lib.conf
PACKAGE_PATH="/home/Miaozhen"
PACKAGE_NAME="MiaozhenProbe"
SERVICE_NAME="MiaozhenProbeService"
CURRENT_VERSION=""
TARGET_VERSION="${1}"
if [[ -z ${TARGET_VERSION} ]]; then
echo "Argument: TARGET_VERSION is needed!"
exit 2
fi
if [[ ! -d ${PACKAGE_PATH} ]]; then
echo "Not installed ... uninstall stopped"
exit 2
fi
pushd ${PACKAGE_PATH}
if [[ -f ".version" ]]; then
CURRENT_VERSION="$(cat .version)"
fi
if [[ -n ${CURRENT_VERSION} ]]; then
echo "current_version:"${CURRENT_VERSION}" target_version:"${TARGET_VERSION}
if [[ $(version_compare ${CURRENT_VERSION} ${TARGET_VERSION}) != -1 ]]; then
echo "No upgrade required"
popd > /dev/null
exit 2
fi
fi
if [[ $(getSystemVersion ) -eq 6 ]]; then
# stop service
service ${SERVICE_NAME} stop
echo "Stop service ... successed!"
# stop auto startup
chkconfig ${SERVICE_NAME} off
chkconfig --del ${SERVICE_NAME}
echo "Unregister from auto start ... successed!"
# remove files
rm -f /etc/init.d/${SERVICE_NAME}
echo "Unregister from system service ... successed!"
else
# stop service
systemctl stop ${SERVICE_NAME}
echo "Stop service ... successed!"
# stop auto startup
systemctl disable ${SERVICE_NAME}
echo "Unregister from auto start ... successed!"
# remove files
rm -f /usr/lib/systemd/system/${SERVICE_NAME}.service
echo "Unregister from system service ... successed!"
fi
rm -rf ${PACKAGE_PATH}/*
echo "Delete source files (Except log files) ... successed!"
echo "Done!"
popd