2018-01-05 11:36:55 +08:00
|
|
|
#!/bin/sh
|
2018-01-03 12:07:30 +08:00
|
|
|
|
2018-01-04 15:28:16 +08:00
|
|
|
THISDIR=`pwd`
|
|
|
|
if [ `basename $THISDIR` != 'build' ]; then
|
|
|
|
echo "Execute `basename $0` from the build directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-01-03 12:07:30 +08:00
|
|
|
|
2018-01-30 17:11:36 +08:00
|
|
|
BASE_DIR=`dirname $THISDIR`
|
|
|
|
SRC_DIR=$BASE_DIR/src
|
|
|
|
BUILD_DIR=$BASE_DIR/build
|
|
|
|
PKG_DIR=$BASE_DIR/Release
|
|
|
|
STAGING_DIR=$BASE_DIR/Staging
|
2018-01-03 12:07:30 +08:00
|
|
|
|
|
|
|
NAME='ztncui'
|
|
|
|
DESCRIPTION='ZeroTier network controller user interface'
|
|
|
|
VERSION=`grep version ../src/package.json | cut -f4 -d'"'`
|
2018-01-03 13:38:40 +08:00
|
|
|
VENDOR='Key Networks'
|
|
|
|
MAINTAINER='https://key-networks.com/contact'
|
2018-01-03 12:07:30 +08:00
|
|
|
URL='https://key-networks.com'
|
|
|
|
LICENSE='GPLv3'
|
|
|
|
|
2018-01-04 15:28:16 +08:00
|
|
|
BINDINGGYP='node_modules/argon2/binding.gyp'
|
|
|
|
|
2018-07-07 11:55:17 +08:00
|
|
|
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a ]; then
|
2018-01-04 15:28:16 +08:00
|
|
|
echo "You must install libstdc++-static"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-01-03 12:07:30 +08:00
|
|
|
|
2018-07-07 11:55:17 +08:00
|
|
|
if [ ! -f /usr/bin/rpmbuild ]; then
|
|
|
|
echo "You must install rpm-build"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /usr/bin/rpmsign ]; then
|
|
|
|
echo "You must install rpm-sign"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-01-03 12:07:30 +08:00
|
|
|
rm -fr $STAGING_DIR && mkdir $STAGING_DIR
|
|
|
|
rm -fr $PKG_DIR && mkdir $PKG_DIR
|
|
|
|
|
2018-01-04 15:28:16 +08:00
|
|
|
pushd .
|
2018-01-03 12:07:30 +08:00
|
|
|
cd ../src
|
2018-01-04 15:28:16 +08:00
|
|
|
pushd .
|
2018-01-03 12:07:30 +08:00
|
|
|
npm install
|
2018-01-04 15:28:16 +08:00
|
|
|
|
|
|
|
patch --forward --dry-run --silent $BINDINGGYP $BUILD_DIR/binding.gyp.patch
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Applying patch to $BINDINGGYP..."
|
|
|
|
patch --forward $BINDINGGYP $BUILD_DIR/binding.gyp.patch
|
|
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to patch $BINDINGGYP"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd node_modules/argon2/
|
|
|
|
node-gyp rebuild
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to rebuild argon2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd
|
|
|
|
pkg -c ./package.json -t node8-linux-x64 bin/www -o $BUILD_DIR/ztncui
|
|
|
|
|
|
|
|
popd
|
2018-01-03 12:07:30 +08:00
|
|
|
|
2018-01-10 15:25:00 +08:00
|
|
|
install -m 755 -d $STAGING_DIR/opt
|
2018-01-03 12:07:30 +08:00
|
|
|
install -m 750 -d $STAGING_DIR/opt/key-networks
|
|
|
|
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui
|
|
|
|
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/etc
|
|
|
|
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/etc/tls
|
|
|
|
install -m 750 -d $STAGING_DIR/opt/key-networks/ztncui/node_modules/argon2/build/Release
|
2018-01-05 11:36:55 +08:00
|
|
|
install -m 755 -d $STAGING_DIR/lib/systemd/system
|
|
|
|
install -m 600 $SRC_DIR/etc/default.passwd $STAGING_DIR/opt/key-networks/ztncui/etc/default.passwd
|
2018-01-03 12:07:30 +08:00
|
|
|
install -m 755 $SRC_DIR/node_modules/argon2/build/Release/argon2.node $STAGING_DIR/opt/key-networks/ztncui/node_modules/argon2/build/Release/
|
2018-01-04 15:28:16 +08:00
|
|
|
install -m 755 $BUILD_DIR/ztncui $STAGING_DIR/opt/key-networks/ztncui/
|
2018-01-05 11:36:55 +08:00
|
|
|
install -m 644 $BUILD_DIR/ztncui.service $STAGING_DIR/lib/systemd/system
|
|
|
|
|
|
|
|
rm -f $BUILD_DIR/ztncui
|
2018-01-03 12:07:30 +08:00
|
|
|
|
|
|
|
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout $STAGING_DIR/opt/key-networks/ztncui/etc/tls/privkey.pem -out $STAGING_DIR/opt/key-networks/ztncui/etc/tls/fullchain.pem -config $BUILD_DIR/openssl.cnf
|
|
|
|
|
|
|
|
GENERAL_FPM_FLAGS="
|
|
|
|
--name $NAME
|
|
|
|
--version $VERSION
|
|
|
|
--url $URL
|
|
|
|
--license $LICENSE
|
|
|
|
--chdir $STAGING_DIR
|
|
|
|
--package $PKG_DIR
|
|
|
|
--directories /opt/key-networks
|
2018-01-05 14:04:32 +08:00
|
|
|
--depends zerotier-one
|
2018-01-05 11:36:55 +08:00
|
|
|
--before-install before-install.sh
|
2018-01-04 15:28:16 +08:00
|
|
|
--after-install after-install.sh
|
2018-01-05 11:36:55 +08:00
|
|
|
--before-remove before-remove.sh
|
|
|
|
--after-remove after-remove.sh
|
|
|
|
--before-upgrade before-upgrade.sh
|
|
|
|
--after-upgrade after-upgrade.sh
|
2018-01-03 12:07:30 +08:00
|
|
|
"
|
|
|
|
|
|
|
|
fpm -s dir -t rpm \
|
|
|
|
$GENERAL_FPM_FLAGS \
|
|
|
|
--vendor "$VENDOR" \
|
|
|
|
--maintainer "$MAINTAINER" \
|
|
|
|
--description "$DESCRIPTION" \
|
2018-01-05 11:36:55 +08:00
|
|
|
--rpm-user ztncui \
|
|
|
|
--rpm-group ztncui \
|
2018-01-09 19:50:42 +08:00
|
|
|
--rpm-sign \
|
2018-01-03 12:07:30 +08:00
|
|
|
.
|
|
|
|
|
|
|
|
fpm -s dir -t deb \
|
|
|
|
$GENERAL_FPM_FLAGS \
|
|
|
|
--vendor "$VENDOR" \
|
|
|
|
--maintainer "$MAINTAINER" \
|
|
|
|
--description "$DESCRIPTION" \
|
2018-01-05 11:36:55 +08:00
|
|
|
--deb-user ztncui \
|
|
|
|
--deb-group ztncui \
|
2018-01-03 12:07:30 +08:00
|
|
|
.
|
2018-01-09 20:11:03 +08:00
|
|
|
|
|
|
|
createrepo $PKG_DIR
|
|
|
|
gpg -u 'Key Networks' --detach-sign --armor $PKG_DIR/repodata/repomd.xml
|