first commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/rpmbuild/BUILD/**
|
||||||
|
/rpmbuild/BUILDROOT/**
|
||||||
14
add_empty_folders.sh
Normal file
14
add_empty_folders.sh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 保存为 add_empty_folders.sh
|
||||||
|
|
||||||
|
echo "正在查找并处理空文件夹..."
|
||||||
|
|
||||||
|
# 查找所有空文件夹并创建 .gitkeep
|
||||||
|
find . -type d -empty | while read dir; do
|
||||||
|
if [ ! -f "$dir/.gitkeep" ]; then
|
||||||
|
touch "$dir/.gitkeep"
|
||||||
|
echo "✅ 已创建: $dir/.gitkeep"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "处理完成!"
|
||||||
93
build-smarttms-mysql-rpm.sh
Normal file
93
build-smarttms-mysql-rpm.sh
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e # 任何命令失败时立即退出
|
||||||
|
|
||||||
|
echo "--- 开始构建 RPM 包 ---"
|
||||||
|
|
||||||
|
# 1. 获取脚本自身的绝对路径
|
||||||
|
# SCRIPT_PATH 是脚本的完整路径 (例如: /home/smart/smarttms-rpm-build/smarttms-rpm-build.sh)
|
||||||
|
SCRIPT_PATH=$(readlink -f "${BASH_SOURCE[0]}")
|
||||||
|
# PROJECT_ROOT 是脚本所在的目录,也是整个项目的根目录 (例如: /home/smart/smarttms-rpm-build)
|
||||||
|
PROJECT_ROOT=$(dirname "$SCRIPT_PATH")
|
||||||
|
|
||||||
|
# 2. 根据项目根目录确定 rpmbuild 的顶层目录
|
||||||
|
# TOP_DIR 是 rpmbuild 的根目录 (例如: /home/smart/smarttms-rpm-build/rpmbuild)
|
||||||
|
TOP_DIR="$PROJECT_ROOT/rpmbuild"
|
||||||
|
|
||||||
|
# 3. 定义其他重要目录的绝对路径
|
||||||
|
SOURCES_DIR="$TOP_DIR/SOURCES"
|
||||||
|
SPECS_DIR="$TOP_DIR/SPECS"
|
||||||
|
SPEC_FILE="$SPECS_DIR/smarttms.spec" # SPEC 文件的绝对路径
|
||||||
|
# 应用程序源代码的实际目录,它位于 SOURCES_DIR 下面
|
||||||
|
SOURCE_CODE_ORIGINAL_DIR="$SOURCES_DIR/smarttms"
|
||||||
|
|
||||||
|
echo "脚本路径: $SCRIPT_PATH"
|
||||||
|
echo "项目根目录: $PROJECT_ROOT"
|
||||||
|
echo "RPM构建顶层目录 (_topdir): $TOP_DIR"
|
||||||
|
echo "SOURCES目录: $SOURCES_DIR"
|
||||||
|
echo "SPEC文件: $SPEC_FILE"
|
||||||
|
echo "原始源代码目录 (待打包): $SOURCE_CODE_ORIGINAL_DIR"
|
||||||
|
|
||||||
|
|
||||||
|
# 4. 检查原始源代码目录是否存在
|
||||||
|
if [ ! -d "$SOURCE_CODE_ORIGINAL_DIR" ]; then
|
||||||
|
echo "错误:找不到应用程序原始源代码目录 '$SOURCE_CODE_ORIGINAL_DIR'。"
|
||||||
|
echo "请确保你的 'smarttms/' 目录位于 '$SOURCES_DIR' 下。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. 确保 SOURCES 目录存在
|
||||||
|
mkdir -p "$SOURCES_DIR"
|
||||||
|
|
||||||
|
# 6. 从 SPEC 文件中提取 Name 和 Version
|
||||||
|
# rpmbuild 期望 Source0 的格式为 %{name}-%{version}.tar.gz
|
||||||
|
# 因此,我们需要确保生成的 tarball 名称和其内部的顶层目录名匹配这个约定。
|
||||||
|
SPEC_NAME=$(grep "^Name:" "$SPEC_FILE" | awk '{print $2}')
|
||||||
|
SPEC_VERSION=$(grep "^Version:" "$SPEC_FILE" | awk '{print $2}')
|
||||||
|
|
||||||
|
if [ -z "$SPEC_NAME" ] || [ -z "$SPEC_VERSION" ]; then
|
||||||
|
echo "错误:无法从 '$SPEC_FILE' 中提取 Name 或 Version。"
|
||||||
|
echo "请确保 SPEC 文件中包含 'Name: <package_name>' 和 'Version: <package_version>'。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# rpmbuild 期望的解压后的顶层目录名 (例如 smarttms-1.0)
|
||||||
|
EXPECTED_UNPACK_DIR_NAME="${SPEC_NAME}-${SPEC_VERSION}"
|
||||||
|
# 最终生成的 tarball 文件名 (例如 smarttms-1.0.tar.gz),与 Source0 匹配
|
||||||
|
TARBALL_NAME="${EXPECTED_UNPACK_DIR_NAME}.tar.gz"
|
||||||
|
TARBALL_PATH="$SOURCES_DIR/$TARBALL_NAME"
|
||||||
|
|
||||||
|
echo "从SPEC文件获取到: Name=$SPEC_NAME, Version=$SPEC_VERSION"
|
||||||
|
echo "rpmbuild预期的解压目录名: $EXPECTED_UNPACK_DIR_NAME"
|
||||||
|
echo "最终的tarball名称 (应与SPEC文件中的Source0匹配): $TARBALL_NAME"
|
||||||
|
|
||||||
|
|
||||||
|
# 7. 清理旧的 tarball
|
||||||
|
echo "清理旧的 tarball: $TARBALL_PATH"
|
||||||
|
rm -f "$TARBALL_PATH"
|
||||||
|
|
||||||
|
# 8. 创建新的 tarball,使其解压后为期望的目录名 (例如 smarttms-1.0)
|
||||||
|
echo "创建新的 tarball: $TARBALL_PATH"
|
||||||
|
|
||||||
|
# 创建一个临时目录作为打包的暂存区
|
||||||
|
STAGING_TEMP_DIR=$(mktemp -d)
|
||||||
|
# 确保脚本退出时清理临时目录
|
||||||
|
trap "rm -rf '$STAGING_TEMP_DIR'" EXIT
|
||||||
|
|
||||||
|
# 将原始源代码复制到暂存区,并重命名为 rpmbuild 期望的目录名
|
||||||
|
echo "将原始源代码 '$SOURCE_CODE_ORIGINAL_DIR' 复制到临时暂存区并重命名为 '$EXPECTED_UNPACK_DIR_NAME'"
|
||||||
|
cp -r "$SOURCE_CODE_ORIGINAL_DIR" "$STAGING_TEMP_DIR/$EXPECTED_UNPACK_DIR_NAME"
|
||||||
|
|
||||||
|
# 在暂存区内执行 tar 命令,压缩重命名后的目录
|
||||||
|
# 这样生成的 tarball 解压后就会得到 EXPECTED_UNPACK_DIR_NAME/ 目录
|
||||||
|
(cd "$STAGING_TEMP_DIR" && tar -czvf "$TARBALL_PATH" "$EXPECTED_UNPACK_DIR_NAME")
|
||||||
|
|
||||||
|
echo "Tarball '$TARBALL_PATH' 已创建,其内容解压后将为顶层目录 '$EXPECTED_UNPACK_DIR_NAME/'。"
|
||||||
|
|
||||||
|
# 9. 执行 rpmbuild
|
||||||
|
echo "执行 rpmbuild 命令..."
|
||||||
|
# 使用 --define _topdir 明确告诉 rpmbuild 它的顶层目录
|
||||||
|
rpmbuild --define "_topdir $TOP_DIR" -ba "$SPEC_FILE"
|
||||||
|
|
||||||
|
echo "--- RPM 包构建完成! ---"
|
||||||
|
echo "生成的 RPM 包在: $TOP_DIR/RPMS/"
|
||||||
|
echo "生成的 SRPM 包在: $TOP_DIR/SRPMS/"
|
||||||
135
rpmbuild/SPECS/smarttms-mysql.spec
Normal file
135
rpmbuild/SPECS/smarttms-mysql.spec
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
Name: smarttms
|
||||||
|
Version: 1.0
|
||||||
|
Release: 1%{?dist}
|
||||||
|
Summary: SmartTMS application suite for managing smart devices.
|
||||||
|
|
||||||
|
# 禁用 debuginfo 包的生成
|
||||||
|
%define debug_package %{nil}
|
||||||
|
%global __debug_install_post %{nil}
|
||||||
|
|
||||||
|
License: Proprietary
|
||||||
|
URL: https://your.company.com/smarttms
|
||||||
|
Source0: %{name}-%{version}.tar.gz
|
||||||
|
|
||||||
|
# BuildRequires 是构建 RPM 包所需的工具,这里主要是复制和打包,所以通常不需要太多
|
||||||
|
# BuildRequires: tar, gzip # 这些通常是系统自带的,不需要显式列出
|
||||||
|
|
||||||
|
# Requires 是安装 RPM 包后,应用程序运行时所需的依赖。
|
||||||
|
# 如果你的 smarttms.service 依赖 Java 或特定的运行时环境,需要在这里添加。
|
||||||
|
# 例如:Requires: java-1.8.0-openjdk
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
This package installs the SmartTMS application suite, including a
|
||||||
|
Tomcat server, a starter application, a custom command-line tool,
|
||||||
|
and a systemd service for automatic startup. It also configures
|
||||||
|
sudoers for the 'smart' user and places application shortcuts.
|
||||||
|
|
||||||
|
# --- 准备阶段 ---
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
# 修复模糊的 Python shebangs
|
||||||
|
# 假设这些脚本是 Python 3。如果它们是 Python 2 脚本,请将 'python3' 改为 'python2'。
|
||||||
|
# 查找所有 .py 文件,将 #!/usr/bin/env python 替换为 #!/usr/bin/env python3
|
||||||
|
find . -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/env python$|#!/usr/bin/env python3|g' {} +
|
||||||
|
# 查找所有 .py 文件,将 #!/usr/bin/python 替换为 #!/usr/bin/python3
|
||||||
|
find . -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/python$|#!/usr/bin/python3|g' {} +
|
||||||
|
# 针对日志中提到的 websockify/run 文件,它没有 .py 后缀
|
||||||
|
sed -i 's|^#!/usr/bin/python$|#!/usr/bin/python3|g' apache-tomcat-7.0.63/webapps/noVNC-master/utils/websockify/run
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# --- 构建阶段 ---
|
||||||
|
%build
|
||||||
|
# 你的原始脚本没有编译步骤,所以此部分为空。
|
||||||
|
|
||||||
|
# --- 安装阶段 ---
|
||||||
|
%install
|
||||||
|
# %{buildroot} 是一个临时目录,模拟最终的根文件系统。
|
||||||
|
|
||||||
|
# 1. 创建目标目录
|
||||||
|
mkdir -p %{buildroot}/home/smart/.tms3/apache-tomcat-7.0.63
|
||||||
|
mkdir -p %{buildroot}/home/smart/.tms3/starter
|
||||||
|
mkdir -p %{buildroot}%{_bindir} # /usr/bin
|
||||||
|
mkdir -p %{buildroot}%{_sysconfdir}/sudoers.d # /etc/sudoers.d
|
||||||
|
mkdir -p %{buildroot}%{_unitdir} # /etc/systemd/system 或 /usr/lib/systemd/system
|
||||||
|
mkdir -p %{buildroot}%{_datadir}/applications # /usr/share/applications
|
||||||
|
|
||||||
|
# 2. 复制文件
|
||||||
|
cp -r apache-tomcat-7.0.63/* %{buildroot}/home/smart/.tms3/apache-tomcat-7.0.63/
|
||||||
|
cp -r starter/* %{buildroot}/home/smart/.tms3/starter/
|
||||||
|
cp smarttms %{buildroot}%{_bindir}/smarttms
|
||||||
|
cp smart %{buildroot}%{_sysconfdir}/sudoers.d/smart # sudoers.d 文件
|
||||||
|
cp smarttms.service %{buildroot}%{_unitdir}/smarttms.service # systemd 服务文件
|
||||||
|
cp starter/tmsrestart.desktop %{buildroot}%{_datadir}/applications/tmsrestart.desktop # 桌面快捷方式
|
||||||
|
|
||||||
|
# --- 文件列表 ---
|
||||||
|
%files
|
||||||
|
# 列出 RPM 包中包含的所有文件和目录。
|
||||||
|
# 路径必须是相对于根目录 (/) 的绝对路径。
|
||||||
|
# %attr(MODE, USER, GROUP) 用于设置文件权限和所有者。
|
||||||
|
# %dir 用于明确声明一个目录。
|
||||||
|
|
||||||
|
# /home/smart/.tms3 目录及其内容
|
||||||
|
# 警告:此路径假设 /home/smart 存在且可写。
|
||||||
|
# 777 权限非常开放,请确保这是你的意图。
|
||||||
|
# 如果该目录可能包含用户生成的数据,RPM 卸载时不会强制删除非 RPM 跟踪的文件。
|
||||||
|
%attr(0777, root, root) %dir /home/smart/.tms3
|
||||||
|
%attr(0777, root, root) %dir /home/smart/.tms3/apache-tomcat-7.0.63
|
||||||
|
/home/smart/.tms3/apache-tomcat-7.0.63/*
|
||||||
|
%attr(0755, root, root) %dir /home/smart/.tms3/starter
|
||||||
|
/home/smart/.tms3/starter/*
|
||||||
|
|
||||||
|
# /usr/bin/smarttms
|
||||||
|
%attr(0755, root, root) %{_bindir}/smarttms
|
||||||
|
|
||||||
|
# /etc/sudoers.d/smart
|
||||||
|
%attr(0440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/smart
|
||||||
|
|
||||||
|
# /etc/systemd/system/smarttms.service
|
||||||
|
%attr(0755, root, root) %config(noreplace) %{_unitdir}/smarttms.service
|
||||||
|
|
||||||
|
# /usr/share/applications/tmsrestart.desktop
|
||||||
|
%attr(0644, root, root) %{_datadir}/applications/tmsrestart.desktop
|
||||||
|
|
||||||
|
|
||||||
|
# --- 安装后脚本 ---
|
||||||
|
%post
|
||||||
|
# 这个脚本在 RPM 包安装完成后执行。
|
||||||
|
# 1. 重新加载 systemd 配置,启用并启动服务
|
||||||
|
systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
systemctl enable smarttms.service >/dev/null 2>&1 || :
|
||||||
|
systemctl start smarttms.service >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
# 2. 更新桌面快捷方式缓存 (重要,让系统识别新的 .desktop 文件)
|
||||||
|
update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
# --- 卸载前脚本 ---
|
||||||
|
%preun
|
||||||
|
# 这个脚本在 RPM 包卸载前执行。
|
||||||
|
# 1. 停止并禁用 systemd 服务
|
||||||
|
systemctl stop smarttms.service >/dev/null 2>&1 || :
|
||||||
|
systemctl disable smarttms.service >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
%postun
|
||||||
|
# 这个脚本在 RPM 包卸载后执行。
|
||||||
|
# 1. 重新加载 systemd 配置 (清理服务配置)
|
||||||
|
systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
# 2. 更新桌面快捷方式缓存 (移除旧的 .desktop 文件)
|
||||||
|
update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || :
|
||||||
|
|
||||||
|
# 3. 清理 /home/smart/.tms3 目录 (可选,如果确定没有用户数据)
|
||||||
|
# 注意:RPM 会自动删除 %files 中列出的文件。
|
||||||
|
# 如果该目录中存在非 RPM 安装的文件,RPM 不会删除该目录。
|
||||||
|
# 如果你希望在卸载时强制删除整个 .tms3 目录,即使里面有其他文件,
|
||||||
|
# 可以添加以下命令,但请慎重考虑数据丢失的风险。
|
||||||
|
# if [ -d /home/smart/.tms3 ] && [ -z "$(ls -A /home/smart/.tms3)" ]; then
|
||||||
|
# rmdir /home/smart/.tms3 >/dev/null 2>&1 || :
|
||||||
|
# fi
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Fri Dec 05 2025 Your Name <your.email@example.com> - 1.0-1
|
||||||
|
- Initial RPM packaging of SmartTMS application suite with systemd, sudoers.d,
|
||||||
|
- and /usr/share/applications desktop shortcut.
|
||||||
68
up+.sh
Normal file
68
up+.sh
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#set -e
|
||||||
|
##################################################################################################################
|
||||||
|
# Author : Erik Dubois
|
||||||
|
# Website : https://www.erikdubois.be
|
||||||
|
# Website : https://www.alci.online
|
||||||
|
# Website : https://www.ariser.eu
|
||||||
|
# Website : https://www.arcolinux.info
|
||||||
|
# Website : https://www.arcolinux.com
|
||||||
|
# Website : https://www.arcolinuxd.com
|
||||||
|
# Website : https://www.arcolinuxb.com
|
||||||
|
# Website : https://www.arcolinuxiso.com
|
||||||
|
# Website : https://www.arcolinuxforum.com
|
||||||
|
##################################################################################################################
|
||||||
|
#
|
||||||
|
# DO NOT JUST RUN THIS. EXAMINE AND JUDGE. RUN AT YOUR OWN RISK.
|
||||||
|
#
|
||||||
|
##################################################################################################################
|
||||||
|
#tput setaf 0 = black
|
||||||
|
#tput setaf 1 = red
|
||||||
|
#tput setaf 2 = green
|
||||||
|
#tput setaf 3 = yellow
|
||||||
|
#tput setaf 4 = dark blue
|
||||||
|
#tput setaf 5 = purple
|
||||||
|
#tput setaf 6 = cyan
|
||||||
|
#tput setaf 7 = gray
|
||||||
|
#tput setaf 8 = light blue
|
||||||
|
##################################################################################################################
|
||||||
|
|
||||||
|
# reset - commit your changes or stash them before you merge
|
||||||
|
# git reset --hard - personal alias - grh
|
||||||
|
|
||||||
|
echo "Deleting the work folder if one exists"
|
||||||
|
[ -d work ] && rm -rf work
|
||||||
|
|
||||||
|
# checking if I have the latest files from github
|
||||||
|
echo "Checking for newer files online first"
|
||||||
|
git pull
|
||||||
|
|
||||||
|
# Below command will backup everything inside the project folder
|
||||||
|
git add --all .
|
||||||
|
|
||||||
|
# Give a comment to the commit if you want
|
||||||
|
echo "####################################"
|
||||||
|
echo "Write your commit comment!"
|
||||||
|
echo "####################################"
|
||||||
|
|
||||||
|
read input
|
||||||
|
|
||||||
|
# Committing to the local repository with a message containing the time details and commit text
|
||||||
|
|
||||||
|
git commit -m "$input"
|
||||||
|
|
||||||
|
# Push the local files to github
|
||||||
|
|
||||||
|
if grep -q main .git/config; then
|
||||||
|
echo "Using main"
|
||||||
|
git push -u origin main
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q master .git/config; then
|
||||||
|
echo "Using master"
|
||||||
|
git push -u origin master
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "################################################################"
|
||||||
|
echo "################### Git Push Done ######################"
|
||||||
|
echo "################################################################"
|
||||||
Reference in New Issue
Block a user