1 #!/bin/sh /etc/rc.common
6 extra_command
"generate_uci_conf" "Generate uci config"
8 TOPDIR
=/usr
/share
/seafile
9 INSTALLPATH
=$TOPDIR/seafile-server
11 uci_conf
=/var
/run
/seafile
/uci.conf
12 default_data_dir
=$TOPDIR
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
22 config_get data_dir
"$cfg" data_dir
"$default_data_dir"
23 uci_data_dir
="$data_dir"
27 local uci_data_dir
="$default_data_dir"
29 config_load seafile-server
30 config_foreach read_uci_section seafile-server
32 mkdir
-p "$uci_data_dir"
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
43 [ ! -L "$seafile_server_latest_symlink" ] ||
rm -f "$seafile_server_latest_symlink"
44 [ ! -L "$seafile_data_dir_symlink" ] ||
rm -f "$seafile_data_dir_symlink"
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"
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"
56 seafile start ||
return
57 if ! seahub start
; then
68 [ "$seahub_ret" -eq 0 ] && [ "$seafile_ret" -eq 0 ]