mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 04:42:49 +02:00
Initial code pass:
- adding migrate-from-athena (copying server state over, launching services) - deletes all server files on purge
This commit is contained in:
parent
ffc1b7ee53
commit
00e8ce9bb8
5 changed files with 133 additions and 5 deletions
64
pkg-scripts/deb-functions
Normal file
64
pkg-scripts/deb-functions
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
# functions to assist with deb management
|
||||
|
||||
getAthenaEnabled()
|
||||
{
|
||||
return systemctl list-units --state=loaded \
|
||||
| grep -P "(athena-assignment-client|athena-domain-server|athena-server)" \
|
||||
| cut -d' ' -f 1 \
|
||||
| xargs -I {} sh -c 'if systemctl is-enabled {} >/dev/null ; then echo {} ; fi' \
|
||||
| paste -s -d'|'
|
||||
}
|
||||
|
||||
getVircadiaEnabled()
|
||||
{
|
||||
return systemctl list-units --state=loaded \
|
||||
| grep -P "(vircadia-assignment-client|vircadia-domain-server|vircadia-server)" \
|
||||
| cut -d' ' -f 1 \
|
||||
| xargs -I {} sh -c 'if systemctl is-enabled {} >/dev/null ; then echo {} ; fi' \
|
||||
| paste -s -d'|'
|
||||
}
|
||||
|
||||
getAthenaActive()
|
||||
{
|
||||
return systemctl list-units \
|
||||
| grep -P "(athena-assignment-client|athena-domain-server|athena-server)" \
|
||||
| cut -d' ' -f 1 \
|
||||
| paste -s -d'|'
|
||||
}
|
||||
|
||||
getVircadiaActive()
|
||||
{
|
||||
return systemctl list-units \
|
||||
| grep -P "(vircadia-assignment-client|vircadia-domain-server|vircadia-server)" \
|
||||
| cut -d' ' -f 1 \
|
||||
| paste -s -d'|'
|
||||
}
|
||||
|
||||
disableList()
|
||||
{
|
||||
echo $1 \
|
||||
| xargs -d'|' \
|
||||
| systemctl disable
|
||||
}
|
||||
|
||||
enableList()
|
||||
{
|
||||
echo $1 \
|
||||
| xargs -d'|' \
|
||||
| systemctl enable
|
||||
}
|
||||
|
||||
stopList()
|
||||
{
|
||||
echo $1 \
|
||||
| xargs -d'|' \
|
||||
| systemctl stop
|
||||
}
|
||||
|
||||
startList()
|
||||
{
|
||||
echo $1 \
|
||||
| xargs -d'|' \
|
||||
| systemctl start
|
||||
}
|
|
@ -59,6 +59,7 @@ cp $ATHENA/source/pkg-scripts/vircadia-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/pkg-scripts/server-postrm debian/postrm
|
||||
cp $ATHENA/source/LICENSE debian/copyright
|
||||
|
||||
echo /etc/opt/vircadia > debian/dirs
|
||||
|
|
|
@ -28,8 +28,6 @@ if [ -d "/var/lib/vircadia/$1" ]; then
|
|||
fi
|
||||
|
||||
mkdir -p /var/lib/vircadia/$1/.local/share
|
||||
ln -s ../.. /var/lib/vircadia/$1/.local/share/Project\ Athena\ -\ dev
|
||||
ln -s ../.. /var/lib/vircadia/$1/.local/share/Project\ Athena
|
||||
ln -s ../.. /var/lib/vircadia/$1/.local/share/Vircadia\ -\ dev
|
||||
ln -s ../.. /var/lib/vircadia/$1/.local/share/Vircadia
|
||||
mkdir -p /var/lib/vircadia/$1/domain-server
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# postinst script for vircadia-server
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
. ./deb-functions
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -26,9 +27,31 @@ case "$1" in
|
|||
chown vircadia:vircadia /var/lib/vircadia
|
||||
chmod 775 /var/lib/vircadia
|
||||
if [ ! -d "/var/lib/vircadia/default" ]; then
|
||||
/opt/vircadia/new-server default 40100
|
||||
systemctl enable vircadia-server@default.target
|
||||
systemctl start vircadia-server@default.target
|
||||
if [ -d "/var/lib/athena" ]; then
|
||||
getAthenaActive # get list of active Athena services
|
||||
ATHENA_ACTIVE=$?
|
||||
getAthenaEnabled # get list of enabled Athena services
|
||||
ATHENA_ENABLED=$?
|
||||
stopList $ATHENA_ACTIVE # shutdown active Athena servers
|
||||
|
||||
# copy the server files over
|
||||
cp /etc/opt/athena/* /etc/opt/vircadia
|
||||
cp -R /var/lib/athena/* /var/lib/vircadia
|
||||
chown -R vircadia:vircadia /var/lib/vircadia/*
|
||||
find /var/lib/athena -maxdepth 3 -path "*\.local/share" -execdir sh -c 'cd share; ln -s ../.. Vircadia - dev' ';'
|
||||
find /var/lib/athena -maxdepth 3 -path "*\.local/share" -execdir sh -c 'cd share; ln -s ../.. Vircadia' ';'
|
||||
|
||||
VIRCADIA_ACTIVE=`echo $ATHENA_ACTIVE | sed 's/athena/vircadia/g'`
|
||||
VIRCADIA_ENABLED=`echo $ATHENA_ENABLED | sed 's/athena/vircadia/g'`
|
||||
|
||||
disableList $ATHENA_ENABLED
|
||||
enableList $VIRCADIA_ENABLED
|
||||
startList $VIRCADIA_ACTIVE
|
||||
else
|
||||
/opt/vircadia/new-server default 40100
|
||||
systemctl enable vircadia-server@default.target
|
||||
systemctl start vircadia-server@default.target
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
|
|
42
pkg-scripts/server-postrm
Executable file
42
pkg-scripts/server-postrm
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
# postrm script for vircadia-server
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
. ./deb-functions
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postrm> `remove'
|
||||
# * <postrm> `purge'
|
||||
# * <old-postrm> `upgrade' <new-version>
|
||||
# * <new-postrm> `failed-upgrade' <old-version> <new-version>
|
||||
# * <postrm> `disappear' <overwriter-package> <overwriter-version>
|
||||
# * <new-postrm> `abort-install;
|
||||
# * <new-postrm> `abort-install' <old-version> <new-version>
|
||||
# * <new-postrm> `abort-upgrade' <old-version> <new-version>
|
||||
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
purge)
|
||||
rm -r /etc/opt/vircadia
|
||||
rm -r /var/lib/vircadia
|
||||
;;
|
||||
|
||||
remove|upgrade|failed-upgrade|disappear|abort-install|abort-upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postrm 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
|
Loading…
Reference in a new issue