Skip to content

Commit

Permalink
Merge pull request #30 from Worteks/issue-22-cache-dir
Browse files Browse the repository at this point in the history
Move cache dirs in /var
  • Loading branch information
coudot authored Oct 28, 2020
2 parents f8f0af4 + d6f1071 commit 6db3ec5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
4 changes: 4 additions & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
# To read the actual password in the posthook script, use a base64_decode function/tool
#$posthook_password_encodebase64 = false;

# Cache directory
#$smarty_compile_dir = "/var/cache/service-desk/templates_c";
#$smarty_cache_dir = "/var/cache/service-desk/cache";

# Allow to override current settings with local configuration
if (file_exists (dirname (__FILE__) . '/config.inc.local.php')) {
include dirname (__FILE__) . '/config.inc.local.php';
Expand Down
7 changes: 5 additions & 2 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
#==============================================================================
require_once(SMARTY);

$compile_dir = $smarty_compile_dir ? $smarty_compile_dir : "../templates_c/";
$cache_dir = $smarty_cache_dir ? $smarty_cache_dir : "../cache/";

$smarty = new Smarty();
$smarty->escape_html = true;
$smarty->setTemplateDir('../templates/');
$smarty->setCompileDir('../templates_c/');
$smarty->setCacheDir('../cache/');
$smarty->setCompileDir($compile_dir);
$smarty->setCacheDir($cache_dir);
$smarty->debugging = $debug;

error_reporting(0);
Expand Down
4 changes: 4 additions & 0 deletions packaging/debian/replace_cache_dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sed -i 's:^#$smarty_cache_dir.*:$smarty_cache_dir = "/var/cache/service-desk/cache";:' debian/service-desk/usr/share/service-desk/conf/config.inc.php
sed -i 's:^#$smarty_compile_dir.*:$smarty_compile_dir = "/var/cache/service-desk/templates_c";:' debian/service-desk/usr/share/service-desk/conf/config.inc.php
8 changes: 6 additions & 2 deletions packaging/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export DH_COMPAT=9
%:
dh $@

override_dh_install:
dh_install
debian/replace_cache_dirs

override_dh_fixperms:
dh_fixperms
chown www-data:www-data debian/service-desk/usr/share/service-desk/cache
chown www-data:www-data debian/service-desk/usr/share/service-desk/templates_c
chown www-data:www-data debian/service-desk/var/cache/service-desk/cache
chown www-data:www-data debian/service-desk/var/cache/service-desk/templates_c
4 changes: 2 additions & 2 deletions packaging/debian/service-desk.dirs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/usr/share/service-desk/cache
/usr/share/service-desk/templates_c
/var/cache/service-desk/cache
/var/cache/service-desk/templates_c
14 changes: 9 additions & 5 deletions packaging/rpm/SPECS/service-desk.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
%define sd_realname ltb-project-%{name}
%define sd_version 0.3
%define sd_destdir /usr/share/%{name}
%define sd_cachedir /var/cache/%{name}

#=================================================
# Header
Expand Down Expand Up @@ -56,13 +57,13 @@ rm -rf %{buildroot}

# Create directories
mkdir -p %{buildroot}/%{sd_destdir}
mkdir -p %{buildroot}/%{sd_destdir}/cache
mkdir -p %{buildroot}/%{sd_cachedir}/cache
mkdir -p %{buildroot}/%{sd_destdir}/conf
mkdir -p %{buildroot}/%{sd_destdir}/htdocs
mkdir -p %{buildroot}/%{sd_destdir}/lang
mkdir -p %{buildroot}/%{sd_destdir}/lib
mkdir -p %{buildroot}/%{sd_destdir}/templates
mkdir -p %{buildroot}/%{sd_destdir}/templates_c
mkdir -p %{buildroot}/%{sd_cachedir}/templates_c
mkdir -p %{buildroot}/etc/httpd/conf.d

# Copy files
Expand All @@ -78,17 +79,19 @@ install -m 644 templates/* %{buildroot}/%{sd_destdir}/templates
## Apache configuration
install -m 644 %{SOURCE1} %{buildroot}/etc/httpd/conf.d/service-desk.conf

# Adapt Smarty path
# Adapt Smarty paths
sed -i 's:/usr/share/php/smarty3:/usr/share/php/Smarty:' %{buildroot}%{sd_destdir}/conf/config.inc.php
sed -i 's:^#$smarty_cache_dir.*:$smarty_cache_dir = "'%{sd_cachedir}/cache'";:' %{buildroot}%{sd_destdir}/conf/config.inc.php
sed -i 's:^#$smarty_compile_dir.*:$smarty_compile_dir = "'%{sd_cachedir}/templates_c'";:' %{buildroot}%{sd_destdir}/conf/config.inc.php

%post
#=================================================
# Post Installation
#=================================================

# Change owner
/bin/chown apache:apache %{sd_destdir}/cache
/bin/chown apache:apache %{sd_destdir}/templates_c
/bin/chown apache:apache %{sd_cachedir}/cache
/bin/chown apache:apache %{sd_cachedir}/templates_c

#=================================================
# Cleaning
Expand All @@ -104,6 +107,7 @@ rm -rf %{buildroot}
%config(noreplace) %{sd_destdir}/conf/config.inc.php
%config(noreplace) /etc/httpd/conf.d/service-desk.conf
%{sd_destdir}
%{sd_cachedir}

#=================================================
# Changelog
Expand Down

0 comments on commit 6db3ec5

Please sign in to comment.