1
0

增加一个 h3c-inode-client,还有一点小问题

This commit is contained in:
Sense T 2025-02-28 15:27:22 +08:00
parent 288eeaccc9
commit e8e111d337
4 changed files with 225 additions and 12 deletions

62
flake.lock generated Normal file
View File

@ -0,0 +1,62 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1740547748,
"narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3a05eebede89661660945da1f151959900903b6a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735554305,
"narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1739829690,
"narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "3d0579f5cc93436052d94b73925b48973a104204",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,6 +1,4 @@
{
description = "";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
@ -22,6 +20,8 @@
libz
atk
ell
bash
coreutils
glib
cairo
ncurses5
@ -39,12 +39,11 @@
{
formatter.${system} = treefmtEval.config.build.wrapper;
devShell."${system}" = mkShell {
buildInputs =
with pkgs;
[
tokei
]
++ packages-inode;
nativeBuildInputs = with pkgs; [
tokei
nil
];
buildInputs = packages-inode;
};
packages."${system}" = {
@ -54,13 +53,19 @@
in
pkgs.buildFHSEnv {
name = "inode-dev-shell";
buildInputs = packages-inode;
targetPkgs = pkgs: with pkgs; [ ] ++ packages;
targetPkgs = pkgs: [ pkgs.makeWrapper ] ++ packages-inode;
profile = ''
export FHS=1
export PROMPT_COMMAND="echo -n '(FHS)'"
'';
extraBuildCommands = ''
echo $PATH
# mount --bind $HOME/.config/iNode/ $out/iNodeClient/clientfiles
'';
};
h3c-inode-client = pkgs.callPackage ./h3c-inode-client/package.nix { };
};
};
}

View File

@ -0,0 +1,146 @@
{
stdenv,
makeWrapper,
autoPatchelfHook,
# denpendencies
libgcc,
libxcrypt-legacy,
libuuid,
libpng12,
libjpeg,
libudev0-shim,
libz,
atk,
bash,
coreutils,
ell,
glib,
cairo,
ncurses5,
pango,
gtk2,
gdk-pixbuf,
freetype,
fontconfig,
xorg, # libSM, libX11, libXxf86vm
...
}:
let
install_dir = "/opt/iNodeClient";
libraries = [
libgcc
libxcrypt-legacy
libuuid
libpng12
libjpeg
libudev0-shim
libz
atk
ell
bash
coreutils
glib
cairo
ncurses5
pango
gtk2
gdk-pixbuf
freetype
fontconfig
xorg.libSM
xorg.libX11
xorg.libXxf86vm
];
in
stdenv.mkDerivation {
pname = "h3c-inode-client";
version = "7.3.0";
src = fetchTarball {
url = "https://download.h3c.com/app/cn/download.do?id=7684846";
sha256 = "0y92bia0xcm6d8al3vzkgglcqd63z09lkssvi9ihsz6m1kabwxyl";
};
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
buildInputs = libraries;
installPhase = ''
# 安装应用文件
mkdir -p $out${install_dir}
for i in $(ls -a $src); do
if [ $i == "$src/clientfiles" ]; then
continue
fi
cp -r $i $out${install_dir}
done
for i in $(ls $out${install_dir}/*.ps); do
sed -i 's|#!/bin/sh|#!/usr/bin/env sh|' $i
chmod +x $i
done
# 禁用 enablecards.ps (清空文件内容)
head -n1 $out${install_dir}/enablecards.ps | tee $out${install_dir}/enablecards.ps
# 客户端配置目录
rm -rf $out${install_dir}/clientfiles
ln -sf /var/lib/inode/clientfiles $out${install_dir}/
ln -sf /var/lib/inode/Data $out${install_dir}/
mkdir -p $out/var/lib/inode/conf
mv $out${install_dir}/conf/iNode.conf $out/var/lib/inode/conf
rm $out${install_dir}/conf -rf
ln -sf /var/lib/inode/conf $out${install_dir}/
# 日志目录
rm -rf $out${install_dir}/log
ln -sf /var/log/inode $out${install_dir}/log
# 快捷方式
mkdir -p $out/share/applications
cat $out${install_dir}/iNodeClient.desktop | sed "/^Exec=/s#@INSTALL_PATH/iNodeClient.sh#$out${install_dir}/.iNode/iNodeClient#" | sed "/^Icon=/s#@INSTALL_PATH#$out${install_dir}#" > $out/share/applications/iNodeClient.desktop
# /etc 目录文件
mkdir -p $out/etc/iNode
echo INSTALL_DIR=$out${install_dir} > $out/etc/iNode/inodesys.conf
# 运行文件
mkdir -p $out/bin
cat > $out/bin/h3c-inode-client <<EOF
#!/usr/bin/env bash
#$out${install_dir}/.iNode/iNodeClient
bash
EOF
chmod +x $out/bin/h3c-inode-client
cat > $out/bin/setup <<EOF
#!/usr/bin/env bash
[ -d /var/lib/inode/clientfiles/7000 ] || mkdir -p /var/lib/inode/clientfiles/7000
[ -d /var/lib/inode/Data ] || mkdir -p /var/lib/inode/Data
[ -d /var/lib/inode/conf ] || mkdir -p /var/lib/inode/conf
[ -e /var/lib/inode/conf/iNode.conf ] || cp $out/var/lib/inode/conf/iNode.conf /var/lib/inode/conf
chmod 777 -R /var/lib/inode/*
[ -d /var/log/inode/cmd ] || mkdir -p /var/log/inode/cmd
chmod 777 -R /var/log/inode
[ -e /etc/iNode/inodesys.conf ] || (mkdir -p /etc/iNode && ln -sf $out/etc/iNode/inodesys.conf /etc/iNode/inodesys.conf)
EOF
chmod +x $out/bin/setup
cat > $out/bin/AuthenMngService <<EOF
#!/usr/bin/env bash
$out${install_dir}/iNodeMon \$@
$out${install_dir}/AuthenMngService \$@
EOF
chmod +x $out/bin/AuthenMngService
'';
}