1#!/usr/local/bin/bash 2 3echo "" 4 5SCRIPT=$(readlink -f "$0") 6INSTALLPATH=$(dirname "${SCRIPT}") 7TOPDIR=$(dirname "${INSTALLPATH}") 8default_ccnet_conf_dir=${TOPDIR}/ccnet 9default_seafile_data_dir=${TOPDIR}/seafile-data 10default_conf_dir=${TOPDIR}/conf 11seaf_fsck=${INSTALLPATH}/seafile/bin/seaf-fsck 12 13export PATH=${INSTALLPATH}/seafile/bin:$PATH 14export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH} 15 16script_name=$0 17function usage () { 18 echo "usage : " 19 echo "$(basename ${script_name}) [-h/--help] [-r/--repair] [-E/--export path_to_export] [repo_id_1 [repo_id_2 ...]]" 20 echo "" 21} 22 23function validate_ccnet_conf_dir () { 24 if [[ ! -d ${default_ccnet_conf_dir} ]]; then 25 echo "Error: there is no ccnet config directory." 26 echo "Have you run setup-seafile.sh before this?" 27 echo "" 28 exit -1; 29 fi 30} 31 32function validate_seafile_data_dir () { 33 if [[ ! -d ${default_seafile_data_dir} ]]; then 34 echo "Error: there is no seafile server data directory." 35 echo "Have you run setup-seafile.sh before this?" 36 echo "" 37 exit 1; 38 fi 39} 40 41function run_seaf_fsck () { 42 validate_ccnet_conf_dir; 43 validate_seafile_data_dir; 44 45 echo "Starting seaf-fsck, please wait ..." 46 echo 47 48 LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_fsck} \ 49 -c "${default_ccnet_conf_dir}" -d "${default_seafile_data_dir}" \ 50 -F "${default_conf_dir}" \ 51 ${seaf_fsck_opts} 52 53 echo "seaf-fsck run done" 54 echo 55} 56 57if [ $# -gt 0 ]; 58then 59 for param in $@; 60 do 61 if [ ${param} = "-h" -o ${param} = "--help" ]; 62 then 63 usage; 64 exit 1; 65 fi 66 done 67fi 68 69seaf_fsck_opts=$@ 70run_seaf_fsck; 71 72echo "Done." 73