summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
author Marcel Saegebarth <marc@mos6581.de>2015-02-23 18:31:39 +0100
committer Willy Sudiarto Raharjo <willysr@slackbuilds.org>2015-02-28 03:01:51 +0700
commit86fa2f111f4904da8199c9ec812450e9a79d1822 (patch)
tree16427bac032b2a9d81b8119cde94a345c8bda1d1 /network
parent8fdad9c92d349858aa0487025c96d3f7c540a35f (diff)
downloadslackbuilds-86fa2f111f4904da8199c9ec812450e9a79d1822.tar.gz
slackbuilds-86fa2f111f4904da8199c9ec812450e9a79d1822.tar.xz
network/seafile-server: Added garbage collector and fix long option.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r--network/seafile-server/patch-seafile-controller-pid-path.diff11
-rw-r--r--network/seafile-server/patch-seafile-controller-pid-path.diff.gzbin372 -> 0 bytes
-rw-r--r--network/seafile-server/seafile75
-rw-r--r--network/seafile-server/seafile-server.SlackBuild4
4 files changed, 84 insertions, 6 deletions
diff --git a/network/seafile-server/patch-seafile-controller-pid-path.diff b/network/seafile-server/patch-seafile-controller-pid-path.diff
new file mode 100644
index 0000000000..b9698206ea
--- /dev/null
+++ b/network/seafile-server/patch-seafile-controller-pid-path.diff
@@ -0,0 +1,11 @@
+--- controller/seafile-controller.c.orig 2015-02-05 13:00:40.096813074 +0100
++++ controller/seafile-controller.c 2015-02-05 13:03:44.628487779 +0100
+@@ -576,7 +576,7 @@
+ static void
+ init_pidfile_path (SeafileController *ctl)
+ {
+- char *pid_dir = g_build_filename (topdir, "pids", NULL);
++ char *pid_dir = g_build_filename (ctl->seafile_dir, "pids", NULL);
+ if (!g_file_test(pid_dir, G_FILE_TEST_EXISTS)) {
+ if (g_mkdir(pid_dir, 0777) < 0) {
+ seaf_warning("failed to create pid dir %s: %s", pid_dir, strerror(errno));
diff --git a/network/seafile-server/patch-seafile-controller-pid-path.diff.gz b/network/seafile-server/patch-seafile-controller-pid-path.diff.gz
deleted file mode 100644
index fd5e2ff65d..0000000000
--- a/network/seafile-server/patch-seafile-controller-pid-path.diff.gz
+++ /dev/null
Binary files differ
diff --git a/network/seafile-server/seafile b/network/seafile-server/seafile
index 0454531932..fd80c1d68b 100644
--- a/network/seafile-server/seafile
+++ b/network/seafile-server/seafile
@@ -1,6 +1,6 @@
#!/bin/sh
-# Simple `seafile-admin` wrapper script.
+# Simple `seafile-admin` & `seafserv-gc` wrapper script.
# Copyright 2015 Marcel Saegebarth <marc@mos6581.de>
# All rights reserved.
@@ -24,18 +24,82 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+THIS_NAME=$(basename ${0})
WORKING_DIR=${WORKING_DIR:-/opt/haiwen}
PYTHONPATH=$WORKING_DIR/seafile-server/seahub/thirdpart:$PYTHONPATH
PATH=$PYTHONPATH:$PATH
SEAFILEUSER=seafile
+SEAFILEDATA=${SEAFILEDATA:-""}
+OPTHELP=${OPTHELP:-no}
+ARGUMENTS=${ARGUMENTS:-$1}
-set -e
+set -o pipefail
+set -o nounset
+
+alias printf=$(command -v printf)
+
+getopt -T > /dev/null
+if [ $? -eq 4 ]; then
+ ARGS=$(getopt -a -n "$THIS_NAME" -l data-directory:,help -o d:h -- "$@")
+ if [ $? -ne 0 ]; then
+ printf '\n' && exit 1
+ fi
+ eval set -- $ARGS
+else
+ printf '%s\n' "Failed: Require GNU enhanced version. Exit." && exit 1
+fi
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -d | --data-directory) SEAFILEDATA=$2 ;;
+ -h | --help) OPTHELP=yes ;;
+ --) shift; break;;
+ esac
+ shift
+done
+
+if [ "$OPTHELP" = "yes" ]; then
+ cat << EOF
+${THIS_NAME}
+
+Usage: seafile start|stop|restart|setup|create-admin|reset-admin|cleanup [-d <seafile-data-directory>]
+
+Options
+ -d, --data-directory Specify seafile data directory for garbage collector or
+ alternatively set the SEAFILEDATA environment variable.
+ if not used it will ask for the directory.
+ -h, --help Displays this help message.
+EOF
+ exit 0
+fi
execute () {
su -s /bin/sh -l $SEAFILEUSER -c "export PYTHONPATH=$PYTHONPATH PATH=$PATH && cd $WORKING_DIR && seafile-admin $1"
}
-case "$1" in
+garbage_collector () {
+ if [ -z "$SEAFILEDATA" ]; then
+ read -p 'Enter seafile data directory: ' SEAFILEDATA
+ fi
+
+ # check if directory
+ if [ ! -d "$SEAFILEDATA" ]; then
+ printf '\n%s\n' "Couldn't find directory '$SEAFILEDATA'" && exit 1
+ fi
+
+ # check if correct directory by checking for 'seafile.db'
+ if [ ! -f "$SEAFILEDATA/seafile.db" ]; then
+ printf '\n%s\n' "Couldn't find 'seafile.db' in directory '$SEAFILEDATA'" && exit 1
+ fi
+
+ # as from the manual, stop seafile first and start again after the garbage
+ # collection
+ execute stop && \
+ su -s /bin/sh -l $SEAFILEUSER -c "seafserv-gc -c \"$WORKING_DIR/ccnet\" -d \"$SEAFILEDATA\"" && \
+ execute start
+}
+
+case "$ARGUMENTS" in
start)
execute start
;;
@@ -54,9 +118,12 @@ case "$1" in
create-admin)
execute create-admin
;;
+ cleanup)
+ garbage_collector
+ ;;
*)
cat << EOF
-Usage: seafile start|stop|restart|setup|create-admin|reset-admin
+Usage: seafile start|stop|restart|setup|create-admin|reset-admin|cleanup [-d <seafile-data-directory>]
EOF
;;
esac
diff --git a/network/seafile-server/seafile-server.SlackBuild b/network/seafile-server/seafile-server.SlackBuild
index 23e727072b..0e538645a0 100644
--- a/network/seafile-server/seafile-server.SlackBuild
+++ b/network/seafile-server/seafile-server.SlackBuild
@@ -27,7 +27,7 @@
PRGNAM=seafile-server
SRCNAM=seafile
VERSION=${VERSION:-4.0.5}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -86,7 +86,7 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
-zcat $CWD/patch-seafile-controller-pid-path.diff.gz | patch -p0
+cat $CWD/patch-seafile-controller-pid-path.diff | patch -p0
sh autogen.sh
CFLAGS="$SLKCFLAGS" \