[Koha-patches] [PATCH 22/28] Centralize creation of Koha instance dirs.
Lars Wirzenius
lars at catalyst.net.nz
Tue May 25 03:44:21 CEST 2010
---
debian/scripts/koha-create | 19 +------------
debian/scripts/koha-create-dirs | 56 +++++++++++++++++++++++++++++++++++++++
debian/scripts/koha-dump | 1 +
debian/scripts/koha-restore | 5 +++
4 files changed, 63 insertions(+), 18 deletions(-)
create mode 100755 debian/scripts/koha-create-dirs
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index 7a7fa45..45f65e4 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -84,24 +84,7 @@ adduser --no-create-home --disabled-login --gecos "Koha instance $username" \
# Create the site-specific directories.
-mkdir "/etc/koha/sites/$name"
-
-mkdir "/var/lock/koha/$name"
-mkdir "/var/lock/koha/$name/authorities"
-mkdir "/var/lock/koha/$name/biblios"
-chown -R "root:$username" "/var/lock/koha/$name"
-chmod -R g+w "/var/lock/koha/$name"
-[ -d "/var/spool/koha/$name" ] || mkdir "/var/spool/koha/$name"
-
-install -d -o "$username" -g "$username" "/var/lib/koha/$name"
-install -d -o "$username" -g "$username" "/var/lib/koha/$name/authorities"
-install -d -o "$username" -g "$username" "/var/lib/koha/$name/biblios"
-install -d -o "$username" -g "$username" "/var/lib/koha/$name/biblios/key"
-install -d -o "$username" -g "$username" "/var/lib/koha/$name/biblios/register"
-install -d -o "$username" -g "$username" "/var/lib/koha/$name/biblios/shadow"
-
-install -d "/var/run/koha/$name/authorities"
-install -d "/var/run/koha/$name/biblios"
+koha-create-dirs "$name"
# Generate Zebra database password.
diff --git a/debian/scripts/koha-create-dirs b/debian/scripts/koha-create-dirs
new file mode 100755
index 0000000..7daf57a
--- /dev/null
+++ b/debian/scripts/koha-create-dirs
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# koha-create-dirs -- Create dirs for a Koha instance.
+# Copyright 2010 Catalyst IT, Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+set -e
+
+userdir() {
+ local username="$1-koha"
+ local directory="$2"
+ if [ ! -d "$directory" ]
+ then
+ install -d -o "$username" -g "$username" "$directory"
+ fi
+}
+
+rootdir() {
+ local directory="$1"
+ if [ ! -d "$directory" ]
+ then
+ install -d -o root -g root "$directory"
+ fi
+}
+
+for name in "$@"
+do
+ rootdir "/var/spool/koha/$name"
+ userdir "$name" "/etc/koha/sites/$name"
+ userdir "$name" "/var/lib/koha/$name"
+ userdir "$name" "/var/lib/koha/$name/authorities"
+ userdir "$name" "/var/lib/koha/$name/biblios"
+ userdir "$name" "/var/lib/koha/$name/biblios/key"
+ userdir "$name" "/var/lib/koha/$name/biblios/register"
+ userdir "$name" "/var/lib/koha/$name/biblios/shadow"
+ userdir "$name" "/var/lock/koha/$name"
+ userdir "$name" "/var/lock/koha/$name/authorities"
+ userdir "$name" "/var/lock/koha/$name/biblios"
+ userdir "$name" "/var/run/koha/$name"
+ userdir "$name" "/var/run/koha/$name/authorities"
+ userdir "$name" "/var/run/koha/$name/biblios"
+done
+
diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump
index ef3e4cc..ab2995e 100755
--- a/debian/scripts/koha-dump
+++ b/debian/scripts/koha-dump
@@ -60,6 +60,7 @@ tar -C / -czf "$metadump" \
"etc/koha/sites/$name" \
"etc/apache2/sites-available/$name" \
"etc/apache2/sites-enabled/$name" \
+ "var/lib/koha/$name" \
"var/log/koha/$name"
echo "Done."
diff --git a/debian/scripts/koha-restore b/debian/scripts/koha-restore
index f4750e4..6e15fd0 100755
--- a/debian/scripts/koha-restore
+++ b/debian/scripts/koha-restore
@@ -57,6 +57,11 @@ adduser --no-create-home --disabled-login --gecos "Koha instance $username" \
--quiet "$username"
+# Create dirs. Some of them will be in the tarball, but not all, e.g.,
+# /var/run and /var/lock.
+koha-create-dirs "$name"
+
+
# Unpack tarball.
tar -C / -xf "$configdump"
--
1.7.1
More information about the Koha-patches
mailing list