mirror of https://github.com/Revertron/Alfis
Added packaging files for deb-based linux distributions.
parent
7cd6d95f99
commit
2305bd503e
@ -0,0 +1,128 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a lazy script to create a .deb for Debian/Ubuntu. It installs
|
||||||
|
# ALFIS and enables it in systemd. You can give it the PKGARCH= argument
|
||||||
|
# i.e. PKGARCH=i386 sh contrib/deb/generate.sh
|
||||||
|
|
||||||
|
if [ `pwd` != `git rev-parse --show-toplevel` ]
|
||||||
|
then
|
||||||
|
echo "You should run this script from the top-level directory of the git repo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PKGBRANCH=$(basename `git name-rev --name-only HEAD`)
|
||||||
|
PKGNAME=$(sh contrib/semver/name.sh)
|
||||||
|
PKGVERSION=$(sh contrib/semver/version.sh --bare)
|
||||||
|
PKGARCH=${PKGARCH-amd64}
|
||||||
|
PKGFILE=$PKGNAME-$PKGVERSION-$PKGARCH.deb
|
||||||
|
PKGREPLACES=alfis
|
||||||
|
|
||||||
|
#if [ $PKGBRANCH = "master" ]; then
|
||||||
|
# PKGREPLACES=alfis-develop
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# Building nogui versions only
|
||||||
|
if [ $PKGARCH = "amd64" ]; then cargo build --release --no-default-features && cp target/release/alfis ./alfis
|
||||||
|
elif [ $PKGARCH = "i686" ]; then cross build --target i686-unknown-linux-gnu --release --no-default-features && cp target/i686-unknown-linux-gnu/release/alfis ./alfis
|
||||||
|
elif [ $PKGARCH = "mipsel" ]; then cross build --release --no-default-features --target mipsel-unknown-linux-gnu && cp target/mipsel-unknown-linux-gnu/release/alfis ./alfis
|
||||||
|
elif [ $PKGARCH = "mips" ]; then cross build --release --no-default-features --target mips-unknown-linux-gnu && cp target/mips-unknown-linux-gnu/release/alfis ./alfis
|
||||||
|
elif [ $PKGARCH = "armhf" ]; then cross build --release --no-default-features --target armv7-unknown-linux-gnueabihf && cp target/armv7-unknown-linux-gnueabihf/release/alfis ./alfis
|
||||||
|
elif [ $PKGARCH = "arm64" ]; then cross build --release --no-default-features --target aarch64-unknown-linux-gnu && cp target/aarch64-unknown-linux-gnu/release/alfis ./alfis
|
||||||
|
else
|
||||||
|
echo "Specify PKGARCH=amd64,i686,mips,mipsel,armhf,arm64,armel"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building $PKGFILE"
|
||||||
|
|
||||||
|
mkdir -p /tmp/$PKGNAME/
|
||||||
|
mkdir -p /tmp/$PKGNAME/debian/
|
||||||
|
mkdir -p /tmp/$PKGNAME/usr/bin/
|
||||||
|
mkdir -p /tmp/$PKGNAME/etc/systemd/system/
|
||||||
|
|
||||||
|
cat > /tmp/$PKGNAME/debian/changelog << EOF
|
||||||
|
Please see https://github.com/Revertron/Alfis/
|
||||||
|
EOF
|
||||||
|
echo 9 > /tmp/$PKGNAME/debian/compat
|
||||||
|
cat > /tmp/$PKGNAME/debian/control << EOF
|
||||||
|
Package: $PKGNAME
|
||||||
|
Version: $PKGVERSION
|
||||||
|
Section: contrib/net
|
||||||
|
Priority: extra
|
||||||
|
Architecture: $PKGARCH
|
||||||
|
Replaces: $PKGREPLACES
|
||||||
|
Conflicts: $PKGREPLACES
|
||||||
|
Maintainer: Revertron <revertron@users.noreply.github.com>
|
||||||
|
Description: ALFIS
|
||||||
|
ALFIS (ALternative Free Identity System) is an implementation of a Domain Name System
|
||||||
|
based on a small, slowly growing blockchain. It is lightweight, self-contained,
|
||||||
|
supported on multiple platforms and contains DNS-resolver on its own to resolve domain records
|
||||||
|
contained in blockchain and forward DNS requests of ordinary domain zones to upstream forwarders.
|
||||||
|
EOF
|
||||||
|
cat > /tmp/$PKGNAME/debian/copyright << EOF
|
||||||
|
Please see https://github.com/Revertron/Alfis/
|
||||||
|
EOF
|
||||||
|
cat > /tmp/$PKGNAME/debian/docs << EOF
|
||||||
|
Please see https://github.com/Revertron/Alfis/
|
||||||
|
EOF
|
||||||
|
cat > /tmp/$PKGNAME/debian/install << EOF
|
||||||
|
usr/bin/alfis usr/bin
|
||||||
|
etc/systemd/system/*.service etc/systemd/system
|
||||||
|
EOF
|
||||||
|
cat > /tmp/$PKGNAME/debian/postinst << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if ! getent group alfis 2>&1 > /dev/null; then
|
||||||
|
groupadd --system --force alfis || echo "Failed to create group 'alfis' - please create it manually and reinstall"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /var/lib/alfis
|
||||||
|
chgrp alfis /var/lib/alfis
|
||||||
|
|
||||||
|
if [ -f /etc/alfis.conf ];
|
||||||
|
then
|
||||||
|
mkdir -p /var/backups
|
||||||
|
echo "Backing up configuration file to /var/backups/alfis.conf.`date +%Y%m%d`"
|
||||||
|
cp /etc/alfis.conf /var/backups/alfis.conf.`date +%Y%m%d`
|
||||||
|
echo "Normalising and updating /etc/alfis.conf"
|
||||||
|
/usr/bin/alfis -u /var/backups/alfis.conf.`date +%Y%m%d` > /etc/alfis.conf
|
||||||
|
chgrp alfis /etc/alfis.conf
|
||||||
|
|
||||||
|
if command -v systemctl >/dev/null; then
|
||||||
|
systemctl daemon-reload >/dev/null || true
|
||||||
|
systemctl enable alfis || true
|
||||||
|
systemctl start alfis || true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Generating initial configuration file /etc/alfis.conf"
|
||||||
|
echo "Please familiarise yourself with this file before starting ALFIS"
|
||||||
|
sh -c 'umask 0027 && /usr/bin/alfis -g > /etc/alfis.conf'
|
||||||
|
chgrp alfis /etc/alfis.conf
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
cat > /tmp/$PKGNAME/debian/prerm << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
if command -v systemctl >/dev/null; then
|
||||||
|
if systemctl is-active --quiet alfis; then
|
||||||
|
systemctl stop alfis || true
|
||||||
|
fi
|
||||||
|
systemctl disable alfis || true
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cp alfis /tmp/$PKGNAME/usr/bin/
|
||||||
|
cp contrib/systemd/*.service /tmp/$PKGNAME/etc/systemd/system/
|
||||||
|
|
||||||
|
tar -czvf /tmp/$PKGNAME/data.tar.gz -C /tmp/$PKGNAME/ \
|
||||||
|
usr/bin/alfis \
|
||||||
|
etc/systemd/system/alfis.service \
|
||||||
|
etc/systemd/system/alfis-default-config.service
|
||||||
|
tar -czvf /tmp/$PKGNAME/control.tar.gz -C /tmp/$PKGNAME/debian .
|
||||||
|
echo 2.0 > /tmp/$PKGNAME/debian-binary
|
||||||
|
|
||||||
|
ar -r $PKGFILE \
|
||||||
|
/tmp/$PKGNAME/debian-binary \
|
||||||
|
/tmp/$PKGNAME/control.tar.gz \
|
||||||
|
/tmp/$PKGNAME/data.tar.gz
|
||||||
|
|
||||||
|
rm -rf /tmp/$PKGNAME
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get the current branch name
|
||||||
|
BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
|
||||||
|
|
||||||
|
# Complain if the git history is not available
|
||||||
|
if [ $? != 0 ] || [ -z "$BRANCH" ]; then
|
||||||
|
printf "alfis"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove "/" characters from the branch name if present
|
||||||
|
BRANCH=$(echo $BRANCH | tr -d "/")
|
||||||
|
|
||||||
|
# Check if the branch name is not master
|
||||||
|
if [ "$BRANCH" = "master" ]; then
|
||||||
|
printf "alfis"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it is something other than master, append it
|
||||||
|
printf "alfis-%s" "$BRANCH"
|
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get the last tag
|
||||||
|
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null)
|
||||||
|
|
||||||
|
# Did getting the tag succeed?
|
||||||
|
if [ $? != 0 ] || [ -z "$TAG" ]; then
|
||||||
|
printf -- "unknown"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the current branch
|
||||||
|
BRANCH=$(git symbolic-ref -q HEAD --short 2>/dev/null)
|
||||||
|
|
||||||
|
# Did getting the branch succeed?
|
||||||
|
if [ $? != 0 ] || [ -z "$BRANCH" ]; then
|
||||||
|
BRANCH="master"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split out into major, minor and patch numbers
|
||||||
|
MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1)
|
||||||
|
MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2)
|
||||||
|
PATCH=$(echo $TAG | cut -c 2- | cut -d "." -f 3)
|
||||||
|
|
||||||
|
# Output in the desired format
|
||||||
|
if [ $((PATCH)) -eq 0 ]; then
|
||||||
|
printf '%s%d.%d' "$PREPEND" "$((MAJOR))" "$((MINOR))"
|
||||||
|
else
|
||||||
|
printf '%s%d.%d.%d' "$PREPEND" "$((MAJOR))" "$((MINOR))" "$((PATCH))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add the build tag on non-master branches
|
||||||
|
if [ "$BRANCH" != "master" ]; then
|
||||||
|
BUILD=$(git rev-list --count $TAG..HEAD 2>/dev/null)
|
||||||
|
|
||||||
|
# Did getting the count of commits since the tag succeed?
|
||||||
|
if [ $? != 0 ] || [ -z "$BUILD" ]; then
|
||||||
|
printf -- "-unknown"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Is the build greater than zero?
|
||||||
|
if [ $((BUILD)) -gt 0 ]; then
|
||||||
|
printf -- "-%04d" "$((BUILD))"
|
||||||
|
fi
|
||||||
|
fi
|
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=ALFIS default config generator
|
||||||
|
ConditionPathExists=|!/etc/alfis.conf
|
||||||
|
ConditionFileNotEmpty=|!/etc/alfis.conf
|
||||||
|
Wants=local-fs.target
|
||||||
|
After=local-fs.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Group=alfis
|
||||||
|
StandardOutput=file:/etc/alfis.conf
|
||||||
|
ExecStart=/usr/bin/alfis -g
|
||||||
|
ExecStartPost=/usr/bin/chmod 0640 /etc/alfis.conf
|
@ -0,0 +1,21 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=alfis
|
||||||
|
Wants=network.target
|
||||||
|
Wants=alfis-default-config.service
|
||||||
|
After=network.target
|
||||||
|
After=alfis-default-config.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Group=alfis
|
||||||
|
ProtectHome=true
|
||||||
|
ProtectSystem=true
|
||||||
|
SyslogIdentifier=alfis
|
||||||
|
CapabilityBoundingSet=CAP_NET_ADMIN
|
||||||
|
WorkingDirectory=/var/lib/alfis
|
||||||
|
ExecStart=/usr/bin/alfis -n -c /etc/alfis.conf
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart=always
|
||||||
|
TimeoutStopSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue