Seahub编译

Seahub修改后需要编译,包括i18n和react的编译及文件拷贝,编写脚本如下:

vi $SEAHUB_DIR/mycompile.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

SEAFILE_ROOT=/opt/pzbox/seafile
SEAFILE_SERVER_DIR=$SEAFILE_ROOT/seafile-server

export CCNET_CONF_DIR=$SEAFILE_ROOT/conf/
export SEAFILE_CONF_DIR=$SEAFILE_ROOT/seafile-data/
export SEAHUB_DIR=$SEAFILE_SERVER_DIR/seahub
export PYTHONPATH=$SEAFILE_SERVER_DIR/seafile/lib/python3/site-packages/:$SEAHUB_DIR/thirdpart/:$SEAFILE_SERVER_DIR/pro/python/


function usage () {
echo "usage: $0 <options>"
echo
echo " i18n msgfmt all i18n files + compilejsi18n then deploy(copy)"
echo " react compile react and deploy(copy)"
echo " all both"
echo
}


#do i18n
function do_i18n() {
echo "msgfmt all lang (djangojs.po and django)..."
cd $SEAHUB_DIR/
for each_file in $(find ./locale -type f -name "*.po"); do
msgfmt -o ${each_file%.po}.mo $each_file
done
echo "msgfmt all lang done"
echo

echo "Compiling i18n..."
cd $SEAHUB_DIR
python manage.py compilejsi18n
cp -r ./static/scripts/i18n/* ./media/assets/scripts/i18n/
echo "Compile i18n done"
echo
}

#compile react and copy(deploy)
function do_react() {
echo "Compiling react..."
cd $SEAHUB_DIR/frontend
npm run build
cp -r build/* ../media/assets/
echo "Compile react done"
echo
}

case $1 in
i18n)
do_i18n
;;
react)
do_react
;;
all)
do_i18n && do_react
;;
*)
usage
;;
esac

其中,目录结构如下:

Seafile目录

若需精简语言列表,则修改:

$SEAHUB_DIR/seahub/settings.py

1
2
3
LANGUAGES = [
...
]

参考资料
https://bbs.seafile.com/t/topic/5886

https://www.cnblogs.com/alexyuyu/articles/7989800.html

自己摸索