network/seafile-server: Added garbage collector and fix long option.

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Marcel Saegebarth 2015-02-23 18:31:39 +01:00 committed by Willy Sudiarto Raharjo
parent 8fdad9c92d
commit 86fa2f111f
4 changed files with 84 additions and 6 deletions

View file

@ -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));

View file

@ -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

View file

@ -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" \