Merge pull request #101 from odysseus654/rpm-pr

RPM & Deb build scripts for server
This commit is contained in:
kasenvr 2020-03-28 19:56:49 -04:00 committed by GitHub
commit a0e23580f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 916 additions and 0 deletions

View file

@ -0,0 +1,43 @@
FROM ubuntu:18.04
ARG DEPENDS
ARG GITSRC
ARG GITDATE
ARG GITCOMMIT
# starting out as root, will drop back in entrypoint.sh
USER root
# expose ports for domain server
EXPOSE 40100 40101 40102
EXPOSE 40100/udp 40101/udp 40102/udp
# expose ports for assignment client
EXPOSE 48000/udp 48001/udp 48002/udp 48003/udp 48004/udp 48005/udp 48006/udp
RUN echo UTC >/etc/timezone
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install -y tzdata supervisor ${DEPENDS} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /var/lib/athena
RUN groupadd -r athena ; \
useradd -Nr athena -d /var/lib/athena ; \
usermod -aG athena athena ; \
chown athena.athena /var/lib/athena ; \
exit 0
VOLUME /var/lib/athena
RUN mkdir -p /var/run ; chmod 777 /var/run
COPY athena.conf /etc/supervisor/conf.d/athena.conf
COPY entrypoint.sh /
COPY opt /opt/athena
COPY lib /opt/athena/lib
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/athena.conf"]
LABEL \
net.projectathena.gitsrc="${GITSRC}" \
net.projectathena.gitdate="${GITDATE}" \
net.projectathena.gitcommit="${GITCOMMIT}"

60
pkg-scripts/README Normal file
View file

@ -0,0 +1,60 @@
Collection of scripts to create server distribution packages. Most of these scripts assume
use of the build script at https://github.com/daleglass/athena-builder, specifically that
the following directory structure exists
base folder/
source/ git checkout
build/ result of cmake build
qt5-install/ installed or built Qt5 installation
These scripts assume that the current directory is the pkg-scripts folder inside of the source directory
and that the base folder can be reached by going to "../..". This may not work if pkg-scripts is a symlink;
adding an ATHENA=~/Athena to the beginning of the commandline will override where it looks for the base folder
Ubuntu:
DEBEMAIL="your-email@somewhere.com" DEBFULLNAME="Your Full Name" ./make-deb-server
This script will retrieve the current git commit date and hash and assemble a version from it.
It will attempt construct a .deb file in the pkg-scripts folder
Amazon Linux 2:
./make-rpm-server
This script will retrieve the current git commit date and hash and assemble a version from it.
It will attempt construct an .rpm file in the pkg-scripts folder
Docker:
./make-docker-server
This script will attempt to create a docker container
Results:
The following directory structure is created for binaries:
/opt/athena - executables
/opt/athena/lib - private shared libraries required for executables
/opt/athena/resources - files required by domain-server administrative website
/opt/athena/plugins - files required by assignment-client, mainly for audio codecs
The following systemd services are installed in /usr/lib/systemd/system:
athena-assignment-client.service
athena-domain-server.service
athena-server.target - used to launch/shutdown the two prior services
athena-assignment-client@.service
athena-domain-server@.service
athena-server@.target - used to launch/shutdown the two prior services
The top three services in this list are the "normal" services that launch Athena
in the typical fashion. The bottom three services are "template" services designed
to permit multiple services to be installed and running on a single machine.
The script "/opt/athena/new-server serverName basePort" will do the necessary
setup for a new domain with the specified server name and port. Upon installation
the package will create and launch a domain named "default" at base port 40100.
The domain name here has nothing to do with the name people will use to find your
domain and has nothing to do with "place names", it is only used to locate the files
used to configure and run the domain on your server.
The server stores its files in the following locations:
/var/lib/athena/.local - "unnamed" services (the default location for Athena servers)
/var/lib/athena/serverName - "named" (template) domains
/etc/opt/athena - environment variables when launching named domains

View file

@ -0,0 +1,18 @@
[Unit]
Description=Assignment client service for Athena server
After=network.target
PartOf=athena-server.target
[Service]
Restart=always
WorkingDirectory=/opt/athena
Environment="LD_LIBRARY_PATH=/opt/athena/lib"
User=athena
Group=athena
#LimitCORE=infinity
#ExecStart=/opt/athena/assignment-client -n 6
ExecStart=/opt/athena/assignment-client --min 6 --max 20
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,20 @@
[Unit]
Description=Assignment client service for Athena server
After=network.target
PartOf=athena-server@%i.target
[Service]
Restart=always
WorkingDirectory=/opt/athena
EnvironmentFile=/etc/opt/athena/%i.conf
Environment="LD_LIBRARY_PATH=/opt/athena/lib" "HOME=/var/lib/athena/%i"
PrivateTmp=true
User=athena
Group=athena
#LimitCORE=infinity
#ExecStart=/opt/athena/assignment-client -n 6
ExecStart=/opt/athena/assignment-client --min 6 --max 20 --server-port $HIFI_DOMAIN_SERVER_PORT
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,18 @@
[Unit]
Description=Domain Server service for Athena
After=network.target
PartOf=athena-server.target
[Service]
Restart=on-failure
WorkingDirectory=/opt/athena
Environment="LD_LIBRARY_PATH=/opt/athena/lib"
User=athena
Group=athena
#LimitCORE=infinity
#ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l domain-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/domain-server/domain-server; fi'
ExecStart=/opt/athena/domain-server
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,20 @@
[Unit]
Description=Domain Server service for Athena
After=network.target
PartOf=athena-server@%i.target
[Service]
Restart=on-failure
WorkingDirectory=/opt/athena
EnvironmentFile=/etc/opt/athena/%i.conf
Environment="LD_LIBRARY_PATH=/opt/athena/lib" "HOME=/var/lib/athena/%i"
PrivateTmp=true
User=athena
Group=athena
#LimitCORE=infinity
#ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l domain-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/domain-server/domain-server; fi'
ExecStart=/opt/athena/domain-server
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,18 @@
[Unit]
Description=Ice Server service for Athena
After=network.target
PartOf=athena-server.target
[Service]
Restart=on-failure
Environment="HIFI_ENVIRONMENT=production" "LD_LIBRARY_PATH=/opt/athena/lib"
WorkingDirectory=/opt/athena
User=athena
Group=athena
#ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l ice-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/ice-server/ice-server; fi'
#LimitCORE=infinity
ExecStart=/opt/athena/ice-server
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,20 @@
[Unit]
Description=Ice Server service for Athena
After=network.target
PartOf=athena-server@%i.target
[Service]
Restart=on-failure
EnvironmentFile=/etc/opt/athena/%i.conf
Environment="HIFI_ENVIRONMENT=production" "LD_LIBRARY_PATH=/opt/athena/lib" "HOME=/var/lib/athena/%i"
PrivateTmp=true
WorkingDirectory=/opt/athena
User=athena
Group=athena
#ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l ice-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/ice-server/ice-server; fi'
#LimitCORE=infinity
ExecStart=/opt/athena/ice-server
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,128 @@
#ATHENA=~/Athena rpmbuild --target x86_64 -bb athena-server.spec
%define version %{lua:print(os.getenv("VERSION"))}
%define depends %{lua:print(os.getenv("DEPENDS"))}
Name: athena-server
Version: %{version}
Release: 1%{?dist}
Summary: Project Athena metaverse platform, based on the High Fidelity Engine.
License: ASL 2.0
URL: https://projectathena.io
Source0: https://github.com/daleglass/athena-builder/blob/master/athena_builder
#BuildRequires: systemd-rpm-macros
BuildRequires: chrpath
Requires: %{depends}
BuildArch: x86_64
AutoReq: no
AutoProv: no
%description
Project Athena allows creation and sharing of VR experiences.
The Project Athena metaverse provides built-in social features, including avatar interactions, spatialized audio and interactive physics. Additionally, you have the ability to import any 3D object into your virtual environment.
%prep
%build
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT/opt/athena
install -m 0755 -t $RPM_BUILD_ROOT/opt/athena $ATHENA/build/assignment-client/assignment-client
install -m 0755 -t $RPM_BUILD_ROOT/opt/athena $ATHENA/build/domain-server/domain-server
install -m 0755 -t $RPM_BUILD_ROOT/opt/athena $ATHENA/build/tools/oven/oven
#install -m 0755 -t $RPM_BUILD_ROOT/opt/athena $ATHENA/build/ice-server/ice-server
strip --strip-all $RPM_BUILD_ROOT/opt/athena/*
chrpath -d $RPM_BUILD_ROOT/opt/athena/*
install -m 0755 -t $RPM_BUILD_ROOT/opt/athena $ATHENA/source/pkg-scripts/new-server
install -d $RPM_BUILD_ROOT/opt/athena/lib
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/build/libraries/*/*.so
strip --strip-all $RPM_BUILD_ROOT/opt/athena/lib/*
chrpath -d $RPM_BUILD_ROOT/opt/athena/lib/*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Network.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Core.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Widgets.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Gui.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Script.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Quick.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5WebSockets.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5Qml.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/qt5-install/lib/libQt5ScriptTools.so.*.*.*
install -m 0644 -t $RPM_BUILD_ROOT/opt/athena/lib $ATHENA/build/ext/makefiles/quazip/project/lib/libquazip5.so.*.*.*
install -d $RPM_BUILD_ROOT/usr/lib/systemd/system
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-assignment-client.service
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-assignment-client@.service
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-domain-server.service
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-domain-server@.service
#install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-ice-server.service
#install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-ice-server@.service
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-server.target
install -m 0644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system $ATHENA/source/pkg-scripts/athena-server@.target
cp -a $ATHENA/source/domain-server/resources $RPM_BUILD_ROOT/opt/athena
cp -a $ATHENA/build/assignment-client/plugins $RPM_BUILD_ROOT/opt/athena
chrpath -d $RPM_BUILD_ROOT/opt/athena/plugins/*.so
chrpath -d $RPM_BUILD_ROOT/opt/athena/plugins/*/*.so
strip --strip-all $RPM_BUILD_ROOT/opt/athena/plugins/*.so
strip --strip-all $RPM_BUILD_ROOT/opt/athena/plugins/*/*.so
find $RPM_BUILD_ROOT/opt/athena/resources -name ".gitignore" -delete
%files
%license $ATHENA/source/LICENSE
/opt/athena
/usr/lib/systemd/system
%changelog
%post
# create users
getent passwd athena >/dev/numm 2>&1 || useradd -r -c "Project Athena" -d /var/lib/athena -U -M athena
#getent group athena >/dev/null 2>&1 || groupadd -r athena
# create data folder
mkdir -p /etc/opt/athena
mkdir -p /var/lib/athena && chown athena:athena /var/lib/athena && chmod 775 /var/lib/athena
ldconfig -n /opt/athena/lib
if [ ! -d "/var/lib/athena/default" ]; then
/opt/athena/new-server default 40100
systemctl enable athena-server@default.target
systemctl start athena-server@default.target
fi
%systemd_post athena-assignment-client.service
%systemd_post athena-assignment-client@.service
%systemd_post athena-domain-server.service
%systemd_post athena-domain-server@.service
#%systemd_post athena-ice-server.service
#%systemd_post athena-ice-server@.service
%systemd_post athena-server.target
%systemd_post athena-server@.target
%preun
%systemd_preun athena-server.target
%systemd_preun athena-server@.target
%systemd_preun athena-assignment-client.service
%systemd_preun athena-assignment-client@.service
%systemd_preun athena-domain-server.service
%systemd_preun athena-domain-server@.service
#%systemd_preun athena-ice-server.service
#%systemd_preun athena-ice-server@.service
%postun
%systemd_postun_with_restart athena-server.target
%systemd_postun_with_restart athena-server@.target
%systemd_postun_with_restart athena-assignment-client.service
%systemd_postun_with_restart athena-assignment-client@.service
%systemd_postun_with_restart athena-domain-server.service
%systemd_postun_with_restart athena-domain-server@.service
#%systemd_postun_with_restart athena-ice-server.service
#%systemd_postun_with_restart athena-ice-server@.service

View file

@ -0,0 +1,11 @@
[Unit]
Description=Athena virtual domain
Wants=athena-assignment-client.service
Wants=athena-domain-server.service
#Wants=athena-ice-server.service
After=athena-assignment-client.service
After=athena-domain-server.service
#After=athena-ice-server.service
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,11 @@
[Unit]
Description=Athena virtual domain
Wants=athena-assignment-client@%i.service
Wants=athena-domain-server@%i.service
#Wants=athena-ice-server@%i.service
After=athena-assignment-client@%i.service
After=athena-domain-server@%i.service
#After=athena-ice-server@%i.service
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,76 @@
[supervisord]
user=athena
nodaemon=true
environment=HOME="/var/lib/athena",USER="athena",LD_LIBRARY_PATH="/opt/athena/lib"
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
[program:domain-server]
command=/opt/athena/domain-server
autorestart=unexpected
directory=/opt/athena
[program:audio-mixer]
command=/opt/athena/assignment-client -t 0 -a localhost -p 48000
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:avatar-mixer]
command=/opt/athena/assignment-client -t 1 -a localhost -p 48001
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:entities-server]
command=/opt/athena/assignment-client -t 6 -a localhost -p 48006
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:asset-server]
command=/opt/athena/assignment-client -t 3 -a localhost -p 48003
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:entity-script-server]
command=/opt/athena/assignment-client -t 5 -a localhost -p 48005
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:messages-mixer]
command=/opt/athena/assignment-client -t 4 -a localhost -p 48004
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:scripted-agent]
command=/opt/athena/assignment-client -t 2 -a localhost --max 100
autorestart=unexpected
directory=/opt/athena
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View file

@ -0,0 +1,33 @@
#!/bin/sh
set -x
# In Prod, this may be configured with a GID already matching the container
# allowing the container to be run directly as Jenkins. In Dev, or on unknown
# environments, run the container as root to automatically correct docker
# group in container to match the docker.sock GID mounted from the host.
if [ -f /var/lib/athena/.local -a "$(id -u)" = "0" ]; then
# realign gid
THIS_ATHENA_GID=`ls -ngd /var/lib/athena/.local | cut -f3 -d' '`
CUR_ATHENA_GID=`getent group athena | cut -f3 -d: || true`
if [ ! -z "$THIS_ATHENA_GID" -a "$THIS_ATHENA_GID" != "$CUR_ATHENA_GID" ]; then
groupmod -g ${THIS_ATHENA_GID} -o athena
fi
# realign pid
THIS_ATHENA_PID=`ls -nd /var/lib/athena/.local | cut -f3 -d' '`
CUR_ATHENA_PID=`getent passwd athena | cut -f3 -d: || true`
if [ ! -z "$THIS_ATHENA_PID" -a "$THIS_ATHENA_PID" != "$CUR_ATHENA_PID" ]; then
usermod -u ${THIS_ATHENA_PID} -o athena
fi
if ! groups athena | grep -q athena; then
usermod -aG athena athena
fi
fi
chmod 777 /dev/stdout
chmod 777 /dev/stderr
# continue with CMD
exec "$@"

110
pkg-scripts/make-deb-server Executable file
View file

@ -0,0 +1,110 @@
#!/bin/sh
if [ "$ATHENA" = "" ]; then
ATHENA=`realpath ../..`
fi
GITDATE=`git -C $ATHENA/source log -n 1 --format=raw | grep author | cut -d">" -f 2 | cut -d" " -f 2 | xargs -I {} date -d @{} +"%Y%m%d"`
GITCOMMIT=`git -C $ATHENA/source rev-parse HEAD | cut -c 1-7`
VERSION=0.86.0-k2-$GITDATE-$GITCOMMIT
sudo apt-get install chrpath binutils dh-make
DEB_BUILD_ROOT=temp-make-deb/athena-server-$VERSION-0ubuntu1
rm -r temp-make-deb
mkdir -p $DEB_BUILD_ROOT
# copy the files over
cp $ATHENA/build/assignment-client/assignment-client $DEB_BUILD_ROOT
cp $ATHENA/build/domain-server/domain-server $DEB_BUILD_ROOT
cp $ATHENA/build/tools/oven/oven $DEB_BUILD_ROOT
cp $ATHENA/build/libraries/*/*.so $DEB_BUILD_ROOT
#cp $ATHENA/build/ice-server/ice-server $DEB_BUILD_ROOT
chrpath -d $DEB_BUILD_ROOT/*
cp $ATHENA/qt5-install/lib/libQt5Network.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Core.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Widgets.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Gui.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Script.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Quick.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5WebSockets.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5Qml.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/qt5-install/lib/libQt5ScriptTools.so.*.*.* $DEB_BUILD_ROOT
cp $ATHENA/build/ext/makefiles/quazip/project/lib/libquazip5.so.*.*.* $DEB_BUILD_ROOT
chmod +x $DEB_BUILD_ROOT/*.so.*.*.*
strip --strip-all $DEB_BUILD_ROOT/*
cp $ATHENA/source/pkg-scripts/new-server $DEB_BUILD_ROOT
cp -a $ATHENA/source/domain-server/resources $DEB_BUILD_ROOT
find $DEB_BUILD_ROOT/resources -name ".gitignore" -delete
find $DEB_BUILD_ROOT/resources -type f -executable -exec sh -c 'chmod -x {}' \;
cp $ATHENA/source/README.md $DEB_BUILD_ROOT
cp $ATHENA/source/README_hifi.md $DEB_BUILD_ROOT
cp -a $ATHENA/build/assignment-client/plugins $DEB_BUILD_ROOT
strip --strip-all $DEB_BUILD_ROOT/plugins/*.so
strip --strip-all $DEB_BUILD_ROOT/plugins/*/*.so
#begin the debian package construction
cd $DEB_BUILD_ROOT
dh_make -p athena-server_$VERSION-0ubuntu1 -c apache -s --createorig -y
cp $ATHENA/source/pkg-scripts/athena-assignment-client.service debian
cp $ATHENA/source/pkg-scripts/athena-assignment-client@.service debian
cp $ATHENA/source/pkg-scripts/athena-domain-server.service debian
cp $ATHENA/source/pkg-scripts/athena-domain-server@.service debian
#cp $ATHENA/source/pkg-scripts/athena-ice-server.service debian
#cp $ATHENA/source/pkg-scripts/athena-ice-server@.service debian
cp $ATHENA/source/pkg-scripts/athena-server.target debian
cp $ATHENA/source/pkg-scripts/athena-server@.target debian
cp $ATHENA/source/pkg-scripts/server-control debian/control
cp $ATHENA/source/pkg-scripts/server-prerm debian/prerm
cp $ATHENA/source/pkg-scripts/server-postinst debian/postinst
cp $ATHENA/source/LICENSE debian/copyright
echo /etc/opt/athena > debian/dirs
echo /var/lib/athena >> debian/dirs
echo README.md > debian/docs
echo README_hifi.md >> debian/docs
echo assignment-client opt/athena > debian/install
echo domain-server opt/athena >> debian/install
echo oven opt/athena >> debian/install
#echo ice-server opt/athena >> debian/install
echo new-server opt/athena >> debian/install
for so in *.so.*.*.*; do
echo $so opt/athena/lib >> debian/install
done
for so in *.so; do
echo $so opt/athena/lib >> debian/install
done
#for service in *.service; do
# echo $service opt/athena/systemd >> debian/install
#done
#for target in *.target; do
# echo $target opt/athena/systemd >> debian/install
#done
find resources -type f -exec sh -c 'echo {} opt/athena/$(dirname "{}") >> debian/install' \;
find plugins -type f -exec sh -c 'echo {} opt/athena/$(dirname "{}") >> debian/install' \;
#echo usr/lib/systemd/system/athena-assignment-client.service opt/athena/systemd/athena-assignment-client.service > debian/athena-server.links
#echo usr/lib/systemd/system/athena-assignment-client@.service opt/athena/systemd/athena-assignment-client@.service >> debian/athena-server.links
#echo usr/lib/systemd/system/athena-domain-server.service opt/athena/systemd/athena-domain-server.service >> debian/athena-server.links
#echo usr/lib/systemd/system/athena-domain-server@.service opt/athena/systemd/athena-domain-server@.service >> debian/athena-server.links
##echo usr/lib/systemd/system/athena-ice-server.service opt/athena/systemd/athena-ice-server.service >> debian/athena-server.links
##echo usr/lib/systemd/system/athena-ice-server@.service opt/athena/systemd/athena-ice-server@.service >> debian/athena-server.links
#echo usr/lib/systemd/system/athena-server.target opt/athena/systemd/athena-server.target >> debian/athena-server.links
#echo usr/lib/systemd/system/athena-server@.target opt/athena/systemd/athena-server@.target >> debian/athena-server.links
SOFILES=`ls *.so *.so.*.*.* | sed 's/\./\\\./g' | paste -d'|' -s`
DEPENDS=`find * -type f -executable -exec sh -c 'objdump -p {} | grep NEEDED' \; | awk '{print $2}' | sort | uniq | egrep -v "^($SOFILES)$" | xargs -n 1 -I {} sh -c 'dpkg -S {} | head -n 1' | cut -d ':' -f 1 | sort | uniq | paste -d',' -s`
cp $ATHENA/source/pkg-scripts/server-rules debian/rules
sed "s/{DEPENDS}/$DEPENDS/" $ATHENA/source/pkg-scripts/server-control > debian/control
dpkg-buildpackage -us -uc
cd ..
mv *.deb ..
cd ..

60
pkg-scripts/make-docker-server Executable file
View file

@ -0,0 +1,60 @@
#!/bin/sh
if [ "$ATHENA" = "" ]; then
ATHENA=`realpath ../..`
fi
GITSRC=`git -C $ATHENA/source config --get remote.origin.url | cut -d':' -f 2`
GITDATE=`git -C $ATHENA/source log -n 1 --format=raw | grep author | cut -d">" -f 2 | cut -d" " -f 2 | xargs -I {} date -d @{} +"%Y%m%d"`
GITCOMMIT=`git -C $ATHENA/source rev-parse HEAD | cut -c 1-7`
sudo apt-get install chrpath binutils
DOCK_BUILD_ROOT=temp-make-dock
rm -r temp-make-dock
mkdir -p $DOCK_BUILD_ROOT
cp $ATHENA/source/pkg-scripts/Dockerfile.templ $DOCK_BUILD_ROOT/Dockerfile
cp $ATHENA/source/pkg-scripts/docker-entrypoint.sh $DOCK_BUILD_ROOT/entrypoint.sh
cp $ATHENA/source/pkg-scripts/docker-athena-supervisor.conf $DOCK_BUILD_ROOT/athena.conf
# copy the files over
mkdir -p $DOCK_BUILD_ROOT/opt
cp $ATHENA/build/assignment-client/assignment-client $DOCK_BUILD_ROOT/opt
cp $ATHENA/build/domain-server/domain-server $DOCK_BUILD_ROOT/opt
cp $ATHENA/build/tools/oven/oven $DOCK_BUILD_ROOT/opt
#cp $ATHENA/build/ice-server/ice-server $DOCK_BUILD_ROOT/opt
strip --strip-all $DOCK_BUILD_ROOT/opt/*
chrpath -d $DOCK_BUILD_ROOT/opt/*
cp -a $ATHENA/build/assignment-client/plugins $DOCK_BUILD_ROOT/opt
strip --strip-all $DOCK_BUILD_ROOT/opt/plugins/*.so
chrpath -d $DOCK_BUILD_ROOT/opt/plugins/*.so
strip --strip-all $DOCK_BUILD_ROOT/opt/plugins/*/*.so
chrpath -d $DOCK_BUILD_ROOT/opt/plugins/*/*.so
cp -a $ATHENA/source/domain-server/resources $DOCK_BUILD_ROOT/opt
find $DOCK_BUILD_ROOT/opt/resources -name ".gitignore" -delete
find $DOCK_BUILD_ROOT/opt/resources -type f -executable -exec sh -c 'chmod -x {}' \;
mkdir -p $DOCK_BUILD_ROOT/lib
cp $ATHENA/build/libraries/*/*.so $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Network.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Core.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Widgets.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Gui.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Script.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Quick.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5WebSockets.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5Qml.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/qt5-install/lib/libQt5ScriptTools.so.*.*.* $DOCK_BUILD_ROOT/lib
cp $ATHENA/build/ext/makefiles/quazip/project/lib/libquazip5.so.*.*.* $DOCK_BUILD_ROOT/lib
chmod +x $DOCK_BUILD_ROOT/lib/*
strip --strip-all $DOCK_BUILD_ROOT/lib/*
chrpath -d $DOCK_BUILD_ROOT/lib/*
ldconfig -n $DOCK_BUILD_ROOT/lib
SOFILES=`ls $DOCK_BUILD_ROOT/lib | sed 's/\./\\\./g' | paste -d'|' -s`
DEPENDS=`find $DOCK_BUILD_ROOT/opt $DOCK_BUILD_ROOT/lib -type f -executable -exec sh -c 'objdump -p {} | grep NEEDED' \; | awk '{print $2}' | sort | uniq | egrep -v "^($SOFILES)$" | xargs -n 1 -I {} sh -c 'dpkg -S {} | head -n 1' | cut -d ':' -f 1 | sort | uniq | paste -d' ' -s`
cd $DOCK_BUILD_ROOT
docker build -t odysseus654/athena-server --build-arg "DEPENDS=$DEPENDS" --build-arg "GITSRC=$GITSRC" --build-arg "GITDATE=$GITDATE" --build-arg "GITCOMMIT=$GITCOMMIT" .

56
pkg-scripts/make-rpm-server Executable file
View file

@ -0,0 +1,56 @@
#!/bin/sh
if [ "$ATHENA" = "" ]; then
ATHENA=`realpath ../..`
fi
GITDATE=`git -C $ATHENA/source log -n 1 --format=raw | grep author | cut -d">" -f 2 | cut -d" " -f 2 | xargs -I {} date -d @{} +"%Y%m%d"`
GITCOMMIT=`git -C $ATHENA/source rev-parse HEAD | cut -c 1-7`
VERSION=0.86.0_K2_${GITDATE}_${GITCOMMIT}
SOFILES=`ls \
$ATHENA/build/libraries/*/*.so \
$ATHENA/qt5-install/lib/libQt5Network.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Core.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Widgets.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Gui.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Script.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Quick.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5WebSockets.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Qml.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5ScriptTools.so.*.*.* \
$ATHENA/build/ext/makefiles/quazip/project/lib/libquazip5.so.*.*.* \
| sed 's/\./\\\./g' \
| paste -d'|' -s`
DEPENDS=mesa-libGL,`ls \
$ATHENA/build/assignment-client/assignment-client \
$ATHENA/build/domain-server/domain-server \
$ATHENA/build/tools/oven/oven \
$ATHENA/build/libraries/*/*.so \
$ATHENA/qt5-install/lib/libQt5Network.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Core.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Widgets.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Gui.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Script.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Quick.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5WebSockets.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5Qml.so.*.*.* \
$ATHENA/qt5-install/lib/libQt5ScriptTools.so.*.*.* \
$ATHENA/build/ext/makefiles/quazip/project/lib/libquazip5.so.*.*.* \
$ATHENA/build/assignment-client/plugins/*.so \
$ATHENA/build/assignment-client/plugins/*/*.so \
| xargs -I {} sh -c 'objdump -p {} | grep NEEDED' \
| awk '{print $2}' \
| sort | uniq \
| egrep -v "^($SOFILES)$" \
| grep -v ^libGL \
| xargs -I {} sh -c "ldconfig -p | grep {} | tr ' ' '\n' | grep /" \
| xargs rpm -qf --queryformat "%{NAME}\n" \
| sort | uniq \
| paste -d',' -s`
sudo yum install chrpath
export VERSION DEPENDS ATHENA
rpmbuild --target x86_64 -bb ./athena-server.spec
mv ~/rpmbuild/RPMS/x86_64/*.rpm .

49
pkg-scripts/new-server Executable file
View file

@ -0,0 +1,49 @@
#!/bin/sh
if [ -z "$1" ] || [ -z "$2" ]; then
echo "new-server {name} {base-port}"
echo
echo "Sets up a new athena server with the specified name and base port number"
echo " {name} - a simple name used to identify the server to scripts (not used in the server configuration)"
echo " {base-port} - the base port number (default server is 40100). The metaverse port will be {base-port}+2"
echo " Four contiguous port numbers are allocated, these must not overlap with other running services on this machine"
echo
echo "Launching a server created by this script is done with:"
echo " sudo systemctl start athena-server@{name}.target"
echo
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then
echo "new-server {name} {base-port}"
echo
echo 'This script must be run by root' >&2
exit 1
fi
if [ -d "/var/lib/athena/$1" ]; then
echo "Path /var/lib/athena/$1 already exists"
echo
echo "Please remove this path first if you wish to recreate this server"
exit 2
fi
mkdir -p /var/lib/athena/$1/.local/share
ln -s ../.. /var/lib/athena/$1/.local/share/Project\ Athena\ -\ dev
ln -s ../.. /var/lib/athena/$1/.local/share/Project\ Athena
mkdir -p /var/lib/athena/$1/domain-server
echo "{\"metaverse\": {\"local_port\": $(($2 + 2))},\"version\": 2.4}" > /var/lib/athena/$1/domain-server/config.json
chown -R athena.athena /var/lib/athena/$1
echo HIFI_DOMAIN_SERVER_HTTP_PORT=$2 > /etc/opt/athena/$1.conf
echo HIFI_DOMAIN_SERVER_HTTPS_PORT=$(($2 + 1)) >> /etc/opt/athena/$1.conf
echo HIFI_DOMAIN_SERVER_PORT=$(($2 + 2)) >> /etc/opt/athena/$1.conf
echo HIFI_DOMAIN_SERVER_DTLS_PORT=$(($2 + 3)) >> /etc/opt/athena/$1.conf
echo "A new athena server has been created with the name of '$1'"
echo
echo "To launch it:"
echo " sudo systemctl start athena-server@$1.target"
echo "To have it launch at system start:"
echo " sudo systemctl enable athena-server@$1.target"
echo "The server configuration console is available at:"
echo " http://localhost:$2"

View file

@ -0,0 +1,15 @@
Source: athena-server
Section: comm
Priority: optional
Maintainer: Heather Anderson <heath@odysseus.anderson.name>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.2
Homepage: https://www.projectathena.dev
Vcs-Git: https://github.com/kasenvr/project-athena.git
Vcs-Browser: https://github.com/kasenvr/project-athena
Package: athena-server
Architecture: any
Depends: adduser, {DEPENDS}
Description: Project Athena allows creation and sharing of VR experiences.
The Project Athena metaverse provides built-in social features, including avatar interactions, spatialized audio and interactive physics. Additionally, you have the ability to import any 3D object into your virtual environment.

53
pkg-scripts/server-postinst Executable file
View file

@ -0,0 +1,53 @@
#!/bin/sh
# postinst script for athena-server
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
ldconfig -n /opt/athena/lib
adduser --system --quiet --gecos "Project Athena" --home /var/lib/athena --group --no-create-home athena
mkdir -p /var/lib/athena
chown athena:athena /var/lib/athena
chmod 775 /var/lib/athena
if [ ! -d "/var/lib/athena/default" ]; then
/opt/athena/new-server default 40100
systemctl enable athena-server@default.target
systemctl start athena-server@default.target
fi
;;
abort-remove|abort-deconfigure)
ldconfig -n /opt/athena/lib
;;
abort-upgrade)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

42
pkg-scripts/server-prerm Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
# prerm script for athena-server
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
remove)
find -P /opt/athena/lib -type l -delete
;;
upgrade|deconfigure)
;;
failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

55
pkg-scripts/server-rules Executable file
View file

@ -0,0 +1,55 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@ --with=systemd
override_dh_systemd_enable:
dh_systemd_enable --no-enable --name athena-assignment-client athena-assignment-client.service
dh_systemd_enable --no-enable --name athena-assignment-client@ athena-assignment-client@.service
dh_systemd_enable --no-enable --name athena-domain-server athena-domain-server.service
dh_systemd_enable --no-enable --name athena-domain-server@ athena-domain-server@.service
#dh_systemd_enable --no-enable --name athena-ice-server athena-ice-server.service
#dh_systemd_enable --no-enable --name athena-ice-server@ athena-ice-server@.service
dh_systemd_enable --no-enable --name athena-server athena-server.target
dh_systemd_enable --no-enable --name athena-server@ athena-server@.target
#dh_systemd_enable --name athena-server@default athena-server@default.target
override_dh_systemd_start:
dh_systemd_start --restart-after-upgrade --no-start athena-assignment-client.service
dh_systemd_start --restart-after-upgrade --no-start athena-assignment-client@.service
dh_systemd_start --restart-after-upgrade --no-start athena-domain-server.service
dh_systemd_start --restart-after-upgrade --no-start athena-domain-server@.service
#dh_systemd_start --restart-after-upgrade --no-start athena-ice-server.service
#dh_systemd_start --restart-after-upgrade --no-start athena-ice-server@.service
dh_systemd_start --restart-after-upgrade --no-start athena-server.target
dh_systemd_start --restart-after-upgrade --no-start athena-server@.target
#dh_systemd_start --restart-after-upgrade athena-server@default.target
override_dh_installinit:
dh_installinit --noscripts
override_dh_shlibdeps:
# don't run sh_shlibdeps, it REALLY won't work. We do it ourselves anyhow
override_dh_strip:
# don't run dh_strip, we do it ourselves anyhow and we want failures to be non-fatal
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)