diff --git a/configure.ac b/configure.ac index 42e8197b..6cba255b 100644 --- a/configure.ac +++ b/configure.ac @@ -148,6 +148,14 @@ AC_ARG_WITH(init_dir, AM_CONDITIONAL([ENABLE_INIT], [test "x${init_dir}" != "x"]) AC_SUBST(init_dir) +# Systemd directory +AC_ARG_WITH(systemd_dir, + [AS_HELP_STRING([--with-systemd-dir=], + [install systemd units to the given directory]) + ],systemd_dir=$withval) +AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x${systemd_dir}" != "x"]) +AC_SUBST(systemd_dir) + # guacd config file AC_ARG_WITH(guacd_conf, [AS_HELP_STRING([--with-guacd-conf=], @@ -1251,6 +1259,12 @@ AM_COND_IF([ENABLE_GUACLOG], [build_guaclog=yes], [build_guaclog=no]) AM_COND_IF([ENABLE_INIT], [build_init="${init_dir}"], [build_init=no]) +# +# Systemd units +# + +AM_COND_IF([ENABLE_SYSTEMD], [build_systemd="${systemd_dir}"], [build_systemd=no]) + # # Display summary # @@ -1290,6 +1304,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION guaclog .... ${build_guaclog} Init scripts: ${build_init} + Systemd units: ${build_systemd} Type \"make\" to compile $PACKAGE_NAME. " diff --git a/src/guacd/.gitignore b/src/guacd/.gitignore index 6db8c7ee..558c3194 100644 --- a/src/guacd/.gitignore +++ b/src/guacd/.gitignore @@ -2,6 +2,9 @@ # Compiled init script init.d/guacd +# Compiled systemd unit +systemd/guacd.service + # Compiled proxy guacd guacd.exe diff --git a/src/guacd/Makefile.am b/src/guacd/Makefile.am index fb8e8ebd..4dcd3d22 100644 --- a/src/guacd/Makefile.am +++ b/src/guacd/Makefile.am @@ -61,11 +61,12 @@ guacd_LDFLAGS = \ @SSL_LIBS@ EXTRA_DIST = \ - init.d/guacd.in \ - man/guacd.8.in \ + init.d/guacd.in \ + systemd/guacd.service.in \ + man/guacd.8.in \ man/guacd.conf.5.in -CLEANFILES = $(init_SCRIPTS) +CLEANFILES = $(init_SCRIPTS) $(systemd_UNITS) # Init script if ENABLE_INIT @@ -77,3 +78,12 @@ init.d/guacd: init.d/guacd.in chmod +x init.d/guacd endif +# Systemd service +if ENABLE_SYSTEMD +systemddir = @systemd_dir@ +systemd_DATA = systemd/guacd.service + +systemd/guacd.service: systemd/guacd.service.in + sed -e 's,[@]sbindir[@],$(sbindir),g' < systemd/guacd.service.in > systemd/guacd.service +endif + diff --git a/src/guacd/systemd/guacd.service.in b/src/guacd/systemd/guacd.service.in new file mode 100644 index 00000000..da3af215 --- /dev/null +++ b/src/guacd/systemd/guacd.service.in @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[Unit] +Description=Guacamole Server +Documentation=man:guacd(8) +After=network.target + +[Service] +User=daemon +ExecStart=@sbindir@/guacd -f +Restart=on-abnormal + +[Install] +WantedBy=multi-user.target