shadowsocks-libev: add note on nftables set restriction
[feed/packages.git] / net / seafile-server / files / seafile-server.init
1 #!/bin/sh /etc/rc.common
2
3 START=99
4 STOP=01
5
6 extra_command "generate_uci_conf" "Generate uci config"
7
8 TOPDIR=/usr/share/seafile
9 INSTALLPATH=$TOPDIR/seafile-server
10
11 uci_conf=/var/run/seafile/uci.conf
12 default_data_dir=$TOPDIR
13
14 seafile_server_latest_symlink=$TOPDIR/seafile-server-latest
15 seafile_data_dir_symlink=$TOPDIR/seafile-data
16 seahub_avatars_symlink=$INSTALLPATH/seahub/media/avatars
17 seahub_custom_media_symlink=$INSTALLPATH/seahub/media/custom
18
19 read_uci_section() {
20 local cfg="$1"
21 local data_dir
22 config_get data_dir "$cfg" data_dir "$default_data_dir"
23 uci_data_dir="$data_dir"
24 }
25
26 generate_uci_conf() {
27 local uci_data_dir="$default_data_dir"
28
29 config_load seafile-server
30 config_foreach read_uci_section seafile-server
31
32 mkdir -p "$uci_data_dir"
33
34 mkdir -p "${uci_conf%/*}"
35 cat <<- EOF > "$uci_conf"
36 export SEAFILE_UCI_CONF_DIR=/etc/seafile
37 export SEAFILE_UCI_DATA_DIR="$uci_data_dir"
38 export SEAFILE_UCI_LOG_DIR=/var/log/seafile
39 export SEAFILE_UCI_PID_DIR=/var/run/seafile
40 export SEAFILE_UCI_SOCKET_DIR=/var/run/seafile
41 EOF
42
43 [ ! -L "$seafile_server_latest_symlink" ] || rm -f "$seafile_server_latest_symlink"
44 [ ! -L "$seafile_data_dir_symlink" ] || rm -f "$seafile_data_dir_symlink"
45
46 [ ! -L "$seahub_avatars_symlink" ] || \
47 [ "$(readlink -f "$seahub_avatars_symlink")" = "$uci_data_dir/seahub-data/avatars" ] || \
48 ln -snf "$uci_data_dir/seahub-data/avatars" "$seahub_avatars_symlink"
49
50 [ ! -L "$seahub_custom_media_symlink" ] || \
51 [ "$(readlink -f "$seahub_custom_media_symlink")" = "$uci_data_dir/seahub-data/custom" ] || \
52 ln -snf "$uci_data_dir/seahub-data/custom" "$seahub_custom_media_symlink"
53 }
54
55 start() {
56 seafile start || return
57 if ! seahub start; then
58 seafile stop
59 return 1
60 fi
61 }
62
63 stop() {
64 seahub stop
65 seahub_ret=$?
66 seafile stop
67 seafile_ret=$?
68 [ "$seahub_ret" -eq 0 ] && [ "$seafile_ret" -eq 0 ]
69 }
70
71 restart() {
72 stop
73 sleep 2
74 start
75 }