Compare commits

..
9 Commits
Author SHA1 Message Date
zhangsz 4741a0f007 fix: ... 2025-06-25 10:56:53 +08:00
zhangsz d139aa546f fix:. ... 2025-06-25 10:50:41 +08:00
zhangsz 0ce22ae0c4 fix: build shell script 2025-06-24 18:02:59 +08:00
caiyuchao a5f31f6bb8 fix: 文档更新 2025-04-29 19:33:04 +08:00
caiyuchao dcfd4cd181 fix: 文档更新 2025-04-28 14:04:36 +08:00
caiyuchao c88693c723 fix: gitignore 2025-04-18 12:10:58 +08:00
caiyuchao 05060e4b22 fix: add jar dir 2025-04-18 12:06:42 +08:00
caiyuchao 41dc1a937b feat: add jar dir 2025-04-18 12:04:10 +08:00
caiyuchao de8798b584 init project 2025-04-18 03:57:20 +00:00
16 changed files with 458 additions and 2 deletions

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
!.vscode/launch.json
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# docker
debbuild/opt/lic/docker/jar/*.jar
debbuild/opt/lic/docs/
# release
release
-2
View File
@@ -1,2 +0,0 @@
# license.build.wfc
Executable
+154
View File
@@ -0,0 +1,154 @@
#!/bin/bash
ProjectL=wfc-lic
ProjectU=WFC-LIC
RelDate=`date +%Y%m%d`
#GitRootDir=${HOME}/wfc.git
GitRootDir=$(dirname $(dirname $(dirname $(realpath $0))))
SrcRootDir=${GitRootDir}/license.wfc
BuildRootDir=${GitRootDir}/license.build.wfc
LicenseWorkDir=/opt/lic
BuildDockerDir=${BuildRootDir}/debbuild/opt/docker
ReleseDir=${BuildRootDir}/release
DebBuildDir=${BuildRootDir}/debbuild
DebReleseDir=${ReleseDir}/debs
usage() {
echo "Usage: sh build.sh [jar|srctar|deb] [-g]"
exit 1
}
SKIP_PRE_GIT_PULL=false
# Reorder arguments so that options come first
ARGS=()
for arg in "$@"; do
case $arg in
-g)
SKIP_PRE_GIT_PULL=true
;;
*)
ARGS+=("$arg")
;;
esac
done
if SKIP_PRE_GIT_PULL=true; then
ARGS+=("-g")
fi
# Restore positional parameters
set -- "${ARGS[@]}"
# Process options
while getopts "g" opt; do
case ${opt} in
g )
SKIP_PRE_GIT_PULL=true
;;
\? )
usage
;;
esac
done
shift $((OPTIND -1))
pre-git-pull(){
cd ${SrcRootDir}
git pull
cd ${BuildRootDir}
git pull
}
pre-build-deb(){
if [ ! -d ${ReleseDir}/debs ]; then
mkdir -p ${ReleseDir}/debs
fi
if [ ! -d ${DebBuildDir}/opt/lic ]; then
mkdir -p ${DebBuildDir}/opt/lic
fi
# git update-index --assume-unchanged ${BuildDockerDir}/env/wfc-release
}
build-jar(){
cd ${SrcRootDir}
# git pull
mvn clean package -Dmaven.test.skip=true
}
pre-build-src-tar(){
if [ ! -d ${ReleseDir}/src-tars ]; then
mkdir -p ${ReleseDir}/src-tars
fi
source ${BuildRootDir}/bin/control.sh
}
clean-jar(){
cd ${SrcRootDir}
mvn clean
}
copy-file-debbuild(){
DocsRootDir=${BuildRootDir}/docs
rm -rf ${DebBuildDir}/opt/lic/docker/jar/*.jar
cp -rf ${SrcRootDir}/target/wfc-license-server*.jar ${DebBuildDir}/opt/lic/docker/jar/
cp -rf ${DocsRootDir}/*.pdf ${DebBuildDir}/opt/lic/docs/
}
# create source tar package
create-src-tar(){
SrcTarFileName=${ProjectL}-${RelVersion}-${RelDate}.src.tar.gz
echo -n "Begin build source tar package(${SrcTarFileName}) ... "
WFCRelativeDir=./wfc.git
LicenseSrcDir=${WFCRelativeDir}/license.wfc
LicenseBuildDir=${WFCRelativeDir}/license.build.wfc
cd ${HOME}
tar cvfz ${ReleseDir}/src-tars/${SrcTarFileName} \
--exclude=${LicenseSrcDir}/.git \
--exclude=${LicenseSrcDir}/.vscode \
--exclude=${LicenseSrcDir}/target \
--exclude=${LicenseBuildDir}/.git \
--exclude=${LicenseBuildDir}/.vscode \
--exclude=${LicenseBuildDir}/debbuild/opt/lic/docker/jar/*.jar \
--exclude=${LicenseBuildDir}/debbuild/opt/lic/docs \
--exclude=${LicenseBuildDir}/release \
${LicenseSrcDir} ${LicenseBuildDir} 1>/dev/null
echo "done"
}
# create deb package
create-deb(){
Version=$(grep '^Version:' ${DebBuildDir}/DEBIAN/control | awk '{print $2}')
DebPkgFile=${ProjectL}-${Version}-${RelDate}-ub22.deb
echo -n "Begin build deb package(${DebPkgFile}) ... "
dpkg -b ${DebBuildDir} ${DebReleseDir}/${DebPkgFile} 1>/dev/null
echo "done"
}
case "$1" in
"jar")
build-jar
;;
"deb")
if [ "$SKIP_PRE_GIT_PULL" = false ]; then
pre-git-pull
fi
pre-build-deb
build-jar
copy-file-debbuild
create-deb
;;
"srctar")
if [ "$SKIP_PRE_GIT_PULL" = false ]; then
pre-git-pull
fi
pre-build-src-tar
clean-jar
create-src-tar
# post-build
;;
*)
usage
;;
esac
+4
View File
@@ -0,0 +1,4 @@
Package=WFC-LIC
RelVersion=1.0.0
Architecture=amd64
Description='MacroHub Control and Billing System'
+10
View File
@@ -0,0 +1,10 @@
Package: license-server
Version: 1.0.0
Section: license-server
Prioritt: optional
Architecture: amd64
Maintainer: wfc
Depends:
Description: License Server
+111
View File
@@ -0,0 +1,111 @@
#!/bin/bash
# 默认值(可选)
TIME=""
declare -a IPS=() # 声明为数组
declare -a MACS=() # 声明为数组
CPU=""
MB=""
IP=""
MAC=""
CODE=""
# 解析命令行参数
while [[ $# -gt 0 ]]; do
case "$1" in
-t|--t)
TIME="$2"
shift 2 # 移除选项和参数值
;;
-ip|--ip)
shift # 先移除 "-ip" 自身
# 收集所有后续非选项参数(直到遇到下一个以 "-" 开头的参数)
while [[ $# -gt 0 ]] && [[ ! "$1" =~ ^- ]]; do
IPS+=("$1")
shift
done
# 检查是否至少有一个名字
if [[ ${#IPS[@]} -eq 0 ]]; then
echo "错误:-ip 参数需要至少一个名字"
exit 1
fi
;;
-mac|--mac)
shift # 先移除 "-mac" 自身
# 收集所有后续非选项参数(直到遇到下一个以 "-" 开头的参数)
while [[ $# -gt 0 ]] && [[ ! "$1" =~ ^- ]]; do
MACS+=("$1")
shift
done
# 检查是否至少有一个名字
if [[ ${#MACS[@]} -eq 0 ]]; then
echo "错误:-mac 参数需要至少一个名字"
exit 1
fi
;;
-cpu|--cpu)
CPU="$2"
shift 2
;;
-code|--code)
CODE="$2"
shift 2
;;
-mb|--mb)
MB="$2"
shift 2
;;
*) # 未知选项
echo "错误:未知选项 $1"
exit 1
;;
esac
done
# 检查必需参数
if [[ -z "$TIME" ]]; then
echo "错误:缺少 -t 参数"
exit 1
fi
# 输出结果(或执行其他操作)
echo "失效时间: $TIME"
IP=$(printf "%s\",\"" "${IPS[@]}")
IP=${IP%\",\"}
if [ ! -z "$IP" ]; then
IP=\"$IP\"
fi
MAC=$(printf "%s\",\"" "${MACS[@]}")
MAC=${MAC%\",\"}
if [ ! -z "$MAC" ]; then
MAC=\"$MAC\"
fi
RAW='{
"expiryTime": "'$TIME'",
"ipAddress": ['$IP'],
"macAddress": ['$MAC'],
"cpuSerial": "'$CPU'",
"activationCode": "'$CODE'",
"mainBoardSerial": "'$MB'"
}'
res=$(curl --location --request GET 'http://localhost:8070/license/generateLicense' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VyX2tleSI6IjE3NTE3MTBkLWI5YzItNGRjYy1iZGUwLTNlMTEyYjY2OGYzZCIsInBsYXRmb3JtIjoic3lzdGVtIiwidXNlcm5hbWUiOiJhZG1pbiJ9.NG7WLME_mH6nPhfAwwqHD3kzdlZi6Zn1B4t5BG_IMWRh9ClsoM0dqRH9agq7FKL4fn68cahbJS7EpFwCXNgOWA' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: 192.168.2.249:8070' \
--header 'Connection: keep-alive' \
--data-raw "$RAW")
echo $res
isok=$(echo $res | grep "result\":\"ok")
#echo "$RAW"
echo "------------------------"
if [ -z "$isok" ]; then
echo "生成license证书失败"
else
echo "生成license证书成功,license.lic文件在/opt/lic/docker/license目录下"
fi
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
WFCWorkDir=/opt/lic
DockerDir=${WFCWorkDir}/docker
DockerCompose=docker-compose
PIDFile=/run/licensecontrol.pid
case "$1" in
start)
cd ${DockerDir}
if [ -z "$2" ]; then
${DockerCompose} up -d
echo $! > ${PIDFile}
else
${DockerCompose} up -d $2
fi
;;
stop)
cd ${DockerDir}
if [ -z "$2" ]; then
${DockerCompose} stop
if [ -f ${PIDFile} ]; then
rm ${PIDFile}
fi
else
${DockerCompose} stop $2
fi
;;
restart)
$0 stop $2
sleep 1
$0 start $2
;;
down)
cd ${DockerDir}
if [ -z "$2" ]; then
${DockerCompose} down --rmi all
if [ -f ${PIDFile} ]; then
rm ${PIDFile}
fi
else
${DockerCompose} down --rmi $2
fi
;;
status)
cd ${DockerDir}
if [ -z "$2" ]; then
${DockerCompose} ps
else
${DockerCompose} ps $2
fi
;;
*)
echo "License Server Service ... "
echo "Usage: $0 start|stop|restart|down|status"
exit 1
;;
esac
@@ -0,0 +1,12 @@
version: '3.8'
services:
wfc-license-serve:
# 使用前面创建的Dockerfile构建的镜像
build: .
# 指定容器名(可选)
container_name: wfc-license-server
# 指定端口映射(例如,将容器的8080端口映射到主机的8080端口)
ports:
- "8070:8070"
volumes:
- ./license:/opt/license
+15
View File
@@ -0,0 +1,15 @@
# 基础镜像
FROM openjdk:8-jre
# author
LABEL org.wfc.image.authors="wfc@wfc.org"
# 挂载目录
VOLUME /opt/wfc
# 创建目录
RUN mkdir -p /opt/wfc
# 指定路径
WORKDIR /opt/wfc
# 复制jar文件到路径
COPY jar/wfc-license-server-1.0.0.jar /opt/wfc/wfc-license-server.jar
# 启动licese-serve服务
ENTRYPOINT ["java","-jar","wfc-license-server.jar"]
+1
View File
@@ -0,0 +1 @@
�����֤���Ĵ���õ�jar�ļ�������docker����Ӧ�á�
Binary file not shown.
+39
View File
@@ -0,0 +1,39 @@
# Licence软件操作手册
## Project Introduction
A License, also known as a copyright license certificate, is typically provided to paying users of paid software as proof of access permission. License authentication is a verification method based on authorization. During the startup or operation of an application, it will check the validity of the License file. If an invalid or expired License is detected, the application will refuse to provide services.
This project is used to generate the license.lic certificate and provide it to users for use. This project is not available for external use.
* Directory tree after installation
```text
/opt/lic # work root directory
├── bin # shell script and binary file
├── docker # docker compose work directory
│   └── jar # jar package
└── docs # related document directory
```
* Launch the project
```sh
cd /opt/lic/bin
sudo ./licensecontrol.sh start
```
* Generate certificate
```sh
cd /opt/lic/bin
sudo ./generatelic.sh -t "2026-05-31 23:59:59" -code "ud9BGY9yZzo/ekXvf5vXzS4RmyCXm9a7rBqiUy1q7x+0kIBSz6AJ98MtGQiojJLpFbYRD1RkP2UsbtGCxyyozTK69+OWukfq9zTMu2qCkXcajL+HhuF/0VJQDSWPjp+J"
```
generatelic script parameter description:
-t Certificate expiration time, required field. Format: "2026-05-31 23:59:59"
- Code: Activation code, optional, format:"ud9BGY9yZzo/ekXvf5vXzS4RmyCXm9a7rBqiUy1q7x+0kIBSz6AJ98MtGQiojJLpFbYRD1RkP2UsbtGCxyyozTK69+OWukfq9zTMu2qCkXcajL+HhuF/0VaJQDSWPjp+J"
The activation code is the unique identifier of the device and is used to specify the machine for certificate usage. The activation code is automatically generated in /opt/wfc/docker/conf/license/activation_code.txt after the WANFI project is running.
The certificate is generated at /opt/lic/docker/license/license.lic.
The license.lic file must be placed in the /opt/wfc/docker/conf/license/ directory of the WANFI project for the project to be able to use it.
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
# Licence软件操作手册
## 项目介绍
License也就是版权许可证书,一般用于收费软件给付费用户提供的访问许可证明,License认证是一种基于授权许可的验证方式。应用程序在启动或运行过程中会检查License文件的有效性,如果检测到无效或过期的 License,应用程序将拒绝提供服务。
本项目用于生成license.lic证书,将证书提供给用户使用。本项目不对外提供。
* 安装后目录树
```text
/opt/lic # work root directory
├── bin # shell script and binary file
├── docker # docker compose work directory
│   └── jar # jar package
└── docs # related document directory
```
* 启动项目
```sh
cd /opt/lic/bin
sudo ./licensecontrol.sh start
```
* 生成证书
```sh
cd /opt/lic/bin
sudo ./generatelic.sh -t "2026-05-31 23:59:59" -code "ud9BGY9yZzo/ekXvf5vXzS4RmyCXm9a7rBqiUy1q7x+0kIBSz6AJ98MtGQiojJLpFbYRD1RkP2UsbtGCxyyozTK69+OWukfq9zTMu2qCkXcajL+HhuF/0VJQDSWPjp+J"
```
generatelic脚本参数说明:
-t 证书到期时间,必填,格式如"2026-05-31 23:59:59"
-code 激活码,可选,格式如"ud9BGY9yZzo/ekXvf5vXzS4RmyCXm9a7rBqiUy1q7x+0kIBSz6AJ98MtGQiojJLpFbYRD1RkP2UsbtGCxyyozTK69+OWukfq9zTMu2qCkXcajL+HhuF/0VaJQDSWPjp+J"
激活码是设备的唯一标识,用于指定的机器使用证书,激活码在WANFI项目运行后自动生成在/opt/wfc/docker/conf/license/activation_code.txt
证书生成在/opt/lic/docker/license/license.lic
将license.lic文件放入wanfi项目目录/opt/wfc/docker/conf/license/,WANFI项目才可使用
Binary file not shown.