mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-11 18:48:26 +00:00
Make service installation optional
This commit is contained in:
parent
9ee4e70e1d
commit
6e9167dcc9
@ -77,6 +77,8 @@ curl -sL http://git.io/vtf5N | sudo bash -s steam
|
||||
|
||||
NB: You may want to change the `bash -s` parameter to fit your steam user if different from `steam`.
|
||||
|
||||
If you want to install the `arkmanager` service, append the `--install-service` option to the install command.
|
||||
|
||||
This will copy the `arkmanager` script and its daemon to the proper directories and will create an empty log directory in `/var/log` for ARK Server Tools.
|
||||
|
||||
To instead perform a user-install of ARK Server Tools as an unprivileged user, run this command:
|
||||
|
||||
@ -13,6 +13,7 @@ args=()
|
||||
output=/dev/null
|
||||
unstable=
|
||||
userinstall=
|
||||
installservice=
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
@ -44,6 +45,7 @@ fi
|
||||
|
||||
function doInstallFromCommit(){
|
||||
local commit="$1"
|
||||
shift
|
||||
tmpdir="$(mktemp -t -d "ark-server-tools-XXXXXXXX")"
|
||||
if [ -z "$tmpdir" ]; then echo "Unable to create temporary directory"; exit 1; fi
|
||||
cd "$tmpdir"
|
||||
@ -55,7 +57,7 @@ function doInstallFromCommit(){
|
||||
-e "s|^arkstTag='.*'|arkstTag='${tagname}'|" \
|
||||
arkmanager
|
||||
echo "Running install.sh"
|
||||
bash install.sh "$steamcmd_user" "${reinstall_args[@]}"
|
||||
bash install.sh "$steamcmd_user" "$@"
|
||||
result=$?
|
||||
cd /
|
||||
rm -rf "$tmpdir"
|
||||
@ -85,7 +87,7 @@ function doInstallFromRelease(){
|
||||
echo "Latest release is ${tagname}"
|
||||
echo "Getting commit for latest release..."
|
||||
local commit="$(curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/tags/${tagname}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p')"
|
||||
doInstallFromCommit "$commit"
|
||||
doInstallFromCommit "$commit" "$@"
|
||||
else
|
||||
echo "Unable to get latest release"
|
||||
return 1
|
||||
@ -94,14 +96,15 @@ function doInstallFromRelease(){
|
||||
|
||||
function doInstallFromBranch(){
|
||||
channel="$1"
|
||||
shift
|
||||
commit="`curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/heads/${channel}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p'`"
|
||||
|
||||
if [ -z "$commit" ]; then
|
||||
if [ -n "$unstable" ]; then
|
||||
echo "Channel ${channel} not found - trying master"
|
||||
doInstallFromBranch master
|
||||
doInstallFromBranch master "$@"
|
||||
else
|
||||
doInstallFromRelease
|
||||
doInstallFromRelease "$@"
|
||||
fi
|
||||
else
|
||||
doInstallFromCommit "$commit"
|
||||
@ -112,8 +115,8 @@ function doInstallFromBranch(){
|
||||
cd "$TEMP"
|
||||
|
||||
if [ "$channel" = "master" ] && [ -z "$unstable" ]; then
|
||||
doInstallFromRelease
|
||||
doInstallFromRelease "${args[@]}"
|
||||
else
|
||||
doInstallFromBranch "$channel"
|
||||
doInstallFromBranch "$channel" "${args[@]}"
|
||||
fi
|
||||
|
||||
|
||||
132
tools/install.sh
132
tools/install.sh
@ -4,6 +4,7 @@ userinstall=no
|
||||
steamcmd_user=
|
||||
showusage=no
|
||||
migrateconfig=no
|
||||
installservice=no
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
@ -67,6 +68,9 @@ while [ -n "$1" ]; do
|
||||
--migrate-config)
|
||||
migrateconfig=yes
|
||||
;;
|
||||
--install-service)
|
||||
installservice=yes
|
||||
;;
|
||||
-*)
|
||||
echo "Invalid option '$1'"
|
||||
showusage=yes
|
||||
@ -141,6 +145,8 @@ if [ "$showusage" == "yes" ]; then
|
||||
echo " [LIBEXECDIR=${LIBEXECDIR}]"
|
||||
echo "--datadir Specify the directory under which to install support files"
|
||||
echo " [DATADIR=${DATADIR}]"
|
||||
echo "--install-service"
|
||||
echo " Install the service"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -215,38 +221,73 @@ else
|
||||
-e "s|^DATADIR=.*|DATADIR=\"${DATADIR}\"|" \
|
||||
"${INSTALL_ROOT}${LIBEXECDIR}/arkmanager-uninstall.sh"
|
||||
|
||||
# Copy arkdaemon to /etc/init.d ,set permissions and add it to boot
|
||||
if [ -f /lib/lsb/init-functions ]; then
|
||||
# on debian 8, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit
|
||||
if [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
mkdir -p "${INSTALL_ROOT}${LIBEXECDIR}"
|
||||
cp systemd/arkmanager.init "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
chmod +x "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
cp systemd/arkmanager.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
sed -i "s|=/usr/libexec/arkmanager/|=${LIBEXECDIR}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
cp systemd/arkmanager@.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
sed -i "s|=/usr/bin/|=${BINDIR}/|;s|=steam$|=${steamcmd_user}|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
if [ -z "${INSTALL_ROOT}" ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable arkmanager.service
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "systemctl disable arkmanager.service"
|
||||
fi
|
||||
else # systemd not present, so use sysvinit
|
||||
cp lsb/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
if [ "$installservice" = "yes" ]; then
|
||||
# Copy arkdaemon to /etc/init.d ,set permissions and add it to boot
|
||||
if [ -f /lib/lsb/init-functions ]; then
|
||||
# on debian 8, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit
|
||||
if [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
mkdir -p "${INSTALL_ROOT}${LIBEXECDIR}"
|
||||
cp systemd/arkmanager.init "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
chmod +x "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
cp systemd/arkmanager.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
sed -i "s|=/usr/libexec/arkmanager/|=${LIBEXECDIR}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
cp systemd/arkmanager@.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
sed -i "s|=/usr/bin/|=${BINDIR}/|;s|=steam$|=${steamcmd_user}|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
if [ -z "${INSTALL_ROOT}" ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable arkmanager.service
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "systemctl disable arkmanager.service"
|
||||
fi
|
||||
else # systemd not present, so use sysvinit
|
||||
cp lsb/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
# add to startup if the system use sysinit
|
||||
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
|
||||
update-rc.d arkmanager defaults
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "update-rc.d -f arkmanager remove"
|
||||
fi
|
||||
fi
|
||||
elif [ -f /etc/rc.d/init.d/functions ]; then
|
||||
# on RHEL 7, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit
|
||||
if [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
mkdir -p "${INSTALL_ROOT}${LIBEXECDIR}"
|
||||
cp systemd/arkmanager.init "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
chmod +x "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
cp systemd/arkmanager.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
sed -i "s|=/usr/libexec/arkmanager/|=${LIBEXECDIR}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
cp systemd/arkmanager@.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
sed -i "s|=/usr/bin/|=${BINDIR}/|;s|=steam$|=${steamcmd_user}|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
if [ -z "${INSTALL_ROOT}" ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable arkmanager.service
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "systemctl disable arkmanager.service"
|
||||
fi
|
||||
else # systemd not preset, so use sysvinit
|
||||
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
if [ -x /sbin/chkconfig -a -z "${INSTALL_ROOT}" ]; then
|
||||
chkconfig --add arkmanager
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "chkconfig arkmanager off"
|
||||
fi
|
||||
fi
|
||||
elif [ -f /sbin/runscript ]; then
|
||||
cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
# add to startup if the system use sysinit
|
||||
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
|
||||
update-rc.d arkmanager defaults
|
||||
sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
if [ -x /sbin/rc-update -a -z "${INSTALL_ROOT}" ]; then
|
||||
rc-update add arkmanager default
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "update-rc.d -f arkmanager remove"
|
||||
echo "rc-update del arkmanager default"
|
||||
fi
|
||||
fi
|
||||
elif [ -f /etc/rc.d/init.d/functions ]; then
|
||||
# on RHEL 7, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit
|
||||
if [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
elif [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
mkdir -p "${INSTALL_ROOT}${LIBEXECDIR}"
|
||||
cp systemd/arkmanager.init "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
@ -261,39 +302,6 @@ else
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "systemctl disable arkmanager.service"
|
||||
fi
|
||||
else # systemd not preset, so use sysvinit
|
||||
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||
if [ -x /sbin/chkconfig -a -z "${INSTALL_ROOT}" ]; then
|
||||
chkconfig --add arkmanager
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "chkconfig arkmanager off"
|
||||
fi
|
||||
fi
|
||||
elif [ -f /sbin/runscript ]; then
|
||||
cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
if [ -x /sbin/rc-update -a -z "${INSTALL_ROOT}" ]; then
|
||||
rc-update add arkmanager default
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "rc-update del arkmanager default"
|
||||
fi
|
||||
elif [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||
mkdir -p "${INSTALL_ROOT}${LIBEXECDIR}"
|
||||
cp systemd/arkmanager.init "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
chmod +x "${INSTALL_ROOT}${LIBEXECDIR}/arkmanager.init"
|
||||
cp systemd/arkmanager.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
sed -i "s|=/usr/libexec/arkmanager/|=${LIBEXECDIR}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||
cp systemd/arkmanager@.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
sed -i "s|=/usr/bin/|=${BINDIR}/|;s|=steam$|=${steamcmd_user}|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager@.service"
|
||||
if [ -z "${INSTALL_ROOT}" ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable arkmanager.service
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "systemctl disable arkmanager.service"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user