summaryrefslogtreecommitdiff
path: root/www/seahub/files/patch-scripts_setup-seafile.sh
blob: 7756ea50005251c6a51c8225c5d3e8a2957b0a42 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
--- scripts/setup-seafile.sh.orig	2020-02-09 03:22:51 UTC
+++ scripts/setup-seafile.sh
@@ -14,6 +14,8 @@ export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/
 
 server_manual_http='https://download.seafile.com/published/seafile-manual/home.md'
 
+os_bsd=$(uname | grep -cm1 -e BSD -e DragonFly)
+
 function welcome () {
     echo "-----------------------------------------------------------------"
     echo "This script will guide you to config and setup your seafile server."
@@ -330,10 +332,17 @@ fi
 }
 
 function copy_user_manuals() {
-    src_docs_dir=${INSTALLPATH}/seafile/docs/
+    if [ $os_bsd == "1" ]; then
+        src_docs_dir=${INSTALLPATH}/seafile/share/doc/seafile/
+    else
+        src_docs_dir=${INSTALLPATH}/seafile/docs/
+    fi
     library_template_dir=${default_seafile_data_dir}/library-template
     mkdir -p ${library_template_dir}
     cp -f ${src_docs_dir}/*.doc ${library_template_dir}
+    if [ $os_bsd == "1" ]; then
+        chown -R %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "${library_template_dir}"
+    fi
 }
 
 function parse_params() {
@@ -621,7 +630,12 @@ function get_seahub_admin_passwd () {
 echo "Creating database now, it may take one minute, please wait... "
 echo
 
-cd ${TOPDIR}/ccnet && mkdir -m 0755 GroupMgr misc OrgMgr PeerMgr && cd -
+if [ $os_bsd == "1" ]; then
+    cd ${TOPDIR}/ccnet && install -d -m 0755 -o %%SEAFILE_USER%% -g %%SEAFILE_GROUP%% \
+    GroupMgr misc OrgMgr PeerMgr && cd -
+else
+    cd ${TOPDIR}/ccnet && mkdir -m 0755 GroupMgr misc OrgMgr PeerMgr && cd -
+fi
 
 ccnet_group_db=${TOPDIR}/ccnet/GroupMgr/groupmgr.db
 ccnet_group_sql=${INSTALLPATH}/sql/sqlite/groupmgr.sql
@@ -699,6 +713,14 @@ chmod 0600 "$dest_settings_py"
 chmod 0700 "$default_ccnet_conf_dir"
 chmod 0700 "$default_seafile_data_dir"
 chmod 0700 "$default_conf_dir"
+if [ $os_bsd == "1" ]; then
+	for file in "$dest_settings_py" "$default_ccnet_conf_dir" \
+	"$default_conf_dir" "$seahub_db" "$ccnet_group_db" "$ccnet_config_db" \
+	"$ccnet_org_db" "$ccnet_user_db"; do
+		chown %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$file"
+	done
+	chown -R %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$default_seafile_data_dir"
+fi
 
 # -------------------------------------------
 # copy user manuals to library template
@@ -715,9 +737,17 @@ echo
 echo "-----------------------------------------------------------------"
 echo "Your seafile server configuration has been completed successfully." 
 echo "-----------------------------------------------------------------"
-echo 
-echo "run seafile server:     ./seafile.sh { start | stop | restart }"
-echo "run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }"
+echo
+if [ $os_bsd == "1" ]; then
+	echo "run seafile server:     sysrc seafile_enable=YES"
+	echo "                        service seafile { start | stop | restart }"
+	echo "run seahub  server:     sysrc seahub_enable=YES"
+	echo "                        service seahub { start | stop | restart }"
+	echo "run reset-admin:        ./reset-admin.sh"
+else
+	echo "run seafile server:     ./seafile.sh { start | stop | restart }"
+	echo "run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }"
+fi
 echo
 echo "-----------------------------------------------------------------"
 echo "If the server is behind a firewall, remember to open these tcp ports:"