]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Improve Makefile to use templates data
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 17 Jul 2015 07:53:32 +0000 (09:53 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 13 Aug 2015 06:51:50 +0000 (08:51 +0200)
gui/baculum/Makefile
gui/baculum/examples/rpm-template/baculum-apache.conf [new file with mode: 0644]
gui/baculum/examples/rpm-template/baculum-lighttpd.conf [new file with mode: 0644]
gui/baculum/examples/rpm-template/baculum-lighttpd.service [new file with mode: 0644]
gui/baculum/examples/rpm-template/baculum.spec [new file with mode: 0644]
gui/baculum/examples/rpm-template/baculum.startup [new file with mode: 0755]
gui/baculum/examples/rpm-template/baculum.users [new file with mode: 0644]

index 5ce11debbe059cbf4f03c66dacff41346b3a6802..4575a7baf40c1076b08ea8ce2d4e1b3ec96d4e67 100644 (file)
@@ -1,12 +1,29 @@
+NAME = baculum
+VERSION = 7.0.6b
+SAMPLETYPE = rpm-template
+SYSUSRDIR = /usr
+SYSCONFDIR = /etc
+SYSVARDIR = /var
+CONFDIR = $(SYSCONFDIR)/$(NAME)
+HTTPDCONFDIR = $(SYSCONFDIR)/httpd/conf.d
+UNITDIR = $(SYSUSRDIR)/lib/systemd/system
+WWWDIR = $(SYSUSRDIR)/share/$(NAME)/htdocs
+SELINUXDIR = $(SYSUSRDIR)/share/selinux/packages/$(NAME)
+CACHEDIR = $(SYSVARDIR)/cache/$(NAME)
+LOGDIR = $(SYSVARDIR)/log
+HTTPDLOGS = $(LOGDIR)/httpd
+LIGHTTPDLOGS = $(LOGDIR)/$(NAME)
 
-prefix = .
-builddir = $(prefix)/build
+# Internal application directories
 datadir = protected
 frameworkdir = framework
 themesdir = themes
+cachedir = assets
+configdir = $(datadir)/Data
+configcachedir = $(datadir)/runtime
+samplesdir = examples/$(SAMPLETYPE)
 
 datadirsrc = $(datadir)/Class \
-    $(datadir)/Data \
     $(datadir)/JavaScript \
     $(datadir)/Lang \
     $(datadir)/Layouts \
@@ -23,26 +40,40 @@ miscfilesrc = .htaccess \
     LICENSE \
     README
 
-all: build
-
-build: prepare_build prepare_data prepare_externals prepare_themes
-
+build: prepare_build prepare_data prepare_externals prepare_themes setup
 
 prepare_build:
-       [ -d $(builddir) ] || mkdir -p $(builddir)
+       mkdir -p $(DESTDIR)$(SYSCONFDIR) \
+       $(DESTDIR)$(CONFDIR) \
+       $(DESTDIR)$(HTTPDCONFDIR) \
+       $(DESTDIR)$(UNITDIR) \
+       $(DESTDIR)$(WWWDIR) \
+       $(DESTDIR)$(SELINUXDIR) \
+       $(DESTDIR)$(LIGHTTPDLOGS) \
+       $(DESTDIR)$(CACHEDIR)
+       mkdir -p -m 700 $(DESTDIR)$(WWWDIR)/$(cachedir) \
+       $(DESTDIR)$(WWWDIR)/$(configdir) \
+       $(DESTDIR)$(WWWDIR)/$(configcachedir)
 
 prepare_data: prepare_build
-       [ -d "$(builddir)/$(datadir)" ] || mkdir -p $(builddir)/$(datadir)
-       cp -ra $(datadirsrc) $(builddir)/$(datadir)
-       cp -a $(datafilesrc) $(builddir)/$(datadir)
-       cp -a $(miscfilesrc) $(builddir)
+       mkdir -p $(DESTDIR)$(WWWDIR)/$(datadir)
+       cp -ra $(datadirsrc) $(DESTDIR)$(WWWDIR)/$(datadir)
+       cp -a $(datafilesrc) $(DESTDIR)$(WWWDIR)/$(datadir)
+       cp -a $(miscfilesrc) $(DESTDIR)$(WWWDIR)/
 
 prepare_externals: prepare_build
-       cp -ra $(frameworkdir) $(builddir)
+       cp -ra $(frameworkdir) $(DESTDIR)$(WWWDIR)
 
 prepare_themes: prepare_build
-       cp -ra $(themesdir) $(builddir)
+       cp -ra $(themesdir) $(DESTDIR)$(WWWDIR)
+
+prepare_samples:
+       install -m 640 $(samplesdir)/$(NAME)-lighttpd.conf $(DESTDIR)$(CONFDIR)
+       install -m 644 $(samplesdir)/$(NAME)-lighttpd.service $(DESTDIR)$(UNITDIR)
+       install -m 640 $(samplesdir)/$(NAME)-apache.conf $(DESTDIR)$(HTTPDCONFDIR)/$(NAME).conf
+       install -m 600 $(samplesdir)/$(NAME).users $(DESTDIR)$(WWWDIR)/$(configdir)
 
-install: build
-       [ -d $(INSTALL_ROOT) ] || mkdir -p $(INSTALL_ROOT)
-       cp -ra $(builddir) $(INSTALL_ROOT)/
+setup: prepare_samples
+       sed -i -e "s#%DOCUMENTROOT#$(WWWDIR)#g" -e "s#%LOGDIR#$(HTTPDLOGS)#g" $(DESTDIR)$(HTTPDCONFDIR)/$(NAME).conf
+       sed -i -e "s#%DOCUMENTROOT#$(WWWDIR)#g" -e "s#%LOGDIR#$(LIGHTTPDLOGS)#g" $(DESTDIR)$(CONFDIR)/$(NAME)-lighttpd.conf
+       sed -i -e "s#%CONFDIR#$(CONFDIR)#g" $(DESTDIR)$(UNITDIR)/$(NAME)-lighttpd.service
diff --git a/gui/baculum/examples/rpm-template/baculum-apache.conf b/gui/baculum/examples/rpm-template/baculum-apache.conf
new file mode 100644 (file)
index 0000000..cb20a96
--- /dev/null
@@ -0,0 +1,15 @@
+Listen 9095
+
+<VirtualHost *:9095>
+       DocumentRoot %DOCUMENTROOT
+       ServerName localhost
+       CustomLog %LOGDIR/baculum-access.log combined
+       ErrorLog %LOGDIR/baculum-error.log
+       <Directory %DOCUMENTROOT>
+               AllowOverride All
+               AuthType Basic
+               AuthName "Baculum Auth"
+               AuthUserFile %DOCUMENTROOT/protected/Data/baculum.users
+               Require valid-user
+       </Directory>
+</VirtualHost>
\ No newline at end of file
diff --git a/gui/baculum/examples/rpm-template/baculum-lighttpd.conf b/gui/baculum/examples/rpm-template/baculum-lighttpd.conf
new file mode 100644 (file)
index 0000000..d009fc8
--- /dev/null
@@ -0,0 +1,67 @@
+# Baculum WebGUI tool for Bacula Community
+#
+# Web Server Configuration
+#
+
+server.port           = 9095
+server.username       = "lighttpd"
+server.groupname      = "lighttpd"
+server.document-root  = "%DOCUMENTROOT"
+server.errorlog       = "%LOGDIR/baculum-error.log"
+accesslog.filename    = "%LOGDIR/baculum-access.log"
+server.pid-file       = "/var/run/baculum.pid"
+
+server.modules = (
+        "mod_auth",
+        "mod_alias",
+        "mod_rewrite",
+        "mod_fastcgi",
+        "mod_accesslog"
+)
+
+auth.backend          = "htpasswd"
+auth.backend.htpasswd.userfile = "%DOCUMENTROOT/protected/Data/baculum.users"
+auth.require = ( "/" => (
+        "method" => "basic",
+        "realm" => "Baculum Auth",
+        "require" => "valid-user"
+))
+
+index-file.names      = ( "index.php" )
+
+static-file.exclude-extensions = ( ".php" )
+
+dir-listing.encoding  = "utf-8"
+
+mimetype.assign = (
+   ".html" => "text/html",
+   ".gif" => "image/gif",
+   ".png" => "image/png",
+   ".ico" => "image/x-icon",
+   ".css" => "text/css",
+   ".js" => "application/javascript",
+)
+
+alias.url = (
+   "/" => "%DOCUMENTROOT/"
+)
+
+fastcgi.server = (".php"=>((
+  "bin-path"=>"/usr/bin/php-cgi",
+  "socket"=>"/tmp/php.sock",
+  "max-procs" => 1,
+  "bin-environment" => (
+    "PHP_FCGI_CHILDREN" => "4",
+    "PHP_FCGI_MAX_REQUESTS" => "10000"
+  ),
+  "bin-copy-environment" => (
+   "PATH", "SHELL", "USER"
+  ),
+  "broken-scriptfilename" => "enable"
+)))
+
+url.rewrite-once = (
+   "^/themes/(.+)$" => "/themes/$1",
+   "^/assets/(.+)$" => "/assets/$1",
+   "^/(.+)$" => "/index.php/$1"
+)
diff --git a/gui/baculum/examples/rpm-template/baculum-lighttpd.service b/gui/baculum/examples/rpm-template/baculum-lighttpd.service
new file mode 100644 (file)
index 0000000..b54937e
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=Baculum WebGUI Bacula Community tool
+After=network.target
+
+[Service]
+PIDFile=/var/run/baculum.pid
+ExecStart=/usr/sbin/lighttpd -f %CONFDIR/baculum-lighttpd.conf
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/gui/baculum/examples/rpm-template/baculum.spec b/gui/baculum/examples/rpm-template/baculum.spec
new file mode 100644 (file)
index 0000000..db7175a
--- /dev/null
@@ -0,0 +1,191 @@
+Summary:       WebGUI tool for Bacula Community program
+Name:          baculum
+Version:       7.0.6
+Release:       0.3.b%{?dist}
+License:       AGPLv3
+Group:         Applications/Internet
+URL:           http://bacula.org/
+Source0:       http://bacula.org/downloads/baculum/baculum-7.0.6b.tar.gz
+Source1:       baculum.users
+Source2:       baculum-apache.conf
+Source3:       baculum-lighttpd.conf
+Source4:       baculum-lighttpd.service
+BuildRequires: systemd-units
+BuildRequires: selinux-policy
+BuildRequires: selinux-policy-devel
+BuildRequires: checkpolicy
+Requires:      bacula-console
+# Lower version of PHP ( < 5.3.4) does not provide php-mysqlnd db driver
+# and from this reason the lowest is 5.3.4
+Requires:      php >= 5.3.4
+Requires:      php-bcmath
+Requires:      php-common
+Requires:      php-mbstring
+Requires:      php-mysqlnd
+Requires:      php-pdo
+Requires:      php-pgsql
+Requires:      php-xml
+BuildArch:     noarch
+
+%description
+The Baculum program allows the user to administer and manage Bacula jobs.
+By using Baculum it is possible to execute backup/restore operations, monitor
+current Bacula jobs, media management and others. Baculum has integrated web
+console that communicates with Bacula bconsole program.
+
+%package selinux
+Summary:               SELinux module for Baculum WebGUI tool
+Requires:              %name = %version-%release
+Group:                 Applications/Internet
+Requires(post):                policycoreutils-python
+Requires(preun):       policycoreutils-python
+
+%description selinux
+This package provides an SELinux module for Baculum WebGUI tool.
+You should install this package if you are using SELinux, that Baculum
+can be run in enforcing mode.
+
+%package httpd
+Summary:               Apache configuration for Baculum WebGUI tool
+Requires:              %name = %version-%release
+Group:                 Applications/Internet
+Requires:              httpd
+# This conflict field is required because Lighttpd and Apache
+# cannot listen on the same port at the same time. Even using diffeernt
+# ports cause problems like shared framework cache and
+# web server specific directories permissions (for lighttpd and apache
+# users).
+Conflicts:             %{name}-lighttpd
+
+%description httpd
+This package provides the Apache configuration for Baculum WebGUI tool.
+By using this module it is possible to run Baculum in Apache environment.
+
+%package lighttpd
+Summary:               Lighttpd configuration for Baculum WebGUI tool
+Requires:              %name = %version-%release
+Group:                 Applications/Internet
+Requires:              lighttpd
+Requires:              lighttpd-fastcgi
+# This conflict field is required because Lighttpd and Apache
+# cannot listen on the same port at the same time. Even using diffeernt
+# ports cause problems like shared framework cache and
+# web server specific directories permissions (for lighttpd and apache
+# users).
+Conflicts:             %{name}-httpd
+
+%description lighttpd
+This package provides the Lighttpd configuration for Baculum WebGUI tool.
+By using this module it is possible to run Baculum in Lighttpd environment.
+
+%prep
+%autosetup
+
+%build
+# Execute files preparation in build directory by Makefile
+make build
+# Compilation SELinuxu policies before loading them
+make -C examples/selinux/ -f %{_datadir}/selinux/devel/Makefile %{name}.pp
+
+%install
+mkdir -p %{buildroot}%{_datadir}/%{name}/htdocs/protected
+mkdir -p %{buildroot}%{_sysconfdir}/%{name}
+mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
+mkdir -p %{buildroot}%{_unitdir}
+mkdir -p %{buildroot}%{_localstatedir}/cache/%{name}
+mkdir -p %{buildroot}%{_var}/log/%{name}
+mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
+
+cp -ra build/. %{buildroot}%{_datadir}/%{name}/htdocs
+install -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf
+install -m 640 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/
+install -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/
+install -m 600 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/htdocs/protected/Data/%{name}.users
+install -m 644 examples/selinux/%{name}.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}.pp
+# these symbolic links indicates to Baculum's cache directory
+ln -s  %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/assets
+ln -s  %{_localstatedir}/cache/%{name} %{buildroot}%{_datadir}/%{name}/htdocs/protected/runtime
+
+%post lighttpd
+%systemd_post baculum.service
+
+%post selinux
+if [ $1 -le 1 ] ; then
+# Write access is possible for web servers user only to two directories
+# -  Data/ directory stores settings and web server HTTP Basic credentials
+# - /var/cache/baculum - cache used by framework in specific locations (assets/ and protected/runtime/)
+#   by symbolic links to cache directory
+    semanage fcontext -a -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+    restorecon -i -R '%{_datadir}/%{name}/htdocs/protected/Data' || :
+    semanage fcontext -a -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+    restorecon -i -R %{_localstatedir}/cache/%{name} || :
+    semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp 2>/dev/null || :
+fi
+
+%preun
+if [ $1 -lt 1 ] ; then
+    # remove settings and logs if exist
+    [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/settings.conf ] ||
+       rm %{_datadir}/%{name}/htdocs/protected/Data/settings.conf
+    [ ! -e %{_datadir}/%{name}/htdocs/protected/Data/baculum.log ] ||
+       rm %{_datadir}/%{name}/htdocs/protected/Data/baculum*.log
+fi
+
+%preun lighttpd
+%systemd_preun baculum-lighttpd.service
+
+%postun lighttpd
+%systemd_postun_with_restart baculum-lighttpd.service
+
+%postun selinux
+if [ $1 -eq 0 ] ; then
+    semanage fcontext -d -t httpd_sys_rw_content_t '%{_datadir}/%{name}/htdocs/protected/Data(/.*)?' 2>/dev/null || :
+    semanage fcontext -d -t httpd_cache_t '%{_localstatedir}/cache/%{name}(/.*)?' 2>/dev/null || :
+    semodule -r %{name} 2>/dev/null || :
+fi
+
+%files
+%defattr(-,root,root)
+# directory excluded here, because it needs to be provided
+# with selected web server privileges (lighttpd or apache)
+%exclude %{_datadir}/%{name}/htdocs/protected/Data/
+%{_datadir}/%{name}
+%license LICENSE
+%doc AUTHORS INSTALL README
+
+%files selinux
+%defattr(-,root,root)
+%{_datadir}/selinux/packages/%{name}/%{name}.pp
+
+%files httpd
+%defattr(644,root,root)
+# Apache logs are stored in /var/log/httpd/
+%config %{_sysconfdir}/httpd/conf.d/%{name}.conf
+%attr(700,apache,apache) %{_localstatedir}/cache/%{name}/
+%attr(-,apache,apache) %{_datadir}/%{name}/htdocs/protected/Data/
+
+%files lighttpd
+%defattr(644,root,root)
+# Lighttpd logs are stored in /var/log/baculum
+%attr(750,lighttpd,lighttpd) %{_var}/log/%{name}/
+%attr(700,lighttpd,lighttpd) %{_localstatedir}/cache/%{name}/
+%attr(-,lighttpd,lighttpd) %{_datadir}/%{name}/htdocs/protected/Data/
+%{_unitdir}/%{name}-lighttpd.service
+%config %{_sysconfdir}/%{name}/%{name}-lighttpd.conf
+
+%changelog
+ * Tue Jul 14 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.3.b
+ - Separate to subpackage Lighttpd support
+ - Add Apache subpackage
+ - Use upstream Makefile to prepare build files
+ - Cache symlbolic links only in install section
+ - Add comments to Spec
+ - Compile SELinux policies instead of install pre-compiled
+ - Add source files: baculum.users, baculum-apache.conf
+   baculum-lighttpd.conf and baculum-lighttpd.service
+ * Mon Jul 13 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.2.b
+ - Remove chkconfig and service dependencies from Spec
+ - Change Spec sections order
+ - Correct package description typos and errors
+ * Mon Jul 06 2015 Marcin Haba <marcin.haba@bacula.pl> - 7.0.6-0.1.b
+ - Spec create
diff --git a/gui/baculum/examples/rpm-template/baculum.startup b/gui/baculum/examples/rpm-template/baculum.startup
new file mode 100755 (executable)
index 0000000..a2bb4a9
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# chkconfig: 2345 91 9
+# description: This script uses Lighttpd web server for \
+#              working Baculum WebGUI tool.
+#
+
+### BEGIN INIT INFO
+# Provides:          baculum
+# Required-Start:    $local_fs $remote_fs $network $syslog $named
+# Required-Stop:     $local_fs $remote_fs $network $syslog $named
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop Baculum
+# Description:       Start the Baculum WebGUI Bacula Community tool.
+### END INIT INFO
+
+DESC="Baculum WebGUI Bacula Community tool"
+NAME=baculum
+SCRIPTNAME=/etc/init.d/$NAME
+DAEMON=/usr/sbin/lighttpd
+DAEMON_OPTS="-f /etc/baculum/baculum.lighttpd.conf"
+PIDFILE=/var/run/$NAME.pid
+LOCKFILE=/var/lock/subsys/$NAME
+
+test -x $DAEMON || exit 0
+
+check_syntax()
+{
+    $DAEMON -t $DAEMON_OPTS > /dev/null || exit $?
+}
+
+log_daemon_msg()
+{
+    logger "$@"
+}
+
+log_end_msg()
+{
+    [ $1 -eq 0 ] && RES=OK
+    logger ${RES:=FAIL}
+}
+
+rh_status() {
+    status $prog
+}
+
+if test -f /lib/lsb/init-functions; then
+. /lib/lsb/init-functions
+fi
+
+. /etc/init.d/functions
+
+case "$1" in
+    start)
+        check_syntax
+        log_daemon_msg "Starting $DESC" $NAME
+        if ! ${DAEMON} $DAEMON_OPTS
+        then
+            log_end_msg 1
+        else
+            log_end_msg 0
+            touch $LOCKFILE
+        fi
+        ;;
+    stop)
+        log_daemon_msg "Stopping $DESC" $NAME
+        if kill -TERM `<$PIDFILE`
+        then
+            rm -f $PIDFILE
+            rm -f $LOCKFILE
+            log_end_msg 0
+        else
+            log_end_msg 1
+        fi
+        ;;
+    status)
+        rh_status
+        ;;
+    restart)
+        check_syntax
+        $0 stop
+        $0 start
+        ;;
+    *)
+        echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
+        exit 1
+        ;;
+esac
+
+exit 0
\ No newline at end of file
diff --git a/gui/baculum/examples/rpm-template/baculum.users b/gui/baculum/examples/rpm-template/baculum.users
new file mode 100644 (file)
index 0000000..1375f69
--- /dev/null
@@ -0,0 +1 @@
+admin:YWG41BPzVAkN6
\ No newline at end of file