Skip to content

Commit c5a66f8

Browse files
committed
add ztncui-code
1 parent ebeee83 commit c5a66f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3660
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Release/
2+
Staging/
3+
ztncui
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
ETC='/opt/key-networks/ztncui/etc'
4+
if [ -f ${ETC}/passwd ]; then
5+
echo "Password file aready exists"
6+
else
7+
echo "Copying default password file..."
8+
cp -pv ${ETC}/default.passwd ${ETC}/passwd
9+
fi
10+
if [ -f /opt/key-networks/ztncui/etc/tls/privkey.pem ] && [ -f /opt/key-networks/ztncui/etc/tls/fullchain.pem ]; then
11+
echo "TLS key and certificate already exist"
12+
else
13+
echo "Generating new TLS key and self-signed certificate..."
14+
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout /opt/key-networks/ztncui/etc/tls/privkey.pem -out /opt/key-networks/ztncui/etc/tls/fullchain.pem -subj "/C=XX/ST=YY/L=ZZ/O=Security/OU=SelfSigned/CN=example.com"
15+
fi
16+
chown ztncui.ztncui /opt/key-networks/ztncui/etc/tls/*
17+
echo "Enabling and starting ztncui service..."
18+
systemctl enable ztncui
19+
systemctl start ztncui
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
systemctl daemon-reload
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
if [ -f /opt/key-networks/ztncui/etc/tls/privkey.pem ] && [ -f /opt/key-networks/ztncui/etc/tls/fullchain.pem ]; then
4+
echo "TLS key and certificate already exist"
5+
else
6+
echo "Generating new TLS key and self-signed certificate..."
7+
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout /opt/key-networks/ztncui/etc/tls/privkey.pem -out /opt/key-networks/ztncui/etc/tls/fullchain.pem -subj "/C=XX/ST=YY/L=ZZ/O=Security/OU=SelfSigned/CN=example.com"
8+
fi
9+
chown ztncui.ztncui /opt/key-networks/ztncui/etc/tls/*
10+
systemctl daemon-reload
11+
systemctl try-restart ztncui
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
getent passwd ztncui || useradd --system --home-dir /opt/key-networks/ztncui --shell /bin/false ztncui
2+
if [ $(getent group zerotier-one) ]; then
3+
echo "Adding user ztncui to group zerotier-one..."
4+
usermod -a -G zerotier-one ztncui
5+
chmod g+r /var/lib/zerotier-one/authtoken.secret
6+
else
7+
echo "Could not add user ztncui to group zerotier-one... is zerotier-one installed?"
8+
fi
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
systemctl stop ztncui
2+
systemctl disable ztncui

[email protected]/build/before-upgrade.sh

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- ../src/node_modules/argon2/binding.gyp
2+
+++ ../src/node_modules/argon2/binding.gyp
3+
@@ -47,6 +47,7 @@
4+
],
5+
"cflags+": ["-Wno-cast-function-type"],
6+
"include_dirs+": ["<!(node -e \"require('nan')\")"],
7+
+ "libraries": ["/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a"],
8+
"dependencies": ["libargon2"],
9+
"configurations": {
10+
"Debug": {

[email protected]/build/build.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
THISDIR=`pwd`
6+
if [ `basename $THISDIR` != 'build' ]; then
7+
echo "Execute `basename $0` from the build directory"
8+
exit 1
9+
fi
10+
11+
BASE_DIR=`dirname $THISDIR`
12+
SRC_DIR=$BASE_DIR/src
13+
BUILD_DIR=$BASE_DIR/build
14+
PKG_DIR=$BASE_DIR/Release
15+
STAGING_DIR=$BASE_DIR/Staging
16+
17+
NAME='ztncui'
18+
DESCRIPTION='ZeroTier network controller user interface'
19+
VERSION=`grep version ../src/package.json | cut -f4 -d'"'`
20+
VENDOR='Key Networks'
21+
MAINTAINER='https://key-networks.com/contact'
22+
URL='https://key-networks.com'
23+
LICENSE='GPLv3'
24+
25+
BINDINGGYP='node_modules/argon2/binding.gyp'
26+
27+
NODE_VER='v16'
28+
29+
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a ]; then
30+
echo "You must install libstdc++-static"
31+
exit 1
32+
fi
33+
34+
DEPS="rpmbuild rpmsign npm node"
35+
36+
for DEP in ${DEPS}; do
37+
if ! which ${DEP}; then
38+
echo "Missing dependency ${DEP}"
39+
exit 1
40+
fi
41+
done
42+
43+
rm -fr $STAGING_DIR && mkdir $STAGING_DIR
44+
rm -fr $PKG_DIR && mkdir $PKG_DIR
45+
46+
pushd .
47+
cd ../src
48+
pushd .
49+
50+
NVER=`node --version`
51+
if [[ ${NVER%%.*} != ${NODE_VER} ]]; then
52+
echo "Missing dependency node ${NODE_VER}"
53+
exit 1
54+
fi
55+
56+
[[ -d ../src/node_modules ]] && rm -fr ../src/node_modules
57+
58+
npm install
59+
60+
patch --forward --dry-run --silent $BINDINGGYP $BUILD_DIR/binding.gyp.patch
61+
if [ $? -eq 0 ]; then
62+
echo "Applying patch to $BINDINGGYP..."
63+
patch --forward $BINDINGGYP $BUILD_DIR/binding.gyp.patch
64+
fi
65+
if [ $? -ne 0 ]; then
66+
echo "Failed to patch $BINDINGGYP"
67+
exit 1
68+
fi
69+
70+
cd node_modules/argon2/
71+
node-gyp rebuild
72+
if [ $? -ne 0 ]; then
73+
echo "Failed to rebuild argon2"
74+
exit 1
75+
fi
76+
77+
popd
78+
pkg -c ./package.json -t node16-linux-x64 bin/www -o $BUILD_DIR/ztncui
79+
80+
popd
81+
82+
install -m 755 -d $STAGING_DIR/opt
83+
install -m 750 -d $STAGING_DIR/opt/key-networks
84+
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui
85+
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/etc
86+
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/etc/tls
87+
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/node_modules/argon2/build/Release
88+
install -m 755 -d $STAGING_DIR/lib/systemd/system
89+
install -m 600 $SRC_DIR/etc/default.passwd $STAGING_DIR/opt/key-networks/ztncui/etc/default.passwd
90+
install -m 755 $SRC_DIR/node_modules/argon2/build/Release/argon2.node $STAGING_DIR/opt/key-networks/ztncui/node_modules/argon2/build/Release/
91+
install -m 755 $BUILD_DIR/ztncui $STAGING_DIR/opt/key-networks/ztncui/
92+
install -m 644 $BUILD_DIR/ztncui.service $STAGING_DIR/lib/systemd/system
93+
94+
rm -f $BUILD_DIR/ztncui
95+
96+
GENERAL_FPM_FLAGS="
97+
--name $NAME
98+
--version $VERSION
99+
--url $URL
100+
--license $LICENSE
101+
--chdir $STAGING_DIR
102+
--package $PKG_DIR
103+
--directories /opt/key-networks
104+
--depends zerotier-one
105+
--depends openssl
106+
--before-install before-install.sh
107+
--after-install after-install.sh
108+
--before-remove before-remove.sh
109+
--after-remove after-remove.sh
110+
--before-upgrade before-upgrade.sh
111+
--after-upgrade after-upgrade.sh
112+
"
113+
114+
fpm -s dir -t rpm \
115+
$GENERAL_FPM_FLAGS \
116+
--vendor "$VENDOR" \
117+
--maintainer "$MAINTAINER" \
118+
--description "$DESCRIPTION" \
119+
--rpm-user ztncui \
120+
--rpm-group ztncui \
121+
.
122+
123+
fpm -s dir -t deb \
124+
$GENERAL_FPM_FLAGS \
125+
--vendor "$VENDOR" \
126+
--maintainer "$MAINTAINER" \
127+
--description "$DESCRIPTION" \
128+
--deb-user ztncui \
129+
--deb-group ztncui \
130+
.
131+
132+
rpm --addsign ../Release/ztncui*rpm
133+
rpm --checksig ../Release/ztncui*rpm
134+
135+
createrepo $PKG_DIR
136+
gpg -u 'Key Networks' --detach-sign --armor $PKG_DIR/repodata/repomd.xml

0 commit comments

Comments
 (0)